PageSourceSearch

https://www.faithassembly.org.uk/assets/AppointmentManager-CPwBMrq7.js

js faithassembly.org.uk collected 2026-10-03 19:00:40 UTC 13,230 bytes, 1 lines download raw bytes

1import{r as a,j as e,af as n}from"./vendor-BFIOfVip.js";import{d as j}from"./index-BWk9MH7v.js";import{b as L,F as T,m as P,G as B,J as q,l as I,T as R,H as U,N as $,w as F,M as z}from"./vendor-firebase-IWWIlHC2.js";import{dF as G,Y as E,V as O,x as V,bM as D,ae as W,b2 as Y,bL as H,ax as J}from"./vendor-icons-BjlO8Ivt.js";import"./vendor-motion-C4-LgF0B.js";const _=({isOpen:h,onClose:p,onSuccess:b})=>{const o=L().currentUser,[g,f]=a.useState(!1),[y,A]=a.useState([]),[i,d]=a.useState(""),[m,N]=a.useState(""),[x,t]=a.useState(""),[r,l]=a.useState(""),[c,v]=a.useState("");a.useEffect(()=>{h&&(async()=>{try{const u=T(P(j,"users"),B("role","in",["admin","super_admin"])),S=(await q(u)).docs.map(C=>({uid:C.data().uid,displayName:C.data().displayName||"Unknown Staff"}));A(S)}catch(u){console.error("Error fetching pastors",u)}})()},[h]);const k=async s=>{var u;if(s.preventDefault(),!o){n.error("You must be logged in to book.");return}if(!i||!m||!x||!r){n.error("Please fill in all required fields.");return}f(!0);try{const w=((u=y.find(S=>S.uid===i))==null?void 0:u.displayName)||"Unknown";await I(P(j,"appointments"),{pastorId:i,pastorName:w,memberId:o.uid,memberName:o.displayName||"Anonymous",memberEmail:o.email,date:m,timeSlot:x,reason:r,notes:c,status:"pending",createdAt:R.now()}),n.success("Appointment Request Sent!"),b==null||b(),p(),d(""),N(""),t(""),l(""),v("")}catch(w){console.error(w),n.error("Failed to book appointment.")}finally{f(!1)}};return h?e.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto","aria-labelledby":"modal-title",role:"dialog","aria-modal":"true",children:e.jsxs("div",{className:"flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[e.jsx("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity",onClick:p,"aria-hidden":"true"}),e.jsx("span",{className:"hidden sm:inline-block sm:align-middle sm:h-screen","aria-hidden":"true",children:"​"}),e.jsxs("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg w-full",children:[e.jsx("div",{className:"bg-blue-700 px-4 py-6 sm:px-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:"bg-white/20 p-2 rounded-lg",children:e.jsx(G,{className:"text-white text-2xl"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg leading-6 font-bold text-white",id:"modal-title",children:"Pastoral Appointment"}),e.jsx("p",{className:"text-blue-100 text-sm",children:"Schedule a time to speak with our pastoral team."})]})]}),e.jsx("button",{onClick:p,className:"text-white/70 hover:text-white transition",children:e.jsx(E,{})})]})}),e.jsx("div",{className:"px-4 pt-5 pb-4 sm:p-6 sm:pb-4",children:e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Select Pastor"}),e.jsxs("select",{value:i,onChange:s=>d(s.target.value),className:"block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm rounded-md border",required:!0,children:[e.jsx("option",{value:"",children:"Choose a pastor..."}),y.map(s=>e.jsxs("option",{value:s.uid,children:["Pastor ",s.displayName]},s.uid))]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Date"}),e.jsxs("div",{className:"relative rounded-md shadow-sm",children:[e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:e.jsx(O,{className:"text-gray-400"})}),e.jsx("input",{type:"date",value:m,onChange:s=>N(s.target.value),className:"focus:ring-blue-500 focus:border-blue-500 block w-full sm:text-sm border-gray-300 rounded-md border py-2 pl-3",required:!0,min:new Date().toISOString().split("T")[0]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Time Slot"}),e.jsxs("div",{className:"relative rounded-md shadow-sm",children:[e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:e.jsx(V,{className:"text-gray-400"})}),e.jsxs("select",{value:x,onChange:s=>t(s.target.value),className:"focus:ring-blue-500 focus:border-blue-500 block w-full sm:text-sm border-gray-300 rounded-md border py-2 pl-3",required:!0,children:[e.jsx("option",{value:"",children:"Select a time"}),e.jsx("option",{value:"09:00 AM - 09:30 AM",children:"09:00 AM - 09:30 AM"}),e.jsx("option",{value:"09:30 AM - 10:00 AM",children:"09:30 AM - 10:00 AM"}),e.jsx("option",{value:"10:00 AM - 10:30 AM",children:"10:00 AM - 10:30 AM"}),e.jsx("option",{value:"10:30 AM - 11:00 AM",children:"10:30 AM - 11:00 AM"}),e.jsx("option",{value:"11:00 AM - 11:30 AM",children:"11:00 AM - 11:30 AM"}),e.jsx("option",{value:"11:30 AM - 12:00 PM",children:"11:30 AM - 12:00 PM"}),e.jsx("option",{value:"02:00 PM - 02:30 PM",children:"02:00 PM - 02:30 PM"}),e.jsx("option",{value:"02:30 PM - 03:00 PM",children:"02:30 PM - 03:00 PM"}),e.jsx("option",{value:"03:00 PM - 03:30 PM",children:"03:00 PM - 03:30 PM"}),e.jsx("option",{value:"03:30 PM - 04:00 PM",children:"03:30 PM - 04:00 PM"})]})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Reason for Visit"}),e.jsxs("select",{value:r,onChange:s=>l(s.target.value),className:"block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm rounded-md border",required:!0,children:[e.jsx("option",{value:"",children:"Select a reason"}),e.jsx("option",{value:"Counseling",children:"Counseling"}),e.jsx("option",{value:"Wedding",children:"Wedding Inquiry"}),e.jsx("option",{value:"Dedication",children:"Child Dedication"}),e.jsx("option",{value:"General",children:"General Inquiry"}),e.jsx("option",{value:"Other",children:"Other"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Additional Notes"}),e.jsx("textarea",{rows:4,value:c,onChange:s=>v(s.target.value),className:"shadow-sm focus:ring-blue-500 focus:border-blue-500 block w-full sm:text-sm border-gray-300 rounded-md border p-2",placeholder:"Please provide any details that will help us prepare..."})]}),e.jsx("div",{className:"mt-5 sm:mt-6",children:e.jsx("button",{type:"submit",disabled:g,className:`w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-3 text-base font-medium text-white sm:text-sm ${g?"bg-blue-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"}`,children:g?"Submitting...":"Book Appointment"})})]})})]})]})}):null},te=()=>
1{const[h,p]=a.useState([]),[b,M]=a.useState(!0),[o,g]=a.useState("all"),[f,y]=a.useState(""),[A,i]=a.useState(!1),d=async()=>{M(!0);try{const t=T(P(j,"appointments"),U("createdAt","desc")),l=(await q(t)).docs.map(c=>({id:c.id,...c.data()}));p(l)}catch(t){console.error("Error fetching appointments:",t),n.error("Failed to load appointments")}finally{M(!1)}};a.useEffect(()=>{d()},[]);const m=async(t,r)=>{if(confirm(`Are you sure you want to change status to ${r}?`))try{await $(F(j,"appointments",t),{status:r}),n.success(`Appointment ${r}`),d()}catch(l){console.error("Error updating status:",l),n.error("Failed to update status")}},N=async t=>{if(confirm("Are you sure you want to delete this appointment? This cannot be undone."))try{await z(F(j,"appointments",t)),n.success("Appointment deleted"),d()}catch(r){console.error("Error deleting appointment:",r),n.error("Failed to delete appointment")}},x=h.filter(t=>{const r=o==="all"||t.status===o,l=f.toLowerCase(),c=(t.memberName||"").toLowerCase(),v=(t.pastorName||"").toLowerCase(),k=(t.reason||"").toLowerCase(),s=c.includes(l)||v.includes(l)||k.includes(l);return r&&s});return e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-center mb-6 gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-800 flex items-center gap-2",children:[e.jsx(D,{className:"text-blue-600"})," Appointment Management"]}),e.jsx("p",{className:"text-gray-500 text-sm mt-1",children:"Manage pastoral appointments and counseling sessions."})]}),e.jsxs("button",{onClick:()=>i(!0),className:"bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 flex items-center gap-2 transition shadow-sm",children:[e.jsx(W,{})," Book Appointment"]})]}),e.jsxs("div",{className:"bg-white p-4 rounded-xl shadow-sm border border-gray-100 mb-6 flex flex-col md:flex-row gap-4 justify-between items-center",children:[e.jsx("div",{className:"flex gap-2 overflow-x-auto w-full md:w-auto pb-2 md:pb-0",children:["all","pending","confirmed","cancelled","completed"].map(t=>e.jsx("button",{onClick:()=>g(t),className:`px-4 py-2 rounded-full text-sm font-medium capitalize transition-colors ${o===t?"bg-blue-100 text-blue-700":"bg-gray-50 text-gray-600 hover:bg-gray-100"}`,children:t},t))}),e.jsxs("div",{className:"relative w-full md:w-64",children:[e.jsx(Y,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),e.jsx("input",{type:"text",placeholder:"Search name, pastor...",value:f,onChange:t=>y(t.target.value),className:"w-full pl-10 pr-4 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),e.jsx("div",{className:"bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden",children:b?e.jsx("div",{className:"p-8 text-center text-gray-500",children:"Loading appointments..."}):x.length===0?e.jsxs("div",{className:"p-12 text-center flex flex-col items-center justify-center",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-50 rounded-full flex items-center justify-center mb-4 text-gray-300 text-2xl",children:e.jsx(D,{})}),e.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"No appointments found"}),e.jsx("p",{className:"text-gray-500 text-sm mt-1",children:"Try adjusting your filters or search terms."})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{className:"bg-gray-50 text-gray-600 font-medium text-sm border-b border-gray-200",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-4",children:"Member"}),e.jsx("th",{className:"px-6 py-4",children:"Pastor"}),e.jsx("th",{className:"px-6 py-4",children:"Date & Time"}),e.jsx("th",{className:"px-6 py-4",children:"Reason"}),e.jsx("th",{className:"px-6 py-4",children:"Status"}),e.jsx("th",{className:"px-6 py-4 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-100",children:x.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50 transition-colors",children:[e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("div",{className:"font-medium text-gray-900",children:t.memberName}),e.jsx("div",{className:"text-xs text-gray-500",children:t.memberEmail})]}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-700",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 text-xs font-bold",children:t.pastorName?t.pastorName.charAt(0):"?"}),t.pastorName]})}),e.jsxs("td",{className:"px-6 py-4 text-sm text-gray-700",children:[e.jsx("div",{children:t.date}),e.jsx("div",{className:"text-xs text-gray-500",children:t.timeSlot})]}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-purple-50 text-purple-700 border border-purple-100",children:t.reason}),t.notes&&e.jsx("p",{className:"text-xs text-gray-400 mt-1 truncate max-w-[150px]",title:t.notes,children:t.notes})]}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium capitalize border ${t.status==="confirmed"?"bg-green-50 text-green-700 border-green-100":t.status==="pending"?"bg-yellow-50 text-yellow-700 border-yellow-100":t.status==="cancelled"?"bg-red-50 text-red-700 border-red-100":"bg-gray-50 text-gray-700 border-gray-100"}`,children:t.status})}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[t.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>m(t.id,"confirmed"),title:"Confirm",className:"p-1.5 text-green-600 hover:bg-green-50 rounded transition",children:e.jsx(H,{})}),e.jsx("button",{onClick:()=>m(t.id,"cancelled"),title:"Cancel",className:"p-1.5 text-red-600 hover:bg-red-50 rounded transition",children:e.jsx(E,{})})]}),e.jsx("button",{onClick:()=>N(t.id),title:"Delete",className:"p-1.5 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded transition",children:e.jsx(J,{})})]})})]},t.id))})]})})}),e.jsx(_,{isOpen:A,onClose:()=>i(!1),onSuccess:d})]})};export{te 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.