1import{a5 as b,u as v,r as i,s as n,j as e,L as y,t as l}from"./index-BsRSMeKU.js";import{u as g}from"./useChildProfile-UvbGQm_T.js";import{L as j}from"./loader-circle-D_8RmJX5.js";import{A as N}from"./arrow-left-DhrX-ssv.js";import{C as _}from"./circle-check-C-KMllKg.js";function L(){const{moduleSlug:c}=b({from:"/app/course/$moduleSlug"}),p=v(),{activeChild:a}=g(),[s,f]=i.useState(null),[d,m]=i.useState(!1),[u,o]=i.useState(!1);i.useEffect(()=>{(async()=>{const{data:t}=await n.from("activities").select("id, slug, title, description, duration_minutes, module_number, attention_domain, steps, materials_needed").eq("slug",c).eq("is_course_module",!0).maybeSingle();f(t??null)})()},[c]),i.useEffect(()=>{!s||!a||(async()=>{const{data:t}=await n.from("activity_completions").select("id").eq("activity_id",s.id).eq("child_id",a.id).maybeSingle();m(!!t)})()},[s,a]);async function h(){if(!s||!a){l.error("Select a child first");return}o(!0);const{data:{session:t}}=await n.auth.getSession();if(!t?.user?.id){o(!1);return}const{error:r}=await n.from("activity_completions").insert({user_id:t.user.id,child_id:a.id,activity_id:s.id});o(!1),r?l.error(r.message):(m(!0),l.success("Module complete"))}if(!s)return e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(j,{className:"h-5 w-5 animate-spin text-navy/40"})});const x=Array.isArray(s.steps)?s.steps:[];return e.jsxs("section",{children:[e.jsxs(y,{to:"/app/course",className:"mb-4 inline-flex items-center gap-1 text-sm text-navy/60 hover:text-navy",children:[e.jsx(N,{className:"h-4 w-4"})," Back to course"]}),e.jsxs("p",{className:"text-xs font-semibold uppercase tracking-wide text-amber",children:["Module ",s.module_number," · ",s.duration_minutes," min"]}),e.jsx("h1",{className:"mt-1 font-serif text-3xl font-bold text-navy",children:s.title}),e.jsx("p",{className:"mt-3 text-sm text-navy/75",children:s.description}),s.materials_needed&&e.jsxs("div",{className:"mt-5 rounded-xl border border-cream-dark bg-white p-4",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-navy/60",children:"Materials"}),e.jsx("p",{className:"mt-1 text-sm text-navy/80",children:s.materials_needed})]}),x.length>0&&e.jsx("ol",{className:"mt-5 space-y-3",children:x.map((t,r)=>e.jsxs("li",{className:"flex gap-3 rounded-xl border border-cream-dark bg-white p-4 shadow-soft",children:[e.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-amber text-sm font-bold text-navy",children:r+1}),e.jsx("p",{className:"text-sm text-navy/85",children:t})]},r))}),e.jsxs("div",{className:"mt-8 flex flex-col gap-3 sm:flex-row",children:[e.jsx("button",{onClick:h,disabled:d||u,className:"inline-flex items-center justify-center gap-2 rounded-md bg-amber px-5 py-3 text-sm font-semibold text-navy hover:bg-amber-light disabled:opacity-60",children:d?e.jsxs(e.Fragment,{children:[e.jsx(_,{className:"h-4 w-4"})," Completed"]}):u?"Savingâ¦":"Mark complete"}),e.jsx("button",{onClick:()=>p({to:"/app/course"}),className:"rounded-md border border-cream-dark bg-white px-5 py-3 text-sm font-semibold text-navy hover:border-amber",children:"Next module"})]})]})}export{L 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.