1import{k as z,l as ee,g as se,r as Q,n as te,j as e,C as M,o as re,p as ae,w as ie,a as P,D as k,m as ne,b as d,c as x,t as le,e as oe,L as de,d as m}from"./index-BupwEmgm.js";import{u as j}from"./useMutation-Bor7Z28h.js";import{B as y}from"./badge-BQIsryWh.js";import{P as ce}from"./progress-BCwjoPeM.js";import{S as me,a as ue,b as xe,c as ge,d as u}from"./select-BE_BfE1n.js";import{D as he,a as pe,b as je,c as ye}from"./dialog-BMZGmwLw.js";import{A as b,a as f,b as v,c as N,d as w,e as _,f as C,g as D,h as S}from"./alert-dialog-DUbAEfZk.js";import{toast as $}from"./index-DWSsIHDv.js";import{C as B}from"./circle-check-big-DHNhhlYj.js";import{S as E}from"./send-BfXl5gst.js";import{L as be}from"./loader-circle-bywfJt-C.js";import{C as I}from"./circle-DNmRdk9G.js";import{t as U,c as fe}from"./en-US-wfBU2YNu.js";import{c as H}from"./constructNow-D3Ie8fTE.js";import{s as R,f as A}from"./format-DCW6RvxT.js";import"./index-BP4mGZh_.js";import"./index-CWzdr2iF.js";import"./index-5VGl---o.js";import"./index-z7BTQWyD.js";import"./index-Dcum08s_.js";import"./index-DtqUbmXC.js";import"./index-DZZvDXV_.js";import"./chevron-down-CZP-y2fV.js";import"./check-CfJfwHKK.js";import"./chevron-up-Cw-759n5.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ve=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 12-4-4-4 4",key:"177agl"}],["path",{d:"M12 16V8",key:"1sbj14"}]],Ne=z("CircleArrowUp",ve);/** 7 * @license lucide-react v0.475.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const we=[["path",{d:"M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z",key:"i9b6wo"}],["line",{x1:"4",x2:"4",y1:"22",y2:"15",key:"1cm3nv"}]],_e=z("Flag",we);function Ce(r,o){const i=U(r);return isNaN(o)?fe(r,NaN):(i.setDate(i.getDate()+o),i)}function G(r,o){const i=R(r),t=R(o);return+i==+t}function De(r){return+U(r)<Date.now()}function K(r){return G(r,H(r))}function Se(r){return G(r,Ce(H(r),1))}const Ae={todo:I,in_progress:be,review:Ne,completed:B,delivered:E,billed:k},O={todo:"bg-muted text-muted-foreground",in_progress:"bg-secondary/10 text-secondary",review:"bg-accent/20 text-accent-foreground",completed:"bg-green-100 text-green-700",delivered:"bg-primary/10 text-primary",billed:"bg-purple-100 text-purple-700"},Y={low:"bg-muted text-muted-foreground",medium:"bg-secondary/10 text-secondary",high:"bg-accent/20 text-accent-foreground",urgent:"bg-destructive/10 text-destructive"};function es(){var L,V;const{user:r,settings:o}=ee(),i=se(),[t,c]=Q.useState(null),[T,J]=Q.useState("all"),{data:l=[]}=te({queryKey:["all-tasks",r==null?void 0:r.email],queryFn:()=>m.entities.Task.filter({user_email:r==null?void 0:r.email},"-created_date"),enabled:!!(r!=null&&r.email)}),h=j({mutationFn:({id:s,data:a})=>m.entities.Task.update(s,a),onSuccess:(s,{id:a,data:n})=>{i.invalidateQueries({queryKey:["all-tasks"]}),(t==null?void 0:t.id)===a&&c(g=>({...g,...n}))}}),W=j({mutationFn:async s=>{await m.entities.Task.update(s.id,{status:"delivered"}),await m.entities.ActivityLog.create({action:`User submitted task "${s.title}" to employer at ${s.company}`,agent:"user",entity_type:"task",entity_id:s.id,status:"success",user_email:r==null?void 0:r.email}),await m.entities.Message.create({job_title:s.job_title,sender:"system",sender_name:"VA Agent",content:`Task "${s.title}" has been submitted to ${s.company}. Awaiting payment confirmation.`,message_type:"billing",user_email:r==null?void 0:r.email})},onSuccess:()=>{i.invalidateQueries({queryKey:["all-tasks"]}),c(null),$.success("Task submitted to employer â VA Agent will notify you when funds arrive")}}),F=j({mutationFn:async s=>{await m.functions.invoke("vaBilling",{task_id:s.id,action:"create_invoice"})},onSuccess:()=>{i.invalidateQueries({queryKey:["all-tasks"]}),i.invalidateQueries({queryKey:["user-settings"]}),c(null),$.success("Invoice created â VA Agent will track payment from the employer")}}),p=j({mutationFn:async s=>{await m.functions.invoke("vaBilling",{task_id:s.id,action:"mark_paid"})},onSuccess:()=>{i.invalidateQueries({queryKey:["all-tasks"]}),i.invalidateQueries({queryKey:["user-settings"]}
11),c(null),$.success("Payment confirmed â your balance has been updated!")}}),q=T==="all"?l:l.filter(s=>s.status===T),X=s=>{if(!s)return null;const a=new Date(s);return De(a)&&!K(a)?"Overdue":K(a)?"Today":Se(a)?"Tomorrow":A(a,"MMM d")};return e.jsxs("div",{className:"space-y-6 min-w-0 w-full",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-heading text-2xl font-bold",children:"Tasks & Calendar"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track job assignments, milestones, deadlines, and deliverables"})]}),e.jsxs(me,{value:T,onValueChange:J,children:[e.jsx(ue,{className:"w-44",children:e.jsx(xe,{})}),e.jsxs(ge,{children:[e.jsx(u,{value:"all",children:"All Tasks"}),e.jsx(u,{value:"todo",children:"To Do"}),e.jsx(u,{value:"in_progress",children:"In Progress"}),e.jsx(u,{value:"review",children:"In Review"}),e.jsx(u,{value:"completed",children:"Completed"}),e.jsx(u,{value:"delivered",children:"Delivered"}),e.jsx(u,{value:"billed",children:"Billed"})]})]})]}),l.length>0&&e.jsx("div",{className:"grid grid-cols-4 gap-2",children:[{label:"To Do",count:l.filter(s=>s.status==="todo").length,color:"text-muted-foreground",bg:"bg-muted/60",border:"border-border"},{label:"In Progress",count:l.filter(s=>s.status==="in_progress").length,color:"text-secondary",bg:"bg-secondary/10",border:"border-secondary/20"},{label:"Completed",count:l.filter(s=>s.status==="completed").length,color:"text-green-700",bg:"bg-green-500/10",border:"border-green-500/20"},{label:"Billed",count:l.filter(s=>s.status==="billed").length,color:"text-purple-700",bg:"bg-purple-500/10",border:"border-purple-500/20"}].map(({label:s,count:a,color:n,bg:g,border:Z})=>e.jsxs("div",{className:`flex flex-col items-center py-3 px-2 rounded-xl border ${g} ${Z}`,children:[e.jsx("span",{className:`text-2xl font-bold font-heading leading-none ${n}`,children:a}),e.jsx("span",{className:"text-xs text-muted-foreground mt-1",children:s})]},s))}),e.jsxs(M,{className:"border-0 shadow-sm",children:[e.jsx(re,{children:e.jsxs(ae,{className:"font-heading text-base flex items-center gap-2",children:[e.jsx(ie,{className:"w-4 h-4 text-secondary"})," Upcoming Deadlines"]})}),e.jsx(P,{children:l.filter(s=>s.due_date&&!["delivered","billed"].includes(s.status)).length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No upcoming deadlines"}):e.jsx("div",{className:"space-y-2",children:l.filter(s=>s.due_date&&!["delivered","billed"].includes(s.status)).sort((s,a)=>new Date(s.due_date)-new Date(a.due_date)).slice(0,6).map(s=>{const a=X(s.due_date),n=a==="Overdue";return e.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg cursor-pointer hover:opacity-80 transition-opacity ${n?"bg-destructive/5 border border-destructive/20":"bg-muted/50"}`,onClick:()=>c(s),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(_e,{className:`w-4 h-4 flex-shrink-0 ${n?"text-destructive":"text-secondary"}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:s.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.company})]})]}),e.jsx(y,{className:n?"bg-destructive/10 text-destructive":"bg-secondary/10 text-secondary",children:a})]},s.id)})})})]}),e.jsx("div",{className:"space-y-3",children:q.length===0?e.jsx(M,{className:"border-0 shadow-sm",children:e.jsxs(P,{className:"py-12 text-center",children:[e.jsx(B,{className:"w-10 h-10 text-muted-foreground mx-auto mb-3"}),e.jsx("p",{className:"font-medium text-sm mb-1",children:"No Tasks Found"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tasks are created by the VA Agent when an employer assigns a job to you."})]})}):q.map((s,a)=>{const n=Ae[s.status]||I;return e.jsx(ne.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:a*.03},children:e.jsx(M,{className:"border-0 shadow-sm hover:shadow-md transition-shadow cursor-pointer",onClick:()=>c(s),children:e.jsx(P,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center shrink-0 ${O[s.status]}`,children:e.jsx(n,{className:`w-4 h-4 ${s.status==="in_progress"?"animate-spin":""}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5 flex-wrap",children:[e.jsx("h3",{className:"font-medium truncate",children:s.title}),e.jsx(y,{className:Y[s.priority],children:s.priority})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[s.company," · Due: ",s.due_date?A(new Date(s.due_date),"MMM d, yyyy"):"TBD",s.billing_amount?` · $${s.billing_amount}`:""]}),e.jsx(ce,{value:s.progress||0,className:"mt-2 h-1"})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",onClick:g=>g.stopPropagation(),children:[s.status==="todo"&&e.jsx(d,{size:"sm",variant:"outline",onClick:()=>h.mutate({id:s.id,data:{status:"in_progress"}}),children:"Start"}),s.status==="in_progress"&&e.jsx(d,{size:"sm",className:"bg-secondary text-secondary-foreground",onClick:()=>h.mutate({id:s.id,data:{status:"completed",progress:100}}),children:"Mark Complete"})]})]})})})},s.id)})}),e.jsx(he,{open:!!t,onOpenChange:()=>c(null),children:e.jsxs(pe,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(je,{children:e.jsx(ye,{className:"font-heading",children:t==null?void 0:t.t
11itle})}),t&&e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx(y,{className:O[t.status],children:(L=t.status)==null?void 0:L.replace("_"," ")}),e.jsxs(y,{className:Y[t.priority],children:[t.priority," priority"]})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.description||"No description provided."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx(x,{className:"text-xs text-muted-foreground",children:"Company"}),e.jsx("p",{children:t.company||"â"})]}),e.jsxs("div",{children:[e.jsx(x,{className:"text-xs text-muted-foreground",children:"Due Date"}),e.jsx("p",{children:t.due_date?A(new Date(t.due_date),"MMM d, yyyy"):"TBD"})]}),e.jsxs("div",{children:[e.jsx(x,{className:"text-xs text-muted-foreground",children:"Progress"}),e.jsxs("p",{children:[t.progress||0,"%"]})]}),t.billing_amount&&e.jsxs("div",{children:[e.jsx(x,{className:"text-xs text-muted-foreground",children:"Billing Amount"}),e.jsxs("p",{className:"font-semibold text-secondary",children:["$",t.billing_amount]})]}),t.billing_status&&e.jsxs("div",{children:[e.jsx(x,{className:"text-xs text-muted-foreground",children:"Payment Status"}),e.jsx("p",{className:"capitalize",children:t.billing_status})]})]}),((V=t.milestones)==null?void 0:V.length)>0&&e.jsxs("div",{children:[e.jsxs(x,{className:"font-medium flex items-center gap-1 mb-2",children:[e.jsx(le,{className:"w-3 h-3"})," Milestones"]}),t.milestones.map((s,a)=>e.jsxs("div",{className:"flex items-center gap-2 py-1.5 border-b border-border last:border-0",children:[s.completed?e.jsx(B,{className:"w-4 h-4 text-secondary"}):e.jsx(I,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:`text-sm ${s.completed?"line-through text-muted-foreground":""}`,children:s.title}),s.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:A(new Date(s.due_date),"MMM d")})]},a))]}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-4 border-t",children:[t.status==="todo"&&e.jsx(d,{onClick:()=>h.mutate({id:t.id,data:{status:"in_progress"}}),variant:"outline",children:"Start Task"}),t.status==="in_progress"&&e.jsx(d,{className:"bg-secondary text-secondary-foreground",onClick:()=>h.mutate({id:t.id,data:{status:"completed",progress:100}}),children:"Mark as Completed"}),t.status==="completed"&&e.jsxs(b,{children:[e.jsx(f,{asChild:!0,children:e.jsxs(d,{className:"bg-secondary text-secondary-foreground",children:[e.jsx(E,{className:"w-4 h-4 mr-2"})," Submit to Employer"]})}),e.jsxs(v,{children:[e.jsxs(N,{children:[e.jsx(w,{children:"Submit Task to Employer?"}),e.jsxs(_,{children:["You are about to submit ",e.jsx("strong",{children:t.title})," to ",e.jsx("strong",{children:t.company}),". Please confirm you have reviewed the work before submitting."]})]}),e.jsxs(C,{children:[e.jsx(D,{children:"Review Again"}),e.jsx(S,{className:"bg-secondary text-secondary-foreground",onClick:()=>W.mutate(t),children:"Confirm & Submit"})]})]})]}),t.status==="delivered"&&t.billing_amount&&(()=>{const s=o==null?void 0:o.subscription_tier,a=["premium","premium_ultra","vip"].includes(s),n=s==="standard";return a?e.jsxs(b,{children:[e.jsx(f,{asChild:!0,children:e.jsxs(d,{className:"bg-green-600 text-white hover:bg-green-700",disabled:F.isPending,children:[e.jsx(k,{className:"w-4 h-4 mr-2"})," Send Invoice â $",t.billing_amount]})}),e.jsxs(v,{children:[e.jsxs(N,{children:[e.jsx(w,{children:"Create Invoice for Client?"}),e.jsxs(_,{children:["The VA Agent will create a Stripe invoice for ",e.jsx("strong",{children:t.company})," â ",e.jsxs("strong",{children:["$",t.billing_amount]})," for ",e.jsx("strong",{children:t.title}),". This requires your consent and will be logged."]})]}),e.jsxs(C,{children:[e.jsx(D,{children:"Not Yet"}),e.jsx(S,{className:"bg-green-600 text-white",onClick:()=>F.mutate(t),children:"Yes, Create Invoice"})]})]})]}):n?e.jsxs(b,{children:[e.jsx(f,{asChild:!0,children:e.jsxs(d,{className:"bg-green-600 text-white hover:bg-green-700",disabled:p.isPending,children:[e.jsx(k,{className:"w-4 h-4 mr-2"})," Mark as Paid â $",t.billing_amount]})}),e.jsxs(v,{children:[e.jsxs(N,{children:[e.jsx(w,{children:"Confirm Payment Received?"}),e.jsxs(_,{children:["Invoice your client directly (email, PayPal, bank transfer), then confirm here once they've paid. Confirming will update your balance by ",e.jsxs("strong",{children:["$",t.billing_amount]}),"."]})]}),e.jsxs(C,{children:[e.jsx(D,{children:"Not Yet"}),e.jsx(S,{className:"bg-green-600 text-white",onClick:()=>p.mutate(t),children:"Yes, I've Been Paid"})]})]})]}):e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-muted/60 border border-border text-sm text-muted-foreground w-full",children:[e.jsx(oe,{className:"w-4 h-4 shrink-0"}),e.jsxs("span",{children:["Billing is not available on Free Trial. ",e.jsx(de,{to:"/subscription",className:"text-secondary underline font-medium",children:"Upgrade to Standard or higher"})," to track payments."]})]})})(),t.status==="billed"&&t.billing_status==="invoiced"&&t.billing_amount&&e.jsxs(b,{children:[e.jsx(f,{asChild:!0,children:e.jsxs(d,{className:"bg-secondary text-secondary-foreground hover:bg-secondary/90",disabled:p.isPending,children:[e.jsx(k,{className:"w-4 h-4 mr-2"})," Mark Payment Received"]})}),e.jsxs(v,{children:[e.jsxs(N,{children:[e.jsx(w,{children:"Confirm Payment Received?"}),e.jsxs(_,{children:["Confirm you received ",e.jsxs("strong",{children:["$",t.billing_amount]})," from ",e.jsx("strong",{children:t.company}),". The VA Agent will update your balance accordingly."]})]}),e.jsxs(C,{children:[e.jsx(D,{children:"Not Yet"}),e.jsx(S,{className:"bg-secondary text-secondary-foreground",onClick:()=>p.mutate(t),children:"Yes, Payment Received"})]})]})]})]})]})]})})]})}export{es as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.