1import{j as e,K as b,aY as P,L as B,aI as q,a9 as S,bl as O,cr as Q}from"./ui-vendor-CphGW0d_.js";import{r as o}from"./react-vendor-BOawO_dD.js";import{aE as w,a$ as y,E as R,u as U,C as p,c as _,d as C,e as f,D as Y,p as $,q as z,r as M,f as T,P as A,B as h,z as F}from"./index-Cn92Z84x.js";import{u as H}from"./useLearningPathProgress-CJ4jUUJm.js";import{u as D}from"./react-ecosystem-BT3vmxzF.js";import{S as K}from"./SimpleStudentTaskQuickModal-D16gKWBP.js";import"./data-vendor-CMH9r-4t.js";const G=()=>{const{currentStudentId:r,currentStudent:n,isAuthenticatedStudent:l}=w(),{assignments:t,loading:d}=y(),{user:i}=R(),{role:u}=U(),c=t.filter(a=>a.student_id===r);return e.jsxs(p,{className:"mb-6 border-yellow-200 bg-yellow-50",children:[e.jsx(_,{children:e.jsx(C,{className:"text-yellow-800",children:"Debug: Student Session & Tasks"})}),e.jsxs(f,{className:"space-y-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Auth User:"})," ",i?.id||"None"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"User Role:"})," ",u||"None"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Current Student ID:"})," ",r||"None"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Student Name:"})," ",n?.student_name||"None"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Is Authenticated Student:"})," ",l?"Yes":"No"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Total Assignments Loaded:"})," ",t.length]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Assignments for Current Student:"})," ",c.length]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Loading State:"})," ",d?"Yes":"No"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Current Route Assignment ID:"})," ",window.location.pathname.includes("/app/student/task/")?window.location.pathname.split("/").pop():"None"]}),t.length>0&&e.jsxs("div",{children:[e.jsx("strong",{children:"Sample Assignment Student IDs:"}),e.jsx("ul",{className:"list-disc list-inside ml-4",children:t.slice(0,3).map(a=>e.jsxs("li",{children:["Assignment ",a.id.slice(0,8),"... â Student: ",a.student_id]},a.id))})]}),c.length>0&&e.jsxs("div",{children:[e.jsx("strong",{children:"Your Task Assignments:"}),e.jsx("ul",{className:"list-disc list-inside ml-4",children:c.map(a=>e.jsxs("li",{children:[a.task?.title||"Untitled Task"," (Status: ",a.status,")"]},a.id))})]})]})]})},J=({assignmentId:r,open:n,onClose:l})=>{const[t,d]=o.useState(null),[i,u]=o.useState(!1),c=D();o.useEffect(()=>{(async()=>{if(!(!r||!n)){u(!0);try{const{data:m,error:k}=await F.from("task_assignments").select("*, task:tasks(*)").eq("id",r).maybeSingle();!k&&m&&d(m)}finally{u(!1)}}})()},[r,n]);const a=()=>{r&&(l(),c(`/app/student/task/${r}`))};return e.jsx(Y,{open:n,onOpenChange:g=>{g||l()},children:e.jsxs($,{className:"max-w-xl",children:[e.jsx(z,{children:e.jsx(M,{children:t?.task?.title||"Task"})}),e.jsx(p,{children:e.jsx(f,{className:"space-y-4 p-4",children:i?e.jsx("div",{className:"text-center text-muted-foreground",children:"Loading task..."}):e.jsxs(e.Fragment,{children:[t?.task?.cover_image_url&&e.jsx("img",{src:t.task.cover_image_url,alt:t.task.title||"Task cover",className:"w-full h-40 object-cover rounded-md"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t?.task?.description||"No description provided."}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[t?.task?.estimated_duration_minutes&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(b,{className:"w-4 h-4"}),t.task.estimated_duration_minutes," min"]}),t?.due_date&&e.jsxs("span",{children:["Due ",new Date(t.due_date).toLocaleDateString()]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{children:"Progress"}),e.jsx(T,{variant:"outline",children:t?.status||"assigned"})]}),e.jsx(A,{value:t?.progress_percentage||0})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(h,{variant:"outline",onClick:l,children:"Close"}),e.jsxs(h,{onClick:a,children:[e.jsx(P,{className:"w-4 h-4 mr-2"})," Start Task"]})]})]})})})]})})},ae=()=>{const r=D(),{assignments:n}=y(),{currentStudentId:l}=w(),{totalLevels:t,currentLevel:d}
1=H(l),[i,u]=o.useState(d||null),[c,a]=o.useState(null),[g,m]=o.useState(!1),[k,L]=o.useState(!1);let x=n.filter(s=>s.student_id===l);i&&(x=x.filter(s=>s.learning_path_level===i)),console.log("ð Found",x.length,"assignments for student:",l,"from total:",n.length),x.length===0&&n.length>0&&(console.log("â ï¸ No tasks found for currentStudentId, showing recent assignments as fallback"),x=n.slice(0,3));const I=s=>{switch(s){case"completed":return"bg-green-100 text-green-800 border-green-200";case"in_progress":return"bg-blue-100 text-blue-800 border-blue-200";case"pending":return"bg-orange-100 text-orange-800 border-orange-200";case"overdue":return"bg-red-100 text-red-800 border-red-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}};o.useEffect(()=>{const s=()=>{console.log("ð StudentTasks refresh event received")};return window.addEventListener("tasks:refresh",s),()=>{window.removeEventListener("tasks:refresh",s)}},[l]);const E=s=>{switch(s){case"completed":return e.jsx(Q,{className:"h-4 w-4"});case"in_progress":return e.jsx(S,{className:"h-4 w-4"});case"overdue":return e.jsx(O,{className:"h-4 w-4"});default:return e.jsx(b,{className:"h-4 w-4"})}};return e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx(G,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"My Tasks"}),e.jsx("p",{className:"text-muted-foreground",children:"Track your learning assignments and progress"})]}),e.jsx(h,{variant:"outline",onClick:()=>r("/app/student-dashboard"),children:"Back to Dashboard"})]}),e.jsx(p,{children:e.jsx(f,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[Array.from({length:t||7},(s,j)=>j+1).map(s=>{const j=s===d,N=i===s,v=s<=d+1;return e.jsxs(h,{size:"sm",variant:N?"default":j?"secondary":"outline",disabled:!v,onClick:()=>u(s),className:"relative",children:[v?s:e.jsx(B,{className:"w-3 h-3"}),s<d&&e.jsx(q,{className:"w-3 h-3 absolute -top-1 -right-1"})]},s)}),e.jsx(h,{size:"sm",variant:"ghost",onClick:()=>u(null),children:"All"})]})})}),x.length===0?e.jsx(p,{children:e.jsxs(f,{className:"p-8 text-center",children:[e.jsx(S,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Tasks Assigned"}),e.jsx("p",{className:"text-muted-foreground",children:i?`No tasks assigned for Level ${i}.`:"You don't have any tasks assigned yet. Check back later or contact your instructor."})]})}):e.jsx("div",{className:"grid gap-4",children:x.map(s=>e.jsxs(p,{className:"hover:shadow-md transition-shadow",children:[e.jsx(_,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-lg",children:s.task?.title||"Task"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.task?.description||"No description available"})]}),e.jsxs(T,{variant:"outline",className:`${I(s.status)} flex items-center gap-1`,children:[E(s.status),s.status]})]})}),e.jsxs(f,{className:"space-y-4",children:[s.task?.cover_image_url&&e.jsx("div",{className:"flex justify-center",children:e.jsx("img",{src:s.task.cover_image_url,alt:s.task.title||"Task cover",className:"w-full max-w-sm h-32 object-cover rounded-lg border",onError:j=>{const N=j.target;N.style.display="none"}})}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{children:"Progress"}),e.jsxs("span",{className:"font-medium",children:[s.progress_percentage,"%"]})]}),e.jsx(A,{value:s.progress_percentage}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s.due_date&&e.jsxs("span",{children:["Due: ",new Date(s.due_date).toLocaleDateString()]}),e.jsxs("span",{className:"ml-4",children:["Assigned: ",new Date(s.assigned_at).toLocaleDateString()]})]}),e.jsx(h,{onClick:()=>{a(s.id),L(!!s.is_simple),m(!0)},disabled:s.status==="completed",children:s.status==="completed"?"Completed":"Open Task"})]})]})]},s.id))}),k?e.jsx(K,{assignmentId:c,open:g,onClose:()=>m(!1)}):e.jsx(J,{assignmentId:c,open:g,onClose:()=>m(!1)})]})};export{ae 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.