1import{r as n,j as e}from"./vendor-BFIOfVip.js";import{d as o}from"./index-CKRbob3g.js";import{C as P,k as p,G as m,K as y,u as h,j as g,J as E}from"./vendor-firebase-dJP658Hw.js";import{dx as L,dB as U,dC as N,dD as w,bO as O,ae as W,ax as T}from"./vendor-icons-BjlO8Ivt.js";import"./vendor-motion-C4-LgF0B.js";const z=()=>{const[l,k]=n.useState("volunteers"),[v,j]=n.useState(!1),[C,S]=n.useState([]),[A,D]=n.useState([]),[R,F]=n.useState([]),[a,i]=n.useState({title:"",description:"",date:"",startTime:"",endTime:"",points:10,type:"task",team:"General"}),[d,x]=n.useState({title:"",content:"",targetTeam:"All"}),[r,c]=n.useState({title:"",description:"",url:"",type:"pdf",category:"General"});n.useEffect(()=>{u()},[l]);const u=async()=>{j(!0);try{if(l==="volunteers"){const t=P(p(o,"users")),s=await m(t);S(s.docs.map(f=>({uid:f.id,...f.data()})))}else if(l==="tasks"){const t=await m(p(o,"volunteer_tasks"));D(t.docs.map(s=>({id:s.id,...s.data()})))}else if(l==="announcements"){const t=await m(p(o,"volunteer_announcements"));F(t.docs.map(s=>({id:s.id,...s.data()})))}}catch(t){console.error("Error fetching data:",t)}finally{j(!1)}},G=async t=>{if(window.confirm("Approve this user as a Volunteer?"))try{await y(h(o,"users",t),{role:"volunteer"}),u()}catch(s){console.error(s)}},q=async t=>{if(window.confirm("Revoke volunteer status?"))try{await y(h(o,"users",t),{role:"user"}),u()}catch(s){console.error(s)}},M=async t=>{t.preventDefault();try{await g(p(o,"volunteer_tasks"),{...a,status:"pending",assignedTo:null,createdAt:new Date().toISOString()}),alert("Task Created!"),i({title:"",description:"",date:"",startTime:"",endTime:"",points:10,type:"task",team:"General"}),u()}catch(s){console.error(s)}},V=async t=>{t.preventDefault();try{await g(p(o,"volunteer_announcements"),{...d,targetTeams:[d.targetTeam],date:new Date().toISOString(),author:"Admin"}),alert("Announcement Posted!"),x({title:"",content:"",targetTeam:"All"}),u()}catch(s){console.error(s)}},_=async t=>{t.preventDefault();try{await g(p(o,"volunteer_resources"),{...r,dateAdded:new Date().toISOString()}),alert("Resource Added!"),c({title:"",description:"",url:"",type:"pdf",category:"General"})}catch(s){console.error(s)}},b=async(t,s)=>{window.confirm("Delete this item?")&&(await E(h(o,s,t)),u())};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Volunteer Manager"}),e.jsx("div",{className:"flex border-b border-gray-200 space-x-4",children:[{id:"volunteers",label:"Volunteers",icon:e.jsx(L,{})},{id:"tasks",label:"Tasks & Shifts",icon:e.jsx(U,{})},{id:"announcements",label:"Announcements",icon:e.jsx(N,{})},{id:"resources",label:"Resources",icon:e.jsx(w,{})}].map(t=>e.jsxs("button",{onClick:()=>k(t.id),className:`flex items-center gap-2 pb-3 px-2 border-b-2 font-medium transition ${l===t.id?"border-purple-600 text-purple-600":"border-transparent text-gray-500 hover:text-gray-700"}`,children:[t.icon," ",t.label]},t.id))}),v&&e.jsxs("div",{className:"text-center py-4",children:[e.jsx(O,{className:"animate-spin inline text-2xl"})," Loading..."]}),l==="volunteers"&&!v&&e.jsx("div",{className:"bg-white rounded-xl shadow overflow-hidden",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-bold text-gray-500 uppercase",children:"User"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-bold text-gray-500 uppercase",children:"Email"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-bold text-gray-500 uppercase",children:"Role"}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-bold text-gray-500 uppercase",children:"Actions"})]})}),e.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:C.map(t=>e.jsxs("tr",{children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900",children:t.displayName||"No Name"}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:t.email}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm",children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs font-bold uppercase ${t.role==="volunteer"?"bg-green-100 text-green-800":t.role==="admin"?"bg-purple-100 text-purple-800":"bg-gray-100 text-gray-800"}`,children:t.role||"user"})}),e.jsxs("td",{className:"px-6 py-4 whitespace-nowrap text-right text-sm",children:[t.role!=="volunteer"&&t.role!=="admin"&&e.jsx("button",{onClick:()=>G(t.uid),className:"text-green-600 hover:text-green-900 font-bold mr-3",children:"Approve"}),t.role==="volunteer"&&e.jsx("button",{onClick:()=>q(t.uid),className:"text-red-600 hover:text-red-900 font-bold",children:"Revoke"})]})]},t.uid))})]})}),l==="tasks"&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-1 bg-white p-6 rounded-xl shadow h-fit",children:[e.jsxs("h3",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[e.jsx(W,{})," Create Task/Shift"]}),e.jsxs("form",{onSubmit:M,className:"space-y-4",children:[e.jsx("input",{required:!0,placeholder:"Title",className:"w-full p-2 border rounded",value:a.title,onChange:t=>i({...a,title:t.target.value})}),e.jsx("textarea",{placeholder:"Description",className:"w-full p-2 border rounded",value:a.description,onChange:t=>i({...a,description:t.target.value})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("select",{className:"p-2 border rounded",value:a.type,onCh
1ange:t=>i({...a,type:t.target.value}),children:[e.jsx("option",{value:"task",children:"Task"}),e.jsx("option",{value:"shift",children:"Shift"})]}),e.jsxs("select",{className:"p-2 border rounded",value:a.team,onChange:t=>i({...a,team:t.target.value}),children:[e.jsx("option",{value:"General",children:"General"}),e.jsx("option",{value:"Media",children:"Media"}),e.jsx("option",{value:"Welcome",children:"Welcome"}),e.jsx("option",{value:"Kids",children:"Kids"})]})]}),e.jsx("input",{required:!0,type:"date",className:"w-full p-2 border rounded",value:a.date,onChange:t=>i({...a,date:t.target.value})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("input",{type:"time",className:"p-2 border rounded",value:a.startTime,onChange:t=>i({...a,startTime:t.target.value})}),e.jsx("input",{type:"time",className:"p-2 border rounded",value:a.endTime,onChange:t=>i({...a,endTime:t.target.value})})]}),e.jsx("button",{type:"submit",className:"w-full bg-purple-600 text-white py-2 rounded font-bold hover:bg-purple-700",children:"Create"})]})]}),e.jsx("div",{className:"lg:col-span-2 space-y-4",children:A.map(t=>e.jsxs("div",{className:"bg-white p-4 rounded-xl shadow flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"font-bold",children:[t.title," ",e.jsx("span",{className:"text-xs bg-gray-100 px-2 py-1 rounded ml-2",children:t.type})]}),e.jsxs("p",{className:"text-sm text-gray-600",children:[t.date," | ",t.team]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Status: ",t.status," | Assigned: ",t.assignedTo||"Unassigned"]})]}),e.jsx("button",{onClick:()=>b(t.id,"volunteer_tasks"),className:"text-red-500 hover:text-red-700",children:e.jsx(T,{})})]},t.id))})]}),l==="announcements"&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-1 bg-white p-6 rounded-xl shadow h-fit",children:[e.jsxs("h3",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[e.jsx(N,{})," Post Announcement"]}),e.jsxs("form",{onSubmit:V,className:"space-y-4",children:[e.jsx("input",{required:!0,placeholder:"Title",className:"w-full p-2 border rounded",value:d.title,onChange:t=>x({...d,title:t.target.value})}),e.jsx("textarea",{required:!0,placeholder:"Content",className:"w-full p-2 border rounded h-32",value:d.content,onChange:t=>x({...d,content:t.target.value})}),e.jsxs("select",{className:"w-full p-2 border rounded",value:d.targetTeam,onChange:t=>x({...d,targetTeam:t.target.value}),children:[e.jsx("option",{value:"All",children:"All Teams"}),e.jsx("option",{value:"Media",children:"Media"}),e.jsx("option",{value:"Welcome",children:"Welcome"})]}),e.jsx("button",{type:"submit",className:"w-full bg-purple-600 text-white py-2 rounded font-bold hover:bg-purple-700",children:"Post"})]})]}),e.jsx("div",{className:"lg:col-span-2 space-y-4",children:R.map(t=>{var s;return e.jsxs("div",{className:"bg-white p-4 rounded-xl shadow flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold",children:t.title}),e.jsx("p",{className:"text-sm text-gray-600 line-clamp-2",children:t.content}),e.jsxs("p",{className:"text-xs text-gray-400 mt-1",children:["To: ",(s=t.targetTeams)==null?void 0:s.join(", ")]})]}),e.jsx("button",{onClick:()=>b(t.id,"volunteer_announcements"),className:"text-red-500 hover:text-red-700",children:e.jsx(T,{})})]},t.id)})})]}),l==="resources"&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-1 bg-white p-6 rounded-xl shadow h-fit",children:[e.jsxs("h3",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[e.jsx(w,{})," Add Resource"]}),e.jsxs("form",{onSubmit:_,className:"space-y-4",children:[e.jsx("input",{required:!0,placeholder:"Title",className:"w-full p-2 border rounded",value:r.title,onChange:t=>c({...r,title:t.target.value})}),e.jsx("input",{required:!0,placeholder:"URL (PDF/Video Link)",className:"w-full p-2 border rounded",value:r.url,onChange:t=>c({...r,url:t.target.value})}),e.jsx("textarea",{placeholder:"Description",className:"w-full p-2 border rounded",value:r.description,onChange:t=>c({...r,description:t.target.value})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("select",{className:"p-2 border rounded",value:r.type,onCh
1ange:t=>c({...r,type:t.target.value}),children:[e.jsx("option",{value:"pdf",children:"PDF"}),e.jsx("option",{value:"video",children:"Video"}),e.jsx("option",{value:"link",children:"Link"})]}),e.jsxs("select",{className:"p-2 border rounded",value:r.category,onChange:t=>c({...r,category:t.target.value}),children:[e.jsx("option",{value:"General",children:"General"}),e.jsx("option",{value:"Training",children:"Training"}),e.jsx("option",{value:"Safety",children:"Safety"})]})]}),e.jsx("button",{type:"submit",className:"w-full bg-purple-600 text-white py-2 rounded font-bold hover:bg-purple-700",children:"Add"})]})]}),e.jsx("div",{className:"lg:col-span-2 bg-white p-6 rounded-xl shadow",children:e.jsx("p",{className:"text-gray-500 text-center",children:"Resource list view coming soon (use Firestore console to manage existing ones)."})})]})]})};export{z 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.