1import{u as k,r as j,b as p,a as y,p as _,j as e,I as S,q as C,g as f,P as A,o as P,m as c,T as E,X as R,h as q}from"./index-u0HMC9Vb.js";import{S as T}from"./switch-zpySaZsg.js";import"./index-BegspP2X.js";const w=["SORA","AERO","ONYX","NOVA"],F=["in_progress","eligible","graduated"];function O({course:n,enrollment:a,profileId:l,onRefresh:o}){const m=(a==null?void 0:a.status)==="active"||(a==null?void 0:a.status)==="completed",[d,i]=j.useState(!1),h=async x=>{i(!0),a?await c.entities.Enrollment.update(a.id,{status:x?"active":"locked"}):await c.entities.Enrollment.create({student_profile_id:l,course_id:n.id,status:x?"active":"locked"}),i(!1),o()};return e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-stone-800",children:[n.code," â ",n.title]}),a&&e.jsx("p",{className:`text-[10px] mt-0.5 ${a.status==="completed"?"text-lime-600":a.status==="active"?"text-blue-600":"text-stone-400"}`,children:a.status}),!a&&e.jsx("p",{className:"text-[10px] text-stone-400 mt-0.5",children:"no enrollment"})]}),e.jsx(T,{checked:m,onCheckedChange:h,disabled:d})]})}function D({profile:n,courses:a,onSave:l,onCancel:o,isSaving:m}){k();const[d,i]=j.useState({...n}),{data:h=[]}=p({queryKey:["cohorts"],queryFn:()=>c.entities.Cohort.list("name")}),{data:x=[],refetch:g}=p({queryKey:["enrollments-admin",n.id],queryFn:()=>c.entities.Enrollment.filter({student_profile_id:n.id}),enabled:!!n.id});return e.jsxs("div",{className:"bg-card border border-border p-5 mb-5",children:[e.jsx("p",{className:"text-[10px] font-meta uppercase tracking-widest text-muted-foreground mb-4",children:"Edit Profile"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-meta uppercase tracking-widest text-muted-foreground mb-1 block",children:"Primary TRA"}),e.jsxs("select",{value:d.primary_tra||"",onChange:t=>i(r=>({...r,primary_tra:t.target.value})),className:"w-full h-9 border border-border bg-muted px-3 text-sm focus:outline-none",children:[e.jsx("option",{value:"",children:"â"}),w.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-meta uppercase tracking-widest text-muted-foreground mb-1 block",children:"Secondary TRA"}),e.jsxs("select",{value:d.secondary_tra||"",onChange:t=>i(r=>({...r,secondary_tra:t.target.value})),className:"w-full h-9 border border-border bg-muted px-3 text-sm focus:outline-none",children:[e.jsx("option",{value:"",children:"â"}),w.map(t=>e.jsx("option",{value:t,children:t},t))]})]})]}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:["self_score","other_score","synthesis_score"].map(t=>e.jsxs("div",{children:[e.jsxs("label",{className:"text-[9px] font-meta uppercase tracking-widest text-muted-foreground mb-1 block",children:[t.replace("_score","")," Score"]}),e.jsx(S,{type:"number",min:0,max:10,value:d[t]||0,onChange:r=>i(b=>({...b,[t]:Number(r.target.value)})),className:"bg-muted border-border h-9 text-sm"})]},t))}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-meta uppercase tracking-widest text-muted-foreground mb-1 block",children:"Cohort"}),e.jsxs("select",{value:d.cohort_id||"",onChange:t=>i(r=>({...r,cohort_id:t.target.value})),className:"w-full h-9 border border-border bg-muted px-3 text-sm focus:outline-none",children:[e.jsx("option",{value:"",children:"â None â"}),h.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-meta uppercase tracking-widest text-muted-foreground mb-1 block",children:"Graduation Status"}),e.jsx("select",{value:d.graduation_status||"in_progress",onChange:t=>i(r=>({...r,graduation_status:t.target.value})),className:"w-full h-9 border border-border bg-muted px-3 text-sm focus:outline-none",children:F.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-meta uppercase tracking-widest text-muted-foreground mb-1 block",children:"Bio"}),e.jsx(E,{value:d.bio||"",onChange:t=>i(r=>({...r,bio:t.target.value})),className:"bg-muted border-border text-sm resize-none",rows:2})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-meta uppercase tracking-widest text-muted-foreground mb-2",children:"Course Acce
1ss"}),e.jsxs("div",{className:"bg-muted px-4 divide-y divide-border",children:[a.map(t=>e.jsx(O,{course:t,enrollment:x.find(r=>r.course_id===t.id),profileId:n.id,onRefresh:g},t.id)),a.length===0&&e.jsx("p",{className:"text-xs text-stone-400 py-3 text-center",children:"No courses found"})]})]})]}),e.jsxs("div",{className:"flex gap-2 mt-4 justify-end",children:[e.jsxs(f,{variant:"outline",size:"sm",onClick:o,className:"text-xs gap-1",children:[e.jsx(R,{className:"w-3 h-3"})," Cancel"]}),e.jsxs(f,{size:"sm",onClick:()=>l(d),disabled:m,className:"text-xs gap-1",children:[e.jsx(q,{className:"w-3 h-3"})," Save"]})]})]})}function I(){const n=k(),[a,l]=j.useState(null),[o,m]=j.useState(""),{data:d=[],isLoading:i}=p({queryKey:["tRESDAProfiles"],queryFn:()=>c.entities.TRESDAProfile.list("-created_date",100)}),{data:h=[]}=p({queryKey:["users-admin"],queryFn:()=>c.entities.User.list()}),{data:x=[]}=p({queryKey:["courses"],queryFn:()=>c.entities.Course.filter({},"order")}),g=s=>h.find(u=>u.id===s.user_id),t=y({mutationFn:({id:s,data:u})=>c.entities.TRESDAProfile.update(s,u),onSuccess:()=>{n.invalidateQueries({queryKey:["tRESDAProfiles"]}),l(null)}}),r=y({mutationFn:s=>c.entities.TRESDAProfile.delete(s),onSuccess:()=>n.invalidateQueries({queryKey:["tRESDAProfiles"]})}),b=d.filter(s=>{if(!o)return!0;const u=g(s);return _(u).toLowerCase().includes(o.toLowerCase())||(s.user_id||"").toLowerCase().includes(o.toLowerCase())}),N=d.find(s=>s.id===a);return e.jsxs("div",{className:"bg-background min-h-screen",children:[e.jsx("header",{className:"border-b border-border px-5 lg:px-10 pt-8 pb-6",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("p",{className:"text-[9px] font-meta uppercase tracking-[0.35em] text-muted-foreground",children:"Admin"}),e.jsx("h1",{className:"text-2xl font-display uppercase text-foreground mt-0.5",children:"Student Profiles"}),e.jsx("p",{className:"text-[10px] font-meta text-muted-foreground mt-1",children:"View and manage member profiles."})]})}),e.jsxs("div",{className:"p-5 lg:px-10 max-w-3xl mx-auto pt-8",children:[e.jsx(S,{placeholder:"Search by username...",value:o,onChange:s=>m(s.target.value),className:"mb-5 bg-muted border-border h-9 text-sm"}),a&&N&&e.jsx(D,{profile:N,courses:x,onSave:s=>t.mutate({id:a,data:s}),onCancel:()=>l(null),isSaving:t.isPending}),e.jsx("div",{className:"space-y-2",children:i?e.jsx("p",{className:"text-sm text-stone-400",children:"Loading..."}):b.length===0?e.jsx("div",{className:"bg-muted p-8 text-center",children:e.jsx("p",{className:"text-[10px] font-meta uppercase tracking-widest text-muted-foreground",children:"No student profiles found."})}):b.map(s=>{const u=g(s),v=_(u);return e.jsx("div",{className:"bg-card border border-border p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-stone-200 flex items-center justify-center flex-shrink-0 overflow-hidden",children:s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(C,{className:"w-4 h-4 text-stone-400",strokeWidth:1.5})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:v}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5",children:s.full_name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[s.student_id&&e.jsx("span",{className:"text-[9px] font-meta uppercase tracking-widest px-1.5 py-0.5 bg-blue-100 text-blue-700 border border-blue-300",children:s.student_id}),s.primary_tra&&e.jsx("span",{className:"text-[9px] font-meta uppercase tracking-widest px-1.5 py-0.5 bg-muted text-muted-foreground border border-border",children:s.primary_tra}),s.secondary_tra&&e.jsx("span",{className:"text-[9px] font-meta uppercase tracking-widest px-1.5 py-0.5 bg-muted text-muted-foreground border border-border",children:s.secondary_tra}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${s.graduation_status==="graduated"?"bg-lime-100 text-lime-700":s.graduation_status==="eligible"?"bg-amber-100 text-amber-700":"bg-stone-100 text-stone-500"}`,children:s.graduation_status||"in_progress"})]}),e.jsxs("div",{className:"mt-2 space-y-0.5",children:[s.location&&e.jsxs("p",{className:"text-[9px] text-muted-foreground",children:["ð ",s.location]}),s.entry_level&&e.jsxs("p",{className:"text-[9px] text-muted-foreground",children:["Process Stage: ",e.jsx("span",{className:"font-medium capitalize",children:s.entry_level.replace(/_/g," ")})]})]})]}),e.jsxs("div",{className:"text-right mr-2 hidden sm:block",children:[e.jsx("p",{className:"text-[10px] font-meta uppercase tracking-widest text-muted-foreground",children:"Self / Other / Synth"}),e.jsxs("p",{className:"text-xs font-medium text-foreground",children:[s.self_score??"â"," / ",s.other_score??"â"," / ",s.synthesis_score??"â"]})]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(f,{size:"icon",variant:"ghost",className:"w-7 h-7",onClick:()=>l(s.id),children:e.jsx(A,{className:"w-3.5 h-3.5 text-muted-foreground",strokeWidth:1.5})}),e.jsx(f,{size:"icon",variant:"ghost",className:"w-7 h-7",onClick:()=>r.mutate(s.id),children:e.jsx(P,{className:"w-3.5 h-3.5 text-red-400",strokeWidth:1.5})})]})]})},s.id)})})]})]})}export{I 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.