1import{a as q,r as a,d7 as v,j as e,X as D,Y as K,Z as f,ak as P,I as O,l as B,aa as w,ab as k,a6 as H,d8 as J,d9 as R,al as u,T as U,da as V,aK as X,db as Y,J as g,O as Z,K as $}from"./index-RMzfyAls.js";function G(){return e.jsxs("div",{className:"space-y-5 pb-10",children:[e.jsx(Z,{title:"Ù
ÙØ§Ù
Ù",description:"اÙÙ
ÙØ§Ù
اÙÙ
ÙØ¬ÙÙØ© ÙÙ Ù
٠اÙÙ
شرÙ"}),e.jsx(z,{})]})}function z(){const{user:C,profile:S}=q(),j=C?.id??null,[t,T]=a.useState([]),[L,N]=a.useState(!0),[r,m]=a.useState(null),[x,E]=a.useState(""),[n,M]=a.useState("active"),[b,A]=a.useState({}),_=async()=>{if(!j)return;N(!0);const{data:s,error:d}=await g.from("specialist_tasks").select("*").eq("assignee_id",j).order("created_at",{ascending:!1});d&&$.error("ØªØ¹Ø°ÙØ± تØÙ
Ù٠اÙÙ
ÙØ§Ù
: "+d.message);const o=s??[];T(o);const i=Array.from(new Set(o.map(c=>c.created_by)));if(i.length){const[{data:c},{data:I}]=await Promise.all([g.from("specialists").select("user_id, full_name").in("user_id",i),g.from("users_profile").select("id, full_name").in("id",i)]),h={};(I??[]).forEach(l=>{l?.id&&(h[l.id]=l.full_name??"â")}),(c??[]).forEach(l=>{l?.user_id&&(h[l.user_id]=l.full_name??h[l.user_id]??"â")}),A(h)}N(!1)};a.useEffect(()=>{_()},[j]);const p=a.useMemo(()=>({active:t.filter(s=>s.status==="new"||s.status==="in_progress"||s.status==="pending_review").length,completed:t.filter(s=>s.status==="completed").length,cancelled:t.filter(s=>s.status==="cancelled").length,overdue:t.filter(v).length}),[t]),y=a.useMemo(()=>t.filter(s=>!(n==="active"&&!(s.status==="new"||s.status==="in_progress"||s.status==="pending_review")||n==="completed"&&s.status!=="completed"||n==="cancelled"&&s.status!=="cancelled"||n==="overdue"&&!v(s)||x.trim()&&!s.title.toLowerCase().includes(x.trim().toLowerCase()))),[t,n,x]);return e.jsxs("div",{className:"space-y-5",children:[e.jsx(D,{value:n,onValueChange:M,children:e.jsxs(K,{className:"grid grid-cols-4 w-full h-auto",children:[e.jsxs(f,{value:"active",className:"flex-col h-auto py-2 gap-0.5",children:[e.jsx("span",{className:"text-xs",children:"ÙØ´Ø·Ø©"}),e.jsx("span",{className:"font-bold",children:p.active})]}),e.jsxs(f,{value:"overdue",className:"flex-col h-auto py-2 gap-0.5 data-[state=active]:text-red-600",children:[e.jsx("span",{className:"text-xs",children:"Ù
تأخرة"}),e.jsx("span",{className:"font-bold",children:p.overdue})]}),e.jsxs(f,{value:"completed",className:"flex-col h-auto py-2 gap-0.5",children:[e.jsx("span",{className:"text-xs",children:"Ù
ÙØªÙ
ÙØ©"}),e.jsx("span",{className:"font-bold",children:p.completed})]}),e.jsxs(f,{value:"cancelled",className:"flex-col h-auto py-2 gap-0.5",children:[e.jsx("span",{className:"text-xs",children:"Ù
ÙØºØ§Ø©"}),e.jsx("span",{className:"font-bold",children:p.cancelled})]})]})}),e.jsxs("div",{className:"relative",children:[e.jsx(P,{className:"absolute start-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(O,{placeholder:"Ø¨ØØ« بعÙÙØ§Ù اÙÙ
ÙÙ
Ø©...",value:x,onChange:s=>E(s.target.value),className:"ps-9"})]}),L?e.jsx("div",{className:"p-10 text-center",children:e.jsx(B,{className:"h-6 w-6 animate-spin mx-auto"})}):y.length===0?e.jsx(w,{children:e.jsxs(k,{className:"p-10 text-center",children:[e.jsx(H,{className:"h-12 w-12 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:t.length===0?"ÙØ§ ØªÙØ¬Ø¯ Ù
ÙØ§Ù
Ù
ÙØ¬ÙØ© ÙÙ ØØ§ÙÙÙØ§.":"ÙØ§ ØªÙØ¬Ø¯ ÙØªØ§Ø¦Ø¬ Ù
Ø·Ø§Ø¨ÙØ©."})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:y.map(s=>{const d=J(s.priority),o=R(s.status),i=v(s);return e.jsx(w,{role:"button",tabIndex:0,onClick:()=>m(s),onKeyDown:c=>(c.key==="Enter"||c.key===" ")&&m(s),className:"cursor-pointer hover:shadow-lg transition active:scale-[0.99]",children:e.jsxs(k,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h3",{className:"font-bold text-base leading-snug line-clamp-2 flex-1",children:s.title}),e.jsx(u,{variant:"outline",className:d.color+" shrink-0",children:d.label})]}),s.description&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:s.description}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[e.jsx(u,{variant:"outline",className:o.color,children:o.label}),i&&e.jsxs(u,{variant:"outline",className:"bg-red-100 text-red-700 border-red-200",children:[e.jsx(U,{className:"h-3 w-3 ml-1"})," Ù
تأخرة"]}),e.jsx(u,{variant:"outline",children:V(s.task_type,s.task_type_other)}
1),s.requires_response&&!s.specialist_response&&e.jsx(u,{variant:"outline",className:"bg-amber-50 text-amber-700 border-amber-200",children:"رد Ù
Ø·ÙÙØ¨"})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground pt-1 border-t",children:[e.jsxs("span",{children:["Ù
Ù: ",b[s.created_by]??"اÙÙ
شرÙ"]}),s.due_date&&e.jsxs("span",{className:`flex items-center gap-1 ${i?"text-red-600 font-semibold":""}`,children:[e.jsx(X,{className:"h-3 w-3"})," ",s.due_date]})]})]})},s.id)})}),e.jsx(Y,{task:r,open:!!r,onClose:()=>m(null),mode:"therapist",assigneeName:S?.full_name??void 0,supervisorName:r?b[r.created_by]:void 0,onUpdated:()=>{_(),r&&g.from("specialist_tasks").select("*").eq("id",r.id).maybeSingle().then(({data:s})=>s&&m(s))}})]})}export{z as MyTasksList,G as component};
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.