1import{r as i,j as t}from"./vendor-react-BDlPBQ8H.js";import{E as M,a2 as T,a3 as v,u,h as A}from"./index-C9I8CK0-.js";import{g}from"./apiUtils-CdltNbxm.js";import{E as N,a as h,b as k}from"./EnterpriseSurface-CxYSrS8g.js";import"./vendor-nhost-yQ8TKvUP.js";import"./vendor-misc-BcNut0Sq.js";import"./vendor-ui-helpers-BA9Ou6yF.js";import"./vendor-radix-CoZ84gME.js";import"./vendor-interactions-B-90v6Vt.js";import"./vendor-sentry-B_mZGnMZ.js";import"./EnterpriseStatCard-Wl26IFB0.js";async function p(e,o={},a){return M(`${T()}${e}`,o,a)}const f=A("partner-training");function b(e){return typeof e=="object"&&e!==null}function P(e){return b(e)&&typeof e.id=="string"&&(e.title===void 0||e.title===null||typeof e.title=="string")}function S(e){return b(e)&&typeof e.id=="string"&&(e.title===void 0||e.title===null||typeof e.title=="string")&&(e.description===void 0||e.description===null||typeof e.description=="string")&&Array.isArray(e.modules)&&e.modules.every(P)}function I(e){return b(e)&&typeof e.courseId=="string"&&Array.isArray(e.completedModules)&&e.completedModules.every(o=>typeof o=="string")}function $(e){return Array.isArray(e)&&e.every(S)}function R(e){return Array.isArray(e)&&e.every(I)}function H(){const e=v(),[o,a]=i.useState([]),[l,x]=i.useState([]),n=i.useMemo(()=>e.organizationId?{organizationId:e.organizationId,schoolId:e.schoolId}:null,[e.organizationId,e.schoolId]),d=i.useCallback(async()=>{if(n)try{const[r,s]=await Promise.all([p("/courses",{method:"GET"},n),p("/courses/enrollments/me",{method:"GET"},n)]);a($(r)?r:[]),x(R(s)?s:[])}catch(r){f.error("Failed to load training courses",g(r)),u.error("Unable to load training courses."),a([]),x([])}},[n]);i.useEffect(()=>{d()},[d]);const y=async r=>{if(n)try{await p(`/courses/${r}/enroll`,{method:"POST"},n),await d()}catch(s){f.error("Failed to enroll in training course",g(s)),u.error("Unable to enroll in this course.")}},j=async(r,s)=>{if(n)try{await p(`/courses/${r}/modules/${s}/complete`,{method:"POST"},n),await d()}catch(m){f.error("Failed to complete training module",g(m)),u.error("Unable to mark this module complete.")}},C=i.useMemo(()=>Object.fromEntries(l.map(r=>[r.courseId,r])),[l]),E=l.reduce((r,s)=>r+s.completedModules.length,0),w=o.reduce((r,s)=>r+s.modules.length,0);return t.jsx(N,{eyebrow:"Partner CMS",title:"Training courses",description:"Partner onboarding, program-quality training, and compliance learning live in the same enterprise workspace as submissions and assets.",badges:["Onboarding progress","Compliance learning","Partner enablement"],metrics:[{label:"Courses",value:String(o.length),badge:"Available",trend:"flat"},{label:"Enrollments",value:String(l.length),badge:"Active",trend:"flat"},{label:"Modules complete",value:`${E}/${w}`,badge:"Progress",trend:"up"},{label:"Workspace",value:n?"Tenant scoped":"Loading",badge:"Secure",trend:"flat"}],aside:t.jsx(h,{title:"Onboarding checklist",description:"Training keeps partner submissions consistent and review-ready.",children:t.jsx(k,{items:[{label:"Understand district review",status:"Coursework",tone:"info"},{label:"Prepare accessible assets",status:"Required",tone:"warning"},{label:"Confirm compliance expectations",status:"Tracked",tone:"success"}]})}),children:t.jsx(h,{title:"Course catalog",description:"Enroll in courses and mark modules complete as your team prepares content.",children:t.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[o.map(r=>{const s=C[r.id],m=s?s.completedModules.length:0;return t.jsxs("article",{className:"rounded-2xl border border-[var(--enterprise-border)] bg-[var(--enterprise-surface)] p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"font-heading text-xl font-semibold",children:r.title}),t.jsx("p",{className:"mt-1 text-sm leading-6 text-[var(--enterprise-muted)]",children:r.description})]}),!s&&t.jsx("button",{type:"button",onClick:()=>y(r.id),className:"enterprise-focus rounded-full bg-[var(--enterprise-primary)] px-4 py-2 text-sm font-semibold text-white",children:"Enroll"})]}),s&&t.jsxs("div",{className:"mt-4 space-y-3",children:[t.jsxs("p",{className:"text-sm font-semibold text-[var(--enterprise-muted)]",children:["Progress: ",m,"/",r.modules.length]}),r.modules.map(c=>t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-[var(--enterprise-border)] p-3 text-sm",children:[t.jsx("span",{children:c.title}),s.completedModules.includes(c.id)?t.jsx("span",{className:"rounded-full bg-[var(--enterprise-success)] px-3 py-1 text-xs font-semibold text-white",children:"Complete"}):t.jsx("button",{type:"button",onClick:()=>j(r.id,c.id),className:"enterprise-focus rounded-full border border-[var(--enterprise-border)] px-3 py-1 text-xs font-semibold",children:"Complete"})]},c.id))]})]},r.id)}),o.length===0?t.jsx("p",{className:"text-sm text-[var(--enterprise-muted)]",children:"No partner training courses are available yet."}):null]})})})}export{H 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.