1import{K as _,w as D,x as K,c as y,bU as m,b_ as v,r as o,j as e,ay as R,aP as G,a4 as I,I as p,ao as W,B as n,a1 as M}from"./index-BBYsJQph.js";import{c as B,L as H}from"./london-time-BTshG-0l.js";import{C as Q}from"./ClientProfileLink-BQpicN55.js";import{C as $}from"./circle-x-Cqd-d9TQ.js";import"./index-DRp-vBl_.js";const V=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function J(){var L,F,O,P;const C=_(),d=D(),l=K(!0),h=y({queryKey:["/api/admin/guest-sessions/settings"],queryFn:()=>m("/api/admin/guest-sessions/settings"),enabled:((L=d.data)==null?void 0:L.enabled)===!0}),S=y({queryKey:["/api/admin/guest-sessions/windows"],queryFn:()=>m("/api/admin/guest-sessions/windows"),enabled:((F=d.data)==null?void 0:F.enabled)===!0}),k=y({queryKey:["/api/admin/guest-sessions/occurrences"],queryFn:()=>m("/api/admin/guest-sessions/occurrences"),enabled:((O=d.data)==null?void 0:O.enabled)===!0}),g=v("/api/admin/guest-sessions/settings","PATCH",["/api/admin/guest-sessions/settings"]),f=v("/api/admin/guest-sessions/windows","POST",["/api/admin/guest-sessions/windows"]),[b,A]=o.useState({}),[i,N]=o.useState({weekday:1,startTime:"",endTime:"",enabled:!0}),[t,u]=o.useState(null),[r,j]=o.useState(""),w=v(t?`/api/admin/guest-sessions/applications/${t.id}`:"/api/admin/guest-sessions/applications/0","PATCH");if(o.useEffect(()=>{h.data&&A(h.data)},[h.data]),o.useEffect(()=>{if(!t||!l.data)return;const s=l.data.find(a=>a.id===t.id);s&&(u(s),j(s.assessmentNotes||""))},[l.data,t==null?void 0:t.id]),d.isLoading)return e.jsx("div",{className:"min-h-screen bg-[#faf7f2]"});if(d.isError||!((P=d.data)!=null&&P.enabled))return e.jsx(R,{to:"/admin"});const T=l.data||[],E=S.data||[],q=k.data||[],c=s=>{w.mutate(s)};return e.jsxs("div",{className:"mx-auto min-h-[100dvh] max-w-7xl bg-[#faf7f2] px-4 py-8 text-[#4A3C3A] sm:px-8",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs uppercase tracking-[.2em] text-[#a05a3f]",children:"Operations"}),e.jsx("h1",{className:"mt-2 font-lulo-clean text-4xl uppercase",children:"Guest Sessions"}),e.jsx("p",{className:"mt-2 text-[#756661]",children:"Review applications, assessments and upcoming qualified sessions."})]}),e.jsxs("div",{className:"rounded-2xl border border-[#eadfd4] bg-white px-4 py-3 text-sm",children:[e.jsx(G,{className:"mr-2 inline h-4 w-4 text-[#a05a3f]"}),"Feature enabled"]})]}),e.jsxs("div",{className:"mt-8 grid gap-6 lg:grid-cols-[1fr_380px]",children:[e.jsxs("section",{className:"space-y-3",children:[l.isLoading?[1,2,3].map(s=>e.jsx("div",{className:"h-24 animate-pulse rounded-2xl bg-[#eee3d8]"},s)):T.map(s=>e.jsxs("button",{onClick:()=>{u(s),j(s.assessmentNotes||"")},className:`w-full rounded-2xl border bg-white p-5 text-left transition-colors ${(t==null?void 0:t.id)===s.id?"border-[#cd8161]":"border-[#eadfd4] hover:border-[#cd8161]"}`,children:[e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:s.dogName||"Dog application"}),e.jsxs("p",{className:"text-sm text-[#756661]",children:[s.ownerName||"Owner"," ·"," ",s.dogBreed||""]})]}),e.jsx("span",{className:"h-fit rounded-full bg-[#f3ece4] px-3 py-1 text-xs font-semibold",children:s.status.replaceAll("_"," ")})]}),s.assessmentScheduledAt&&e.jsxs("p",{className:"mt-3 text-sm text-[#756661]",children:[e.jsx(I,{className:"mr-2 inline h-4 w-4 text-[#a05a3f]"}),new Date(s.assessmentScheduledAt).toLocaleString("en-GB")]})]},s.id)),!l.isLoading&&T.length===0&&e.jsx("div",{className:"rounded-3xl border border-dashed border-[#d9c8b8] p-14 text-center text-[#756661]",children:"No Guest Sessions applications yet."})]}),t?e.jsxs("aside",{className:"sticky top-6 h-fit rounded-3xl border border-[#eadfd4] bg-white p-6",children:[e.jsx("h2",{className:"text-xl font-semibold",children:t.dogName}),e.jsxs("p",{className:"mt-1 text-sm text-[#756661]",children:["Application #",t.id," · ",t.status.replaceAll("_"," ")]}),e.jsx(Q,{dogId:t.dogId,tab:"owners",className:"mt-2 inline-flex min-h-9 items-center text-sm font-semibold text-[#a05a3f] underline underline-offset-4","data-testid":"link-manage-guest-session-client",children:"Manage client"}),e.jsx("label",{className:"mb-2 mt-6 block text-xs uppercase tracking-wider",children:"Assessment date and time"}),e.jsx(p,{type:"datetime-local",value:t.assessmentScheduledAt?W(t.assessmentScheduledAt,H,"yyyy-MM-dd'T'HH:mm"):"",onCh
1ange:s=>{const[a,x]=s.target.value.split("T");u({...t,assessmentScheduledAt:a&&x?B(a,x):""})}}),e.jsx("label",{className:"mb-2 mt-5 block text-xs uppercase tracking-wider",children:"Assessment notes"}),e.jsx("textarea",{className:"min-h-28 w-full rounded-xl border border-[#eadfd4] p-3",value:r,onChange:s=>j(s.target.value),placeholder:"Behaviour, confidence and handling notes"}),e.jsxs("label",{className:"mt-4 flex items-center gap-2 text-sm",children:[e.jsx("input",{type:"checkbox",checked:!!t.adultNeuterVisuallyConfirmed,onChange:s=>u({...t,adultNeuterVisuallyConfirmed:s.target.checked})}),"Adult dog neuter visually confirmed"]}),e.jsxs("div",{className:"mt-5 grid grid-cols-2 gap-2",children:[t.status==="pending"&&e.jsx(n,{disabled:!t.assessmentScheduledAt,onClick:()=>c({status:"assessment_scheduled",assessmentScheduledAt:t.assessmentScheduledAt,assessmentNotes:r}),variant:"outline",children:"Schedule"}),e.jsx(n,{onClick:()=>c({assessmentNotes:r,adultNeuterVisuallyConfirmed:!!t.adultNeuterVisuallyConfirmed}),variant:"outline",children:"Save notes"}),t.status==="assessment_scheduled"&&e.jsx(n,{onClick:()=>c({status:"assessment_completed",assessmentCompletedAt:new Date().toISOString(),assessmentNotes:r,adultNeuterVisuallyConfirmed:!!t.adultNeuterVisuallyConfirmed}),variant:"outline",children:"Mark complete"}),t.status==="assessment_completed"&&e.jsxs(n,{onClick:()=>c({status:"approved",assessmentNotes:r,adultNeuterVisuallyConfirmed:!!t.adultNeuterVisuallyConfirmed}),className:"bg-[#cd8161] text-white hover:bg-[#b5694d]",children:[e.jsx(M,{className:"mr-1 h-4 w-4"}),"Approve"]}),!["approved","declined"].includes(t.status)&&e.jsxs(n,{onClick:()=>c({status:"declined",assessmentNotes:r}),variant:"outline",className:"text-red-700",children:[e.jsx($,{className:"mr-1 h-4 w-4"}),"Decline"]})]}),w.isError&&e.jsx("p",{className:"mt-4 text-sm text-red-700",children:w.error.message})]}):e.jsx("div",{className:"h-fit rounded-3xl bg-[#f3ece4] p-7 text-[#756661]",children:"Select an application to manage its assessment and decision."})]}),e.jsxs("section",{className:"mt-8 rounded-3xl border border-[#eadfd4] bg-white p-6",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Session windows"}),e.jsx("p",{className:"mt-1 text-sm text-[#756661]",children:"Windows use London time and cannot overlap standard Pet-a-Pooch."}),e.jsxs("div",{className:"mt-4 grid gap-2 sm:grid-cols-4",children:[e.jsx("select",{"aria-label":"Weekday",value:i.weekday,onChange:s=>N({...i,weekday:Number(s.target.value)}),className:"rounded-md border border-input bg-background px-3",children:V.map((s,a)=>e.jsx("option",{value:a,children:s},s))}),e.jsx(p,{"aria-label":"Start time",type:"time",value:i.startTime,onChange:s=>N({...i,startTime:s.target.value})}),e.jsx(p,{"aria-label":"End time",type:"time",value:i.endTime,onChange:s=>N({...i,endTime:s.target.value})}),e.jsx(n,{onClick:()=>f.mutate(i),className:"bg-[#cd8161] text-white hover:bg-[#b5694d]",children:"Add window"})]}),e.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[E.map(s=>e.jsxs("span",{className:"inline-flex items-center gap-2 rounded-full bg-[#f3ece4] px-3 py-1.5 text-sm",children:[V[s.weekday]," ",s.startTime,"â",s.endTime,e.jsx("button",{className:"text-red-700",onClick:async()=>{await m(`/api/admin/guest-sessions/windows/${s.id}`,"DELETE"),C.invalidateQueries({queryKey:["/api/admin/guest-sessions/windows"]})},children:"Remove"})]},s.id)),!S.isLoading&&E.length===0&&e.jsx("span",{className:"text-sm text-[#756661]",children:"No windows configured."})]}),f.isError&&e.jsx("p",{className:"mt-3 text-sm text-red-700",children:f.error.message})]}),e.jsxs("section",{className:"mt-5 rounded-3xl border border-[#eadfd4] bg-white p-6",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Availability settings"}),e.jsx("div",{className:"mt-4 grid gap-3 sm:grid-cols-4",children:[["ownerThreshold","Owner threshold"],["cutoffHours","Cutoff hours"],["ownerCapacity","Owner capacity"],["petterCapacity","Visitor capacity"]].map(([s,a])=>e.jsxs("label",{className:"text-xs uppercase tracking-wider",children:[a,e.jsx(p,{className:"mt-2",min:1,type:"number",value:b[s]??"",onChange:x=>A({...b,[s]:Number(x.target.value)})})]},s))}),e.jsx(n,{onClick:()=>g.mutate(b),className:"mt-5 bg-[#cd8161] text-white hover:bg-[#b5694d]",children:"Save settings"}),g.isError&&e.jsx("p",{className:"mt-3 text-sm text-red-700",children:g.error.message})]}),e.jsxs("section",{className:"mt-5 rounded-3xl border border-[#eadfd4] bg-white p-6",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Upcoming sessions"}),e.jsxs("div",{className:"mt-4 space-y-2",children:[q.map(s=>e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 roun
1ded-2xl bg-[#f3ece4] p-4",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[s.date," · ",s.time,"â",s.endTime]}),e.jsxs("p",{className:"mt-1 text-sm text-[#756661]",children:[s.ownerCount," approved dogs · ",s.petterCount," ","visitors · ",s.status]})]}),s.status==="open"&&e.jsx(n,{variant:"outline",className:"text-red-700",onClick:async()=>{await m(`/api/admin/guest-sessions/occurrences/${s.id}/cancel`,"POST"),C.invalidateQueries({queryKey:["/api/admin/guest-sessions/occurrences"]})},children:"Cancel session"})]},s.id)),!k.isLoading&&q.length===0&&e.jsx("p",{className:"text-sm text-[#756661]",children:"No upcoming sessions yet."})]})]})]})}export{J 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.