PageSourceSearch

https://bci-edu-6qu8apwz.manus.space/assets/AdminEvents-VKZJMB5s.js

js bci-edu-6qu8apwz.manus.space collected 2026-10-03 05:00:41 UTC 9,202 bytes, 1 lines download raw bytes

1import{j as e}from"./trpc-vendor-Bv0iaNDN.js";import{r as u}from"./react-vendor-CGOjsTCb.js";import{A}from"./AdminLayout-BvvhRFUw.js";import{t as i,i as g,f as y}from"./index-Bp5xQ-En.js";import{u as j}from"./forms-CoKEKBDA.js";import{P as N}from"./plus-BMR_veRJ.js";import{S as w}from"./square-pen-tpyoT_BD.js";import{T as S}from"./trash-2-DEzeex90.js";import"./bell-DDfP3iQl.js";import"./image-NXvCck6X.js";import"./message-square-D7ASK-H8.js";import"./graduation-cap-DtyfmjZD.js";import"./phone-call-DR-uxlHF.js";import"./radix-vendor-BsQgJgbQ.js";import"./charts-DUKIMxkY.js";function $(){const[p,n]=u.useState(!1),[d,c]=u.useState(null),r=i.useUtils(),{data:o,isLoading:v}=i.events.getAll.useQuery(),m=i.events.create.useMutation({onSuccess:()=>{r.events.getAll.invalidate(),n(!1),l(),g.success("Event created!")}}),x=i.events.update.useMutation({onSuccess:()=>{r.events.getAll.invalidate(),n(!1),c(null),l(),g.success("Event updated!")}}),b=i.events.delete.useMutation({onSuccess:()=>{r.events.getAll.invalidate(),g.success("Event deleted.")}}),{register:s,handleSubmit:h,reset:l,setValue:a}=j({defaultValues:{title:"",description:"",location:"",startDate:"",endDate:"",isPublished:!0}}),E=async t=>{d?await x.mutateAsync({id:d,...t}):await m.mutateAsync(t)},f=t=>{c(t.id),a("title",t.title),a("description",t.description||""),a("location",t.location||""),a("startDate",t.startDate?new Date(t.startDate).toISOString().slice(0,16):""),a("endDate",t.endDate?new Date(t.endDate).toISOString().slice(0,16):""),a("isPublished",t.isPublished),n(!0)};return e.jsx(A,{"data-loc":"client/src/pages/admin/AdminEvents.tsx:42",title:"Events Calendar",children:e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:43",className:"space-y-5",children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:44",className:"flex items-center justify-between",children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:45",children:[e.jsx("h1",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:46",className:"text-xl font-bold text-gray-900",children:"Events Calendar"}),e.jsx("p",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:47",className:"text-sm text-gray-500 mt-0.5",children:"Manage school events and key dates"})]}),e.jsxs("button",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:49",onClick:()=>{c(null),l(),n(!0)},className:"flex items-center gap-2 px-4 py-2.5 bg-bci text-white text-sm font-medium rounded-lg hover:bg-bci-dark transition-colors",children:[e.jsx(N,{"data-loc":"client/src/pages/admin/AdminEvents.tsx:51",size:16})," Add Event"]})]}),p&&e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:56",className:"bg-white rounded-xl border border-gray-200 shadow-sm p-6",children:[e.jsx("h2",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:57",className:"font-semibold text-gray-900 mb-5",children:d?"Edit Event":"New Event"}),e.jsxs("form",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:58",onSubmit:h(E),className:"space-y-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:59",children:[e.jsx("label",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:60",className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Event Title *"}),e.jsx("input",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:61",...s("title",{required:!0}),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-bci/30 focus:border-bci"})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:63",className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:64",children:[e.jsx("label",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:65",className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Start Date & Time *"}),e.jsx("input",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:66",...s("startDate",{required:!0}),type:"datetime-local",className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-bci/30 focus:border-bci"})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:68",children:[e.jsx("label",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:69",className:"block text-sm font-medium text-gray-700 mb-1.5",children:"End Date & Time"}),e.jsx("input",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:70",...s("endDate"),type:"datetime-local",className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-bci/30 focus:border-bci"})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:73",children:[e.jsx("label",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:74",className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Location"}),e.jsx("input",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:75",...s("location"),className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-bci/30 focus:border-bci",placeholder:"e.g. BCI Main Hall"})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:77",children:[e.jsx("label",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:78",className:"block text-sm font-medium text-gray-700 mb-1.5",children:"Description"}),e.jsx("textarea",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:79",...s("description"),rows:3,className:"w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-bci/30 focus:border-bci resize-none"})]}),e.jsxs("label",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:81",className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:82",type:"checkbox",...s("isPublished"),className:"w-4 h-4 accent-bci"}),e.jsx("span",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:83",className:"text-sm font-medium text-gray-700",children:"Show on website"})]}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:85",className:"flex gap-3",children:[e.jsx("button",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:86",type:"submit",disabled:m.isPending||x.isPending,className:"px-5 py-2.5 bg-bci text-white text-sm font-medium rounded-lg hover:bg-bci-dark transition-colors disabled:opacity-50",children:m.isPending||x.isPending?"Saving...":d?"Update":"Create"}),e.jsx("button",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:90",type:"button",onClick:()=>{n(!1),c(null),l()},className:"px-5 py-2.5 border border-gray-300 text-gray-700 text-sm font-medium rounded-lg hover:bg-gray-50 transition-colors",children:"Cancel"})]})]})]}),e.jsx("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:99",className:"bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden",children:v?e.jsx("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:101",className:"p-8 text-center text-gray-400 text-sm",children:"Loading..."}):!o||o.length===0?e.jsx("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:103",className:"p-8 text-center text-gray-400 text-sm",children:'No events yet. Click "Add Event" to create one.'}):e.jsx("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:105",className:"divide-y divide-gray-100",children:o.map(t=>e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:107",className:"flex items-center gap-4 p-4 hover:bg-gray-50 transition-colors",children:[e.jsx("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:108",className:"bg-bci/10 text-bci rounded-lg p-2.5 shrink-0",children:e.jsx(y,{"data-loc":"client/src/pages/admin/AdminEvents.tsx:109",size:20})}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:111",className:"flex-1 min-w-0",children:[e.jsx("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:112",className:"font-medium text-gray-900 text-sm",children:t.title}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:113",className:"text-xs text-gray-500 mt-0.5",children:[new Date(t.startDate).toLocaleStr
1ing("en-SG",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}),t.location&&` · ${t.location}`]})]}),e.jsx("span",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:118",className:`text-xs px-2 py-0.5 rounded-full shrink-0 ${t.isPublished?"bg-green-50 text-green-700":"bg-gray-100 text-gray-500"}`,children:t.isPublished?"Published":"Hidden"}),e.jsxs("div",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:121",className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:122",onClick:()=>f(t),className:"p-1.5 text-gray-400 hover:text-bci hover:bg-red-50 rounded transition-colors",children:e.jsx(w,{"data-loc":"client/src/pages/admin/AdminEvents.tsx:123",size:15})}),e.jsx("button",{"data-loc":"client/src/pages/admin/AdminEvents.tsx:125",onClick:()=>{confirm("Delete this event?")&&b.mutate({id:t.id})},className:"p-1.5 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded transition-colors",children:e.jsx(S,{"data-loc":"client/src/pages/admin/AdminEvents.tsx:127",size:15})})]})]},t.id))})})]})})}export{$ 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.