PageSourceSearch

https://tresda.institute/assets/ResidentDirectory-wBTgTo-i.js

js tresda.institute collected 2026-10-02 01:59:19 UTC 32,990 bytes, 1 lines download raw bytes

1import{j as e,q as $,x as A,b as h,m as x,r as N,u as K,a as T,e as Q,z as W,cA as G,T as I,g as E,h as V,k as D,ak as X,I as P,ah as H,W as J,U as O,A as Z}from"./index-u0HMC9Vb.js";import{S as U}from"./switch-zpySaZsg.js";import{t as C}from"./index-CvPNWckN.js";import{C as ee}from"./circle-x-B0lqQjlS.js";import"./index-BegspP2X.js";const te={prospect:"bg-amber-50 text-amber-700 border-amber-200",active:"bg-emerald-50 text-emerald-700 border-emerald-200",alumni:"bg-blue-50 text-blue-700 border-blue-200",inactive:"bg-stone-100 text-stone-500 border-stone-200"};function se({user:t,profile:s,record:a,onClick:l}){const r=t.full_name||t.email,i=(a==null?void 0:a.resident_status)||"prospect",n=(a==null?void 0:a.override_tra)||(s==null?void 0:s.primary_tra);return e.jsxs("button",{onClick:l,className:"w-full flex items-center gap-4 px-5 py-3.5 border-b border-stone-100 hover:bg-stone-50 transition-colors text-left last:border-b-0",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-stone-100 flex items-center justify-center flex-shrink-0 overflow-hidden",children:s!=null&&s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:"",className:"w-full h-full object-cover"}):e.jsx($,{className:"w-3.5 h-3.5 text-stone-400",strokeWidth:1.5})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-stone-900 truncate",children:r}),e.jsx("p",{className:"text-xs text-stone-400 truncate",children:t.email})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-2 flex-shrink-0",children:[(s==null?void 0:s.student_id)&&e.jsx("span",{className:"text-[9px] font-mono tracking-widest text-stone-400 uppercase",children:s.student_id}),n&&e.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 bg-stone-100 text-stone-600 uppercase tracking-wider",children:n})]}),e.jsx("span",{className:`text-[9px] font-medium px-2 py-0.5 border uppercase tracking-wider flex-shrink-0 ${te[i]}`,children:i})]})}const ae={prospect:"bg-amber-50 text-amber-700 border-amber-200",active:"bg-emerald-50 text-emerald-700 border-emerald-200",alumni:"bg-blue-50 text-blue-700 border-blue-200",inactive:"bg-stone-100 text-stone-500 border-stone-200"},ne=["prospect","active","alumni","inactive"];function ie({user:t,profile:s,record:a,onRecordUpdate:l}){const r=t.full_name||t.email,i=(a==null?void 0:a.resident_status)||"prospect";return e.jsx("div",{className:"border-b border-stone-100 pb-6 mb-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-stone-100 flex items-center justify-center flex-shrink-0 overflow-hidden",children:s!=null&&s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:"",className:"w-full h-full object-cover"}):e.jsx($,{className:"w-6 h-6 text-stone-300",strokeWidth:1})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-lg font-semibold text-stone-900 leading-tight",children:r}),e.jsx("p",{className:"text-sm text-stone-400",children:t.email}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-2",children:[(s==null?void 0:s.student_id)&&e.jsx("span",{className:"text-[9px] font-mono tracking-widest text-stone-500 uppercase border border-stone-200 px-2 py-0.5",children:s.student_id}),(s==null?void 0:s.location)&&e.jsx("span",{className:"text-xs text-stone-400",children:s.location}),t.created_date&&e.jsxs("span",{className:"text-xs text-stone-400",children:["Joined ",A(new Date(t.created_date),"MMM yyyy")]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] uppercase tracking-widest text-stone-400 block mb-1",children:"Status"}),e.jsx("select",{value:i,onChange:n=>l({resident_status:n.target.value}),className:`text-[10px] font-medium px-2 py-1 border uppercase tracking-wider appearance-none cursor-pointer ${ae[i]}`,children:ne.map(n=>e.jsx("option",{value:n,children:n},n))})]})]})})}const ce=["","purchased","admin_granted","scholarship","beta_access","residency_admission","founder_grant"],de={"":"—",purchased:"Purchased",admin_granted:"Admin Granted",scholarship:"Scholarship",beta_access:"Beta Access",residency_admission:"Residency Admission",founder_grant:"Founder Grant"},le=[{key:"trace",label:"TRACE",sourceKey:"trace_access_source"},{key:"labs",label:"LABS",sourceKey:"labs_access_source"},{key:"studio",label:"STUDIO",sourceKey:"studio_access_source"},{key:"residency",label:"RESIDENCY",sourceKey:"residency_access_source"}];function re({record:t,profile:s,userId:a,onRecordUpdate:l}){const{data:r=[]}=h({queryKey:["access-lab-enrolments",a],queryFn:()=>x.entities.LabEnrolment.filter({resident_id:a}),enabled:!!a}),{data:i=[]}=h({queryKey:["access-studio-enrolments",s==null?void 0:s.id],queryFn:()=>x.entities.Enrollment.filter({student_profile_id:s.id}),enabled:!!(s!=null&&s.id)}),{data:n=[]}=h({queryKey:["access-traces",a],queryFn:()=>x.entities.Trace.filter({owner_id:a}),enabled:!!a}),d={trace:n.length>0,labs:r.some(c=>
1c.payment_status==="paid"||c.payment_status==="free"),studio:(s==null?void 0:s.enrollment_status)==="approved"||i.some(c=>c.status==="active"||c.status==="completed"),residency:(s==null?void 0:s.enrollment_status)==="approved"&&((t==null?void 0:t.residency_status)==="active"||(t==null?void 0:t.residency_status)==="applied")},m={trace:n.length>0?"purchased":"",labs:r.some(c=>c.payment_status==="paid")?"purchased":r.some(c=>c.payment_status==="free")?"admin_granted":"",studio:(s==null?void 0:s.enrollment_status)==="approved"?"purchased":"",residency:(t==null?void 0:t.residency_status)==="active"?"residency_admission":""};return e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400 mb-3",children:"Department Access"}),e.jsx("div",{className:"border border-stone-100 divide-y divide-stone-100",children:le.map(({key:c,label:u,sourceKey:j})=>{const w=`${c}_access`,y=(t==null?void 0:t[w])||!1,f=(t==null?void 0:t[j])||"",k=d[c],S=k&&!y;return e.jsxs("div",{className:"flex items-center gap-4 px-4 py-3",children:[e.jsx("div",{className:"w-20 flex-shrink-0",children:e.jsx("p",{className:"text-[10px] font-medium tracking-widest uppercase text-stone-700",children:u})}),e.jsx(U,{checked:y,onCheckedChange:g=>{const p={[w]:g};g&&!f&&m[c]&&(p[j]=m[c]),l(p)}}),e.jsx("span",{className:`text-[9px] px-2 py-0.5 uppercase tracking-wider font-medium ${y?"bg-emerald-50 text-emerald-700 border border-emerald-200":"bg-stone-50 text-stone-400 border border-stone-200"}`,children:y?"Enabled":"Disabled"}),S&&e.jsx("span",{className:"text-[9px] px-2 py-0.5 border border-amber-300 bg-amber-50 text-amber-700 uppercase tracking-wider font-medium",children:"Signed Up"}),k&&y&&e.jsx("span",{className:"text-[9px] text-stone-300 uppercase tracking-wider",children:"Verified"}),e.jsx("div",{className:"ml-auto",children:e.jsx("select",{value:f,onChange:g=>l({[j]:g.target.value}),className:"text-[9px] uppercase tracking-wider text-stone-500 bg-transparent border-0 appearance-none cursor-pointer hover:text-stone-700 outline-none",children:ce.map(g=>e.jsx("option",{value:g,children:de[g]},g))})})]},c)})}),e.jsx("p",{className:"text-[9px] text-stone-300 mt-1.5 px-1",children:'"Signed Up" = activity detected but access not yet enabled. Toggle to grant access.'})]})}const F={SORA:"bg-sky-50 text-sky-700 border-sky-200",AERO:"bg-violet-50 text-violet-700 border-violet-200",ONYX:"bg-stone-800 text-white border-stone-700",NOVA:"bg-amber-50 text-amber-700 border-amber-200"},oe=["","SORA","AERO","ONYX","NOVA"];function xe({profile:t,record:s,onRecordUpdate:a}){const l=(s==null?void 0:s.override_tra)||(t==null?void 0:t.primary_tra),r=t==null?void 0:t.secondary_tra,i=(s==null?void 0:s.override_sos)??((t==null?void 0:t.self_score)||0)+((t==null?void 0:t.other_score)||0)+((t==null?void 0:t.synthesis_score)||0);return e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400 mb-3",children:"TRESDA Identity"}),e.jsxs("div",{className:"border border-stone-100 p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400 mb-2",children:"TRA Archetype"}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[l?e.jsx("span",{className:`text-xs font-medium px-3 py-1 border uppercase tracking-widest ${F[l]||"bg-stone-100 text-stone-700 border-stone-200"}`,children:l}):e.jsx("span",{className:"text-xs text-stone-300",children:"Not classified"}),r&&r!==l&&e.jsx("span",{className:`text-xs font-medium px-3 py-1 border uppercase tracking-widest opacity-60 ${F[r]||"bg-stone-100 text-stone-700 border-stone-200"}`,children:r}),(t==null?void 0:t.tra_completed_at)&&e.jsx("span",{className:"text-[9px] text-stone-400 ml-auto",children:new Date(t.tra_completed_at).toLocaleDateString("en-GB",{month:"short",year:"numeric"})})]}),e.jsxs("div",{className:"mt-2",children:[e.jsx("label",{className:"text-[9px] uppercase tracking-widest text-stone-400 block mb-1",children:"Admin Override"}),e.jsx("select",{value:(s==null?void 0:s.override_tra)||"",onChange:n=>a({override_tra:n.target.value}),className:"text-xs text-stone-700 bg-stone-50 border border-stone-200 px-2 py-1 outline-none",children:oe.map(n=>e.jsx("option",{value:n,children:n||"— Use assessed value —"},n))})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400 mb-2",children:"SOS Score"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-2xl font-semibold text-stone-900 tabular-nums",children:i.toFixed(1)}),e.jsxs("div",{className:"text-xs text-stone-400 space-y-0.5",children:[e.jsxs("p",{children:["Self: ",e.jsx("span",{className:"text-stone-600 font-medium",children:(t==null?void 0:t.self_score)??"—"})]}),e.jsxs("p",{children:["Other: ",e.jsx("span",{className:"text-stone-600 font-medium",children:(t==null?void 0:t.other_score)??"—"})]}),e.jsxs("p",{children:["Synthesis: ",e.jsx("span",{className:"text-stone-600 font-medium",children:(t==null?void 0:t.synthesis_score)??"—"})]})]})]}),e.jsxs("div",{className:"mt-2",children:[e.jsx("label",{className:"text-[9px] uppercase tracking-widest text-stone-400 block mb-1",children:"Admin Override SOS"}),e.jsx("input",{type:"number",min:0,max:30,step:.1,value:(s==null?void 0:s.override_sos)??"",onChange:n=>a({override_sos:n.target.value?parseFloat(n.target.value):null}),placeholder:"Leave blank to use calculated",className:"text-xs text-stone-700 bg-stone-50 border border-stone-200 px-2 py-1 
1w-48 outline-none"})]})]})]})]})}const me={active:"bg-blue-50 text-blue-700 border-blue-200",completed:"bg-emerald-50 text-emerald-700 border-emerald-200",dropped:"bg-stone-100 text-stone-500 border-stone-200"};function ue({userId:t}){const{data:s=[]}=h({queryKey:["resident-lab-enrolments",t],queryFn:()=>x.entities.LabEnrolment.filter({resident_id:t}),enabled:!!t}),{data:a=[]}=h({queryKey:["all-labs"],queryFn:()=>x.entities.Lab.list()}),{data:l=[]}=h({queryKey:["resident-lab-certs",t],queryFn:()=>x.entities.LabCertificate.filter({resident_id:t}),enabled:!!t}),r=s.filter(d=>d.status==="active"),i=s.filter(d=>d.status==="completed"),n=d=>{var m;return((m=a.find(c=>c.id===d))==null?void 0:m.title)||"Unknown Lab"};return e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400 mb-3",children:"Labs"}),e.jsxs("div",{className:"border border-stone-100",children:[e.jsx("div",{className:"grid grid-cols-3 divide-x divide-stone-100 border-b border-stone-100",children:[{label:"Active",value:r.length},{label:"Completed",value:i.length},{label:"Certificates",value:l.length}].map(({label:d,value:m})=>e.jsxs("div",{className:"px-4 py-3 text-center",children:[e.jsx("p",{className:"text-xl font-semibold text-stone-900",children:m}),e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400",children:d})]},d))}),s.length===0?e.jsx("p",{className:"text-xs text-stone-400 px-4 py-4",children:"No lab enrolments."}):e.jsx("div",{className:"divide-y divide-stone-100",children:s.map(d=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-stone-800 truncate",children:n(d.lab_id)}),e.jsxs("p",{className:"text-[9px] text-stone-400 mt-0.5",children:[d.tier==="resident_plus"?"Resident Plus":"Resident",d.enrolled_at&&` · Enrolled ${A(new Date(d.enrolled_at),"dd MMM yyyy")}`]})]}),e.jsx("span",{className:`text-[9px] px-2 py-0.5 border uppercase tracking-wider font-medium ${me[d.status]||"bg-stone-100 text-stone-500 border-stone-200"}`,children:d.status}),l.find(m=>m.lab_id===d.lab_id)&&e.jsx("span",{className:"text-[9px] px-2 py-0.5 border border-amber-200 bg-amber-50 text-amber-700 uppercase tracking-wider font-medium",children:"Certified"})]},d.id))})]})]})}function pe({userId:t,onUpdate:s}){const[a,l]=N.useState(!1),r=K(),{data:i=[]}=h({queryKey:["all-labs"],queryFn:()=>x.entities.Lab.list()}),{data:n=[]}=h({queryKey:["resident-lab-enrolments-access",t],queryFn:()=>x.entities.LabEnrolment.filter({resident_id:t}),enabled:!!t}),d=T({mutationFn:c=>x.entities.LabEnrolment.create(c),onSuccess:()=>{r.invalidateQueries({queryKey:["resident-lab-enrolments-access",t]}),s==null||s()}});T({mutationFn:({id:c,data:u})=>x.entities.LabEnrolment.update(c,u),onSuccess:()=>{r.invalidateQueries({queryKey:["resident-lab-enrolments-access",t]}),s==null||s()}});const m=c=>{n.find(j=>j.lab_id===c)||d.mutate({lab_id:c,resident_id:t,tier:"resident",payment_status:"paid",enrolled_at:new Date().toISOString()}),l(!1)};return n.some(c=>c.payment_status==="paid"||c.payment_status==="free"),e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400 mb-3",children:"Lab Access"}),e.jsxs("div",{className:"border border-stone-100",children:[e.jsxs("div",{className:"flex items-center gap-4 px-4 py-3 relative",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-xs font-medium text-stone-800",children:n.length===0?"No labs assigned":`${n.length} lab${n.length>1?"s":""} assigned`})}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>l(!a),className:"flex items-center gap-1 text-[9px] px-3 py-1.5 border border-stone-200 rounded hover:bg-stone-50 transition-colors",children:["Add Lab",e.jsx(Q,{className:"w-3 h-3",strokeWidth:2})]}),a&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>l(!1)}),e.jsx("div",{className:"absolute top-full right-0 mt-1 z-20 bg-white border border-stone-200 rounded shadow-sm",children:i.map(c=>{const u=n.some(j=>j.lab_id===c.id);return e.jsx("button",{onClick:()=>m(c.id),disabled:u,className:`block w-full text-left px-4 py-2 text-[9px] uppercase tracking-wider font-medium transition-colors ${u?"bg-stone-50 text-stone-300 cursor-default":"hover:bg-stone-50 text-stone-700"}`,children:c.title},c.id)})})]})]})]}),n.length>0&&e.jsx("div",{className:"divide-y divide-stone-100 border-t border-stone-100",children:n.map(c=>{const u=i.find(j=>j.id===c.lab_id);return e.jsxs("div",{className:"flex items-center gap-4 px-4 py-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-stone-800",children:(u==null?void 0:u.title)||"Unknown Lab"}),e.jsxs("p",{className:"text-[9px] text-stone-400 mt-0.5",children:[c.tier==="resident_plus"?"Resident Plus":"Resident"," · ",c.payment_status]})]}),e.jsx("span",{className:`text-[9px] px-2 py-0.5 border uppercase tracking-wider font-medium ${c.payment_status==="paid"?"bg-emerald-50 text-emerald-700 border-emerald-200":"bg-stone-100 text-stone-500 border-stone-200"}`,children:c.payment_status})]},c.id)})})]})]})}function he({userId:t}){const s=W(),{data:a=[]}=h({queryKey:["resident-trace-projects",t],queryFn:()=>x.entities.Trace.filter({owner_id:t}),enabled:!!t}),{data:l=[]}=h({queryKey:["resident-trace-items",t],queryFn:()=>x.entities.TraceItem.filter({created_by_id:t}),enabled:!!t}),r=a.filter(n=>!n.is_archived&&!n.parent_id),i=l.sort((n,d)=>new Date(d.created_date)-new Date(n.created_date))[0];return e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400",children:"TRACE"}),e.jsxs("button",{onClick:()=>s(`/profile/${t}`),className:"flex items-center gap-1 text-[9px] uppercase tracking-widest text-stone-400 hover:text-stone-700 transition-colors",children:["Open Profile ",e.jsx(G,{className:"w-3 h-3"})]})]}),e.jsxs("div",{className:"border border-stone-100",children:[e.jsxs("div",{className:"grid grid-cols-2 divide-x divide-stone-100 border-b border-stone-100",children:[e.jsxs("div",{className:"px-4 py-3 text-center",children:[e.jsx("p",{className:"text-xl font-semibold text-stone-900",children:r.length}),e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400",children:"Projects"})]}),e.jsxs("div",{className:"px-4 py-3 text-center",children:[e.jsx("p",{className:"text-xl font-semibold text-stone-900",children:l.length}),e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400",children:"Traces"})]})]}),e.jsx("div",{className:"px-4 py-3",children:i?e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400 mb-1",children:"Most Recent Trace"}),e.jsx("p",{className:"text-xs text-stone-700 font-medium truncate",children:i.title||"Untitled"}),e.jsx("p",{className:"text-[9px] text-stone-400 mt-0.5",children:A(new Date(i.created_date),"dd MMM yyyy, HH:mm")}
1)]}):e.jsx("p",{className:"text-xs text-stone-400",children:"No traces yet."})})]})]})}const be=["not_started","001_active","002_active","completed"],je={not_started:"Not Started","001_active":"001 Active","002_active":"002 Active",completed:"Completed"},ge={not_started:"bg-stone-50 text-stone-500 border-stone-200","001_active":"bg-blue-50 text-blue-700 border-blue-200","002_active":"bg-violet-50 text-violet-700 border-violet-200",completed:"bg-emerald-50 text-emerald-700 border-emerald-200"};function ve({userId:t,profile:s,record:a,cohorts:l,onRecordUpdate:r}){const i=(a==null?void 0:a.studio_status)||"not_started",n=l.find(c=>c.id===(s==null?void 0:s.cohort_id)),{data:d=[]}=h({queryKey:["resident-enrollments",s==null?void 0:s.id],queryFn:()=>x.entities.Enrollment.filter({student_profile_id:s.id}),enabled:!!(s!=null&&s.id)}),{data:m=[]}=h({queryKey:["resident-submissions",t],queryFn:()=>x.entities.Submission.filter({student_id:t}),enabled:!!t});return e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400 mb-3",children:"Studio"}),e.jsxs("div",{className:"border border-stone-100 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{className:"text-[9px] uppercase tracking-widest text-stone-400 w-24 flex-shrink-0",children:"Status"}),e.jsx("select",{value:i,onChange:c=>r({studio_status:c.target.value}),className:`text-[10px] font-medium px-2 py-1 border uppercase tracking-wider appearance-none cursor-pointer outline-none ${ge[i]}`,children:be.map(c=>e.jsx("option",{value:c,children:je[c]},c))})]}),n&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[9px] uppercase tracking-widest text-stone-400 w-24 flex-shrink-0",children:"Cohort"}),e.jsx("span",{className:"text-xs text-stone-700",children:n.name})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[9px] uppercase tracking-widest text-stone-400 w-24 flex-shrink-0",children:"Enrolments"}),e.jsxs("span",{className:"text-xs text-stone-700",children:[d.length," active"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[9px] uppercase tracking-widest text-stone-400 w-24 flex-shrink-0",children:"Submissions"}),e.jsxs("span",{className:"text-xs text-stone-700",children:[m.length," total"]})]})]})]})}function Ne({date:t,label:s,source:a}){return e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center flex-shrink-0",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-stone-400 mt-1.5 flex-shrink-0"}),e.jsx("div",{className:"w-px flex-1 bg-stone-100 mt-1"})]}),e.jsxs("div",{className:"pb-4",children:[e.jsx("p",{className:"text-xs font-medium text-stone-800",children:s}),e.jsxs("p",{className:"text-[9px] text-stone-400 mt-0.5",children:[t?A(new Date(t),"dd MMM yyyy"):"Date unknown",a&&e.jsx("span",{className:"ml-2 uppercase tracking-wider",children:a})]})]})]})}function ye({user:t,profile:s,record:a,enrolments:l,labs:r}){const i=[];return t.created_date&&i.push({date:t.created_date,label:"Resident ID Created",sort:new Date(t.created_date)}),s!=null&&s.tra_completed_at&&i.push({date:s.tra_completed_at,label:`TRA Generated — ${s.primary_tra||""}`,sort:new Date(s.tra_completed_at)}),a!=null&&a.trace_access&&a.created_date&&i.push({date:a.created_date,label:"TRACE Activated",sort:new Date(a.created_date)}),l.forEach(n=>{const d=r.find(c=>c.id===n.lab_id),m=(d==null?void 0:d.title)||"Lab";n.enrolled_at&&i.push({date:n.enrolled_at,label:`${m} — Enrolled`,sort:new Date(n.enrolled_at)}),n.completed_at&&i.push({date:n.completed_at,label:`${m} — Completed`,sort:new Date(n.completed_at)})}),((a==null?void 0:a.studio_status)==="001_active"||(a==null?void 0:a.studio_status)==="002_active"||(a==null?void 0:a.studio_status)==="completed")&&i.push({date:null,label:"Studio Enrolled",sort:new Date(0)}),(a==null?void 0:a.studio_status)==="completed"&&i.push({date:null,label:"Studio Completed",sort:new Date(0)}),(a==null?void 0:a.residency_status)!=="not_applied"&&(a!=null&&a.residency_status)&&i.push({date:null,label:`Residency — ${a.residency_status.charAt(0).toUpperCase()+a.residency_status.slice(1)}`,sort:new Date(0)}),i.sort((n,d)=>d.sort-n.sort),e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400 mb-3",children:"Resident Timeline"}),e.jsx("div",{className:"border border-stone-100 px-4 pt-4 pb-0",children:i.length===0?e.jsx("p",{className:"text-xs text-stone-400 pb-4",children:"No activity recorded yet."}):i.map((n,d)=>e.jsx(Ne,{date:n.date,label:n.label},d))})]})}function _e({record:t,onRecordUpdate:s}){var n;const[a,l]=N.useState(null);if(!((t==null?void 0:t.residency_status)==="applied"&&((n=t==null?void 0:t.admin_notes)==null?void 0:n.includes("AWAITING ACCEPTANCE"))))return null;const i=async d=>{var m,c;l(d);try{const u=await x.functions.invoke("processResidencyApplication",{resident_record_id:t.
1id,action:d});(m=u.data)!=null&&m.success?(C.success(d==="accept"?"Application accepted — payment captured.":"Application rejected — payment hold released."),s(d==="accept"?{residency_access:!0,residency_access_source:"residency_admission",resident_status:"active",residency_status:"active"}:{residency_status:"not_applied"})):C.error(((c=u.data)==null?void 0:c.error)||"Something went wrong.")}catch{C.error("Failed to process application.")}finally{l(null)}};return e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400 mb-3",children:"Residency Application"}),e.jsxs("div",{className:"border border-amber-200 bg-amber-50 p-4",children:[e.jsx("p",{className:"text-xs text-amber-800 mb-1 font-medium",children:"Payment on hold — awaiting your decision"}),e.jsx("p",{className:"text-[10px] text-amber-700 mb-4 leading-relaxed",children:"Accepting will capture £1,800. Rejecting will release the card hold immediately — no charge."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(E,{size:"sm",onClick:()=>i("accept"),disabled:!!a,className:"gap-1.5 bg-emerald-700 hover:bg-emerald-800 text-white text-xs",children:[a==="accept"?e.jsx(D,{className:"w-3 h-3 animate-spin"}):e.jsx(X,{className:"w-3 h-3"}),"Accept"]}),e.jsxs(E,{size:"sm",variant:"outline",onClick:()=>i("reject"),disabled:!!a,className:"gap-1.5 border-red-300 text-red-700 hover:bg-red-50 text-xs",children:[a==="reject"?e.jsx(D,{className:"w-3 h-3 animate-spin"}):e.jsx(ee,{className:"w-3 h-3"}),"Reject"]})]})]})]})}function we({record:t,onRecordUpdate:s}){const[a,l]=N.useState((t==null?void 0:t.admin_notes)||""),[r,i]=N.useState(!1),n=()=>{s({admin_notes:a}),i(!0),setTimeout(()=>i(!1),2e3)};return e.jsxs(e.Fragment,{children:[e.jsx(_e,{record:t,onRecordUpdate:s}),e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400 mb-3",children:"Admin Notes"}),e.jsxs("div",{className:"border border-stone-100 p-4",children:[e.jsx(I,{value:a,onChange:d=>l(d.target.value),placeholder:"Private notes visible only to administrators...",className:"text-sm bg-stone-50 border-stone-200 resize-none min-h-[100px] outline-none focus:ring-0",rows:4}),e.jsx("div",{className:"flex justify-end mt-2",children:e.jsx(E,{size:"sm",onClick:n,className:`text-xs gap-1.5 ${r?"bg-emerald-700 hover:bg-emerald-700":"bg-stone-900 hover:bg-stone-800"} text-white`,children:r?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"w-3 h-3"})," Saved"]}):"Save Notes"})})]})]})]})}const fe=["Resident","Studio Resident","Residency Resident","SORA","AERO","ONYX","NOVA"];function ke({record:t,onRecordUpdate:s}){const a=(t==null?void 0:t.discord_connected)||!1,l=(t==null?void 0:t.discord_username)||"",r=(t==null?void 0:t.discord_roles)||[],i=n=>{const d=r.includes(n)?r.filter(m=>m!==n):[...r,n];s({discord_roles:d})};return e.jsxs("div",{className:"mb-6",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400 mb-3",children:"Community — Discord"}),e.jsxs("div",{className:"border border-stone-100 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[9px] uppercase tracking-widest text-stone-400 w-28 flex-shrink-0",children:"Connected"}),e.jsx(U,{checked:a,onCheckedChange:n=>s({discord_connected:n})}),e.jsx("span",{className:`text-[9px] px-2 py-0.5 border uppercase tracking-wider font-medium ${a?"bg-indigo-50 text-indigo-700 border-indigo-200":"bg-stone-50 text-stone-400 border-stone-200"}`,children:a?"Yes":"No"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[9px] uppercase tracking-widest text-stone-400 w-28 flex-shrink-0",children:"Username"}),e.jsx(P,{value:l,onChange:n=>s({discord_username:n.target.value}),placeholder:"username#0000",className:"text-xs h-7 bg-stone-50 border-stone-200 w-48"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-stone-400 mb-2",children:"Discord Roles"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:fe.map(n=>e.jsx("button",{onClick:()=>i(n),className:`text-[9px] px-2.5 py-1 border uppercase tracking-wider font-medium transition-colors ${r.includes(n)?"bg-stone-900 text-white border-stone-900":"bg-white text-stone-500 border-stone-200 hover:border-stone-400"}`,children:n},n))})]})]})]})}const Se=["all","prospect","active","alumni","inactive"];function Le(){const t=K(),[s,a]=N.useState(""),[l,r]=N.useState("all"),[i,n]=N.useState(null),{data:d=[],isLoading:m}=h({queryKey:["rd-users"],queryFn:()=>x.entities.User.list("-created_date",500)}),{data:c=[]}=h({queryKey:["rd-profiles"],queryFn:()=>x.entities.TRESDAProfile.list("-created_date",500)}),{data:u=[],isLoading:j}=h({queryKey:["rd-records"],queryFn:()=>x.entities.ResidentRecord.list("-created_date",500)}),{data:w=[]}=h({queryKey:["rd-cohorts"],queryFn:()=>x.entities.Cohort.list("name")}
1),{data:y=[]}=h({queryKey:["rd-all-enrolments"],queryFn:()=>x.entities.LabEnrolment.list("-enrolled_at",500)}),{data:f=[]}=h({queryKey:["rd-all-labs"],queryFn:()=>x.entities.Lab.list()}),k=T({mutationFn:async({userId:o,data:b})=>{const v=u.find(R=>R.user_id===o);return v?x.entities.ResidentRecord.update(v.id,b):x.entities.ResidentRecord.create({user_id:o,...b})},onSuccess:()=>t.invalidateQueries({queryKey:["rd-records"]})}),S=d.map(o=>({user:o,profile:c.find(b=>b.user_id===o.id)||null,record:u.find(b=>b.user_id===o.id)||null})),g=S.filter(({user:o,record:b})=>{const v=(o.full_name||o.email||"").toLowerCase(),R=!s||v.includes(s.toLowerCase())||(o.email||"").toLowerCase().includes(s.toLowerCase()),Y=(b==null?void 0:b.resident_status)||"prospect";return R&&(l==="all"||Y===l)}),p=i?S.find(o=>o.user.id===i):null,M=i?y.filter(o=>o.resident_id===i):[],_=o=>{i&&k.mutate({userId:i,data:o})},[q,L]=N.useState(!1),z=async()=>{if(window.confirm(`Enable TRACE access for all ${d.length} residents? This will create or update their records.`)){L(!0);for(const o of d){const b=u.find(v=>v.user_id===o.id);try{b?b.trace_access||await x.entities.ResidentRecord.update(b.id,{trace_access:!0,trace_access_source:"admin_granted"}):await x.entities.ResidentRecord.create({user_id:o.id,trace_access:!0,trace_access_source:"admin_granted"})}catch{}}await t.invalidateQueries({queryKey:["rd-records"]}),L(!1)}},B=m||j;return e.jsxs("div",{className:"min-h-screen bg-stone-50",children:[e.jsxs("header",{className:"bg-white border-b border-stone-100 px-6 lg:px-10 py-4 flex items-center gap-4 sticky top-0 z-30",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] uppercase tracking-[0.35em] text-stone-400",children:"Admin · TRESDA Institute"}),e.jsx("h1",{className:"text-base font-semibold text-stone-900 leading-tight",children:"Resident Directory"})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs("button",{onClick:z,disabled:q||m||j,className:"flex items-center gap-1.5 px-3 py-1.5 text-[9px] uppercase tracking-widest font-medium border border-stone-200 text-stone-500 hover:bg-stone-900 hover:text-white hover:border-stone-900 transition-colors disabled:opacity-40",children:[e.jsx(H,{className:"w-3 h-3",strokeWidth:1.5}),q?"Enabling...":"Enable TRACE for All"]}),e.jsxs("div",{className:"relative",children:[e.jsx(J,{className:"w-3.5 h-3.5 text-stone-400 absolute left-3 top-1/2 -translate-y-1/2"}),e.jsx(P,{placeholder:"Search residents...",value:s,onChange:o=>a(o.target.value),className:"pl-8 h-8 text-xs w-56 bg-stone-50 border-stone-200"})]})]})]}),e.jsxs("div",{className:"flex h-[calc(100vh-57px)]",children:[e.jsxs("div",{className:`${i?"hidden md:flex":"flex"} flex-col w-full md:w-80 lg:w-96 flex-shrink-0 border-r border-stone-100 bg-white overflow-hidden`,children:[e.jsx("div",{className:"flex gap-0 border-b border-stone-100 overflow-x-auto",children:Se.map(o=>e.jsx("button",{onClick:()=>r(o),className:`flex-shrink-0 px-4 py-2.5 text-[9px] uppercase tracking-widest font-medium transition-colors ${l===o?"bg-stone-900 text-white":"text-stone-400 hover:text-stone-700"}`,children:o},o))}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:B?e.jsx("div",{className:"p-6 text-xs text-stone-400",children:"Loading..."}):g.length===0?e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(O,{className:"w-6 h-6 text-stone-200 mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-stone-400",children:"No residents found"})]}):g.map(({user:o,profile:b,record:v})=>e.jsx(se,{user:o,profile:b,record:v,onClick:()=>n(o.id)},o.id))}),e.jsx("div",{className:"border-t border-stone-100 px-4 py-2.5",children:e.jsxs("p",{className:"text-[9px] text-stone-400 uppercase tracking-widest",children:[g.length," residents"]})})]}),e.jsx("div",{className:`${i?"flex":"hidden md:flex"} flex-1 flex-col overflow-hidden`,children:p?e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("button",{onClick:()=>n(null),className:"md:hidden flex items-center gap-2 px-6 pt-4 pb-2 text-xs text-stone-400 hover:text-stone-700 transition-colors",children:[e.jsx(Z,{className:"w-3.5 h-3.5"})," Back to Directory"]}),e.jsxs("div",{className:"px-6 lg:px-10 pt-6 pb-16 max-w-2xl",children:[e.jsx(ie,{user:p.user,profile:p.profile,record:p.record,onRecordUpdate:_}),e.jsx(re,{record:p.record,profile:p.profile,userId:i,onRecordUpdate:_}),e.jsx(xe,{profile:p.profile,record:p.record,onRecordUpdate:_}),e.jsx(he,{userId:i}),e.jsx(pe,{userId:i,onUpdate:()=>
1t.invalidateQueries({queryKey:["rd-all-enrolments"]})}),e.jsx(ue,{userId:i}),e.jsx(ve,{userId:i,profile:p.profile,record:p.record,cohorts:w,onRecordUpdate:_}),e.jsx(ye,{user:p.user,profile:p.profile,record:p.record,enrolments:M,labs:f}),e.jsx(ke,{record:p.record,onRecordUpdate:_}),e.jsx(we,{record:p.record,onRecordUpdate:_})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-10 h-10 border border-stone-200 flex items-center justify-center mx-auto mb-3",children:e.jsx(O,{className:"w-4 h-4 text-stone-300",strokeWidth:1})}),e.jsx("p",{className:"text-xs text-stone-400",children:"Select a resident to view their record"})]})})})]})]})}export{Le 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.