PageSourceSearch

https://tresda.institute/assets/AdminBridgingWorkshops-B6PEYTdS.js

js tresda.institute collected 2026-10-02 01:58:06 UTC 12,971 bytes, 1 lines download raw bytes

1import{r as d,u as A,b as j,a as p,j as e,n as O,X as $,I as g,T as X,g as h,k as Z,l as G,ae as J,o as U,af as V,x as _,m as r}from"./index-u0HMC9Vb.js";function ee(){var L;const[f,K]=d.useState("workshops"),[k,m]=d.useState(!1),[N,x]=d.useState(null),[D,S]=d.useState(!1),[n,W]=d.useState(null),[C,w]=d.useState(!1),B=d.useRef(),u=A(),[t,i]=d.useState({title:"",description:"",mentor_id:"",course_code:"001",capacity:20,location_type:"online",meeting_url:"",address:"",logo_url:""}),[c,y]=d.useState({start_time:"",end_time:""}),{data:b=[]}=j({queryKey:["bridgingWorkshops"],queryFn:()=>r.entities.BridgingWorkshop.list("-created_date")}),{data:M=[]}=j({queryKey:["mentors"],queryFn:()=>r.entities.Mentor.list()}),{data:q=[]}=j({queryKey:["sessions",n],queryFn:()=>r.entities.BridgingWorkshopSession.filter({workshop_id:n},"-start_time"),enabled:!!n}),{data:v=[]}=j({queryKey:["bookings",n],queryFn:async()=>{if(!n)return[];const a=(await r.entities.BridgingWorkshopSession.filter({workshop_id:n})).map(l=>l.id);return a.length===0?[]:(await r.entities.BridgingWorkshopBooking.list("-created_date",100)).filter(l=>a.includes(l.session_id))},enabled:!!n}),F=p({mutationFn:s=>r.entities.BridgingWorkshop.create(s),onSuccess:()=>{u.invalidateQueries({queryKey:["bridgingWorkshops"]}),m(!1),i({title:"",description:"",mentor_id:"",course_code:"001",capacity:20,location_type:"online",meeting_url:"",address:"",logo_url:""})}}),P=p({mutationFn:s=>r.entities.BridgingWorkshop.update(N.id,s),onSuccess:()=>{u.invalidateQueries({queryKey:["bridgingWorkshops"]}),x(null),i({title:"",description:"",mentor_id:"",course_code:"001",capacity:20,location_type:"online",meeting_url:"",address:"",logo_url:""})}}),Q=p({mutationFn:s=>r.entities.BridgingWorkshop.delete(s),onSuccess:()=>{u.invalidateQueries({queryKey:["bridgingWorkshops"]})}}),I=p({mutationFn:s=>r.entities.BridgingWorkshopSession.create(s),onSuccess:()=>{u.invalidateQueries({queryKey:["sessions",n]}),S(!1),y({start_time:"",end_time:""})}}),H=p({mutationFn:s=>r.entities.BridgingWorkshopSession.delete(s),onSuccess:()=>{u.invalidateQueries({queryKey:["sessions",n]})}}),T=()=>{if(!t.title){alert("Please enter a workshop title");return}N?P.mutate(t):F.mutate(t)},z=()=>{if(!c.start_time||!c.end_time||!n)return;const s=b.find(a=>a.id===n);I.mutate({workshop_id:n,start_time:c.start_time,end_time:c.end_time,available_spots:(s==null?void 0:s.capacity)||20})},E=s=>{x(s),i({title:s.title,description:s.description||"",mentor_id:s.mentor_id||"",course_code:s.course_code,capacity:s.capacity||20,location_type:s.location_type||"online",meeting_url:s.meeting_url||"",address:s.address||"",logo_url:s.logo_url||""}),m(!0)},R=async s=>{var l;const a=(l=s.target.files)==null?void 0:l[0];if(!a)return;w(!0);const{file_url:o}=await r.integrations.Core.UploadFile({file:a});i({...t,logo_url:o}),w(!1)};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-0",children:e.jsxs("div",{className:"max-w-7xl 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 mb-4",children:"Bridging Workshops"}),e.jsx("nav",{className:"flex gap-0",children:["workshops","sessions"].map(s=>e.jsx("button",{onClick:()=>K(s),className:`text-[10px] font-meta uppercase tracking-widest px-4 py-2.5 border-t-2 transition-all ${f===s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground/70"}`,children:s==="workshops"?"Workshops":"Sessions & Bookings"},s))})]})}),e.jsxs("div",{className:"max-w-7xl mx-auto px-5 lg:px-10 py-8",children:[f==="workshops"&&e.jsxs("div",{className:"space-y-6",children:[!k&&e.jsxs("button",{onClick:()=>{m(!0),x(null),i({title:"",description:"",mentor_id:"",course_code:"001",capacity:20,location_type:"online",meeting_url:"",address:"",logo_url:""})},className:"flex items-center gap-2 text-[10px] font-meta uppercase tracking-widest text-primary-foreground bg-primary hover:opacity-90 px-4 py-2",children:[e.jsx(O,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"New Workshop"]}),k&&e.jsxs("div",{className:"bg-card border border-border p-6 space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsxs("h3",{className:"text-sm font-semibold text-stone-900",children:[N?"Edit":"New"," Workshop"]}),e.jsx("button",{onClick:()=>{m(!1),x(null)},className:"text-stone-400 hover:text-stone-700",children:e.jsx($,{className:"w-4 h-4"})})]}),e.jsx(g,{placeholder:"Workshop title",value:t.title,onChange:s=>i({...t,title:s.target.value})}),e.jsx(X,{placeholder:"Description",value:t.description,onChange:s=>i({...t,description:s.target.value}),rows:3}),e.jsx(g,{placeholder:"Mentor name",value:t.mentor_id,onChange:s=>i({...t,mentor_id:s.target.value})}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-stone-600 mb-1 block",children:"Course Code"}),e.jsxs("select",{value:t.course_code,onChange:s=>i({...t,course_code:s.target.value}),className:"w-full border border-border bg-background px-3 py-2 text-sm",children:[e.jsx("option",{value:"001",children:"001 - Self"}),e.jsx("option",{value:"002",children:"002 - Other"}
1),e.jsx("option",{value:"003",children:"003 - Synthesis"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"Capacity"}),e.jsx(g,{type:"number",value:t.capacity,onChange:s=>i({...t,capacity:parseInt(s.target.value)}),min:1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"Location"}),e.jsxs("select",{value:t.location_type,onChange:s=>i({...t,location_type:s.target.value,meeting_url:"",address:""}),className:"w-full border border-border bg-background px-3 py-2 text-sm",children:[e.jsx("option",{value:"online",children:"Online"}),e.jsx("option",{value:"in-person",children:"In-Person"})]})]})]}),t.location_type==="online"?e.jsx(g,{placeholder:"Meeting URL (e.g., Zoom, Teams link)",value:t.meeting_url,onChange:s=>i({...t,meeting_url:s.target.value})}):e.jsx(g,{placeholder:"Physical address",value:t.address,onChange:s=>i({...t,address:s.target.value})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs text-stone-600 block",children:"Partner Logo"}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.logo_url&&e.jsx("img",{src:t.logo_url,alt:"Logo",className:"h-10 object-contain"}),e.jsx(h,{type:"button",size:"sm",variant:"outline",onClick:()=>{var s;return(s=B.current)==null?void 0:s.click()},disabled:C,className:"flex items-center gap-2",children:C?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-3 h-3 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-3 h-3",strokeWidth:1.5}),"Upload Logo"]})}),t.logo_url&&e.jsx("button",{type:"button",onClick:()=>i({...t,logo_url:""}),className:"text-xs text-red-600 hover:text-red-700",children:"Remove"})]})]}),e.jsx("input",{ref:B,type:"file",accept:"image/*",className:"hidden",onChange:R}),e.jsxs("div",{className:"flex gap-2 justify-end pt-4 border-t border-stone-100",children:[e.jsx(h,{variant:"outline",size:"sm",onClick:()=>{m(!1),x(null)},children:"Cancel"}),e.jsx(h,{size:"sm",onClick:T,disabled:F.isPending||P.isPending,children:"Save Workshop"})]})]}),e.jsx("div",{className:"space-y-2",children:b.map(s=>{var a;return e.jsx("div",{className:"bg-card border border-border p-4 hover:bg-muted/40 transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:s.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s.description}),s.logo_url&&e.jsx("div",{className:"mt-2 mb-2",children:e.jsx("img",{src:s.logo_url,alt:"Logo",className:"h-8 object-contain"})}),e.jsxs("div",{className:"flex gap-3 mt-2 text-xs flex-wrap",children:[e.jsxs("span",{className:"text-stone-600",children:["🎓 Mentor: ",((a=M.find(o=>o.id===s.mentor_id))==null?void 0:a.name)||"Unassigned"]}),e.jsxs("span",{className:"text-stone-600",children:["📚 Bridges course ",s.course_code]}),e.jsxs("span",{className:"text-stone-600",children:["👥 Capacity: ",s.capacity]}),e.jsx("span",{className:"text-stone-600",children:s.location_type==="online"?"💻 Online":"📍 In-Person"}),s.location_type==="online"&&s.meeting_url&&e.jsx("a",{href:s.meeting_url,target:"_blank",rel:"noopener noreferrer",className:"text-stone-600 underline",children:"Link"}),s.location_type==="in-person"&&s.address&&e.jsx("span",{className:"text-stone-600",children:s.address})]})]}),e.jsxs("div",{className:"flex gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>E(s),className:"p-2 text-stone-400 hover:text-stone-700 transition-colors",children:e.jsx(J,{className:"w-4 h-4",strokeWidth:1.5})}),e.jsx("button",{onClick:()=>Q.mutate(s.id),className:"p-2 text-stone-400 hover:text-red-600 transition-colors",children:e.jsx(U,{className:"w-4 h-4",strokeWidth:1.5})})]})]})},s.id)})})]}),f==="sessions"&&e.jsx("div",{className:"space-y-6",children:n?e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("button",{onClick:()=>W(null),className:"text-stone-400 hover:text-stone-700",children:"← Back"}),e.jsx("h2",{className:"text-lg font-display uppercase text-foreground",children:(L=b.find(s=>
1s.id===n))==null?void 0:L.title})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsx("h3",{className:"text-[10px] font-meta uppercase tracking-widest text-muted-foreground",children:"Sessions"})}),D&&e.jsxs("div",{className:"bg-card border border-border p-4 space-y-3",children:[e.jsx("input",{type:"datetime-local",value:c.start_time,onChange:s=>y({...c,start_time:s.target.value}),className:"w-full border border-border bg-background px-3 py-2 text-sm"}),e.jsx("input",{type:"datetime-local",value:c.end_time,onChange:s=>y({...c,end_time:s.target.value}),className:"w-full border border-border bg-background px-3 py-2 text-sm"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{size:"sm",variant:"outline",onClick:()=>S(!1),children:"Cancel"}),e.jsx(h,{size:"sm",onClick:z,disabled:I.isPending,children:"Add Session"})]})]}),e.jsx("div",{className:"space-y-2",children:q.map(s=>{const o=v.filter(l=>l.session_id===s.id).filter(l=>l.status==="booked").length;return e.jsx("div",{className:"bg-card border border-border p-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("p",{className:"text-xs font-semibold text-foreground flex items-center gap-2",children:[e.jsx(V,{className:"w-3 h-3",strokeWidth:1.5}),s.start_time&&s.end_time?`${_(new Date(s.start_time),"d MMM, HH:mm")} - ${_(new Date(s.end_time),"HH:mm")}`:"Invalid date"]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[o," / ",s.available_spots," booked"]})]}),e.jsx("button",{onClick:()=>H.mutate(s.id),className:"p-1 text-muted-foreground hover:text-red-600 transition-colors",children:e.jsx(U,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})},s.id)})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-[10px] font-meta uppercase tracking-widest text-muted-foreground",children:"Bookings"}),e.jsx("div",{className:"space-y-2",children:v.length===0?e.jsx("p",{className:"text-xs text-stone-400",children:"No bookings yet"}):v.map(s=>{const a=q.find(o=>o.id===s.session_id);return e.jsxs("div",{className:"bg-white border border-stone-200 p-3 text-xs",children:[e.jsx("p",{className:"text-stone-900",children:s.created_by}),e.jsx("p",{className:"text-stone-500 mt-0.5",children:_(new Date((a==null?void 0:a.start_time)||""),"d MMM, HH:mm")}),e.jsx("span",{className:`inline-block mt-1 px-2 py-0.5 text-[9px] font-meta uppercase tracking-widest ${s.status==="booked"?"bg-green-100 text-green-700":"bg-stone-100 text-stone-600"}`,children:s.status})]},s.id)})})]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-stone-600 mb-4",children:"Select a workshop to manage sessions and bookings:"}),b.map(s=>{var a;return e.jsxs("button",{onClick:()=>W(s.id),className:"w-full text-left bg-card border border-border p-4 hover:bg-muted/40 transition-colors",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:s.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Mentor: ",((a=M.find(o=>o.id===s.mentor_id))==null?void 0:a.name)||"Unassigned"," • ",s.location_type==="online"?"💻 Online":"📍 In-Person"]})]},s.id)})]})})]})]})}export{ee 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.