1import{h as e,ai as t,r as s,s as a,aw as n,j as r,b8 as o,f as i,w as l,C as d,am as c,ak as m,aH as u,z as x,ao as p,ap as g,b9 as h,B as f}from"./index--fmOKDlP.js";import"./pdf-DgJZEHwN.js";const j={urgent:{label:"Urgent",className:"bg-red-500/10 text-red-600 border-red-500/30"},high:{label:"High",className:"bg-orange-500/10 text-orange-600 border-orange-500/30"},normal:{label:"Normal",className:"bg-blue-500/10 text-blue-600 border-blue-500/30"},low:{label:"Low",className:"bg-muted text-muted-foreground border-border"}};function b(){const{user:p}=e(),{activeBusiness:g}=t(),[h,f]=s.useState([]),[j,b]=s.useState(!0),[w,k]=s.useState(null);async function y(e,t){k(e);const{error:s}=await a.from("os_tasks").update({status:t,completed_at:"done"===t?(new Date).toISOString():null}).eq("id",e);k(null),s?n({title:"Update failed",description:s.message,variant:"destructive"}):f(s=>s.map(s=>s.id===e?{...s,status:t}:s))}s.useEffect(()=>{if(!p)return;let e=!1;return b(!0),(async()=>{const{data:t,error:s}=await a.from("os_tasks").select("id, title, description, status, priority, due_at, source, created_at").eq("user_id",p.id).order("created_at",{ascending:!1}).limit(200);e||(s?n({title:"Failed to load tasks",description:s.message,variant:"destructive"}):f(t??[]),b(!1))})(),()=>{e=!0}},[p,g?.place_id]);const v=s.useMemo(()=>({open:h.filter(e=>"open"===e.status||"in_progress"===e.status),done:h.filter(e=>"done"===e.status),snoozed:h.filter(e=>"snoozed"===e.status)}),[h]);return r.jsxs("div",{className:"mx-auto max-w-4xl space-y-6 px-4 py-6",children:[r.jsxs("header",{children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(o,{className:"h-5 w-5 text-primary"}),r.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Smart Tasks"}),r.jsx(i,{variant:"secondary",children:"OS"})]}),r.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Automated and Copilot-generated actions to grow your local presence."})]}),j?r.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[r.jsx(l,{className:"h-4 w-4 animate-spin"}),"Loading tasksâ¦"]}):0===h.length?r.jsx(d,{children:r.jsx(c,{className:"py-10 text-center text-sm text-muted-foreground",children:"No tasks yet. Ask the Copilot to suggest your weekly action plan and it will create tasks here."})}):r.jsxs(r.Fragment,{children:[r.jsx(N,{title:"To do",icon:r.jsx(m,{className:"h-4 w-4 text-orange-500"}),tasks:v.open,updating:w,onAction:e=>y(e,"done"),actionLabel:"Mark done"}),r.jsx(N,{title:"Snoozed",icon:r.jsx(u,{className:"h-4 w-4 text-muted-foreground"}),tasks:v.snoozed,updating:w,onAction:e=>y(e,"open"),actionLabel:"Resume"}),r.jsx(N,{title:"Completed",icon:r.jsx(x,{className:"h-4 w-4 text-emerald-500"}),tasks:v.done,updating:w,onAction:e=>y(e,"open"),actionLabel:"Reopen",muted:!0})]})]})}function N({title:e,icon:t,tasks:s,updating:a,onAction:n,actionLabel:o,muted:m}){return 0===s.length?null:r.jsxs(d,{children:[r.jsx(p,{className:"flex flex-row items-center justify-between pb-3",children:r.jsxs(g,{className:"flex items-center gap-2 text-base",children:[t,e,r.jsxs("span",{className:"text-xs font-normal text-muted-foreground",children:["(",s.length,")"]})]})}),r.jsx(c,{className:"space-y-2",children:s.map(e=>{const t=j[e.priority]??j.normal;return r.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-border bg-card/50 p-3 "+(m?"opacity-70":""),children:[r.jsx(h,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r.jsx("span",{className:"font-medium",children:e.title}),r.jsx(i,{variant:"outline",className:t.className,children:t.label}),e.source?r.jsx(i,{variant:"outline",className:"text-[10px] font-normal",children:e.source}):null]}),e.description?r.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:e.description}):null,e.due_at?r.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Due ",new Date(e.due_at).toLocaleDateString()]}):null]}),r.jsx(f,{size:"sm",variant:"outline",disabled:a===e.id,onClick:()=>n(e.id),children:a===e.id?r.jsx(l,{className:"h-3.5 w-3.5 animate-spin"}):o})]},e.id)})})]})}export{b 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.