PageSourceSearch

https://buildslot.ai/assets/BookingRequests-OIH_5CNi.js

js buildslot.ai collected 2026-10-05 12:13:34 UTC 12,195 bytes, 1 lines download raw bytes

1import{r as m,m as e,B as u,X as L,u as U,v as V,x as z,y as Q,w as G,k as H,C as K,o as X,D as J,a4 as W,a3 as Y,M as Z}from"./index-CpSGH3si.js";import{C as T,a as E}from"./card--3jAFIY6.js";import{S as k}from"./skeleton-D7CKVNpx.js";import{D as w,a as b,b as M,c as _}from"./dialog-DjQOlXK_.js";import{T as ee}from"./textarea-DnsCXU4p.js";import{L as v}from"./label-mxM2ZpWz.js";import{C as se}from"./calendar-DenphN4x.js";import{S as te,a as ae,b as le,c as re,d as ne}from"./select-DF7dIvp6.js";import{toast as y}from"./index-VOExC7zx.js";import{L as C}from"./loader-circle-CZ4nBqpt.js";import{C as $}from"./calendar-clock-AePWPS20.js";import{a as N}from"./format-DRR4LvZs.js";import ie from"./BookingDetailModal-DwCrTpYX.js";import{C as ce}from"./circle-alert-CRwkKVNs.js";import{m as de}from"./proxy-DFy_m_5J.js";import{I as me}from"./image-DhDYYEir.js";import{U as oe}from"./user-DdcnLghC.js";import{P as xe}from"./phone-B5j7AMqT.js";import{M as pe}from"./mail-32WMcMo6.js";import"./differenceInCalendarDays-CFJcUmo7.js";import"./addMonths-Dda1PylI.js";import"./isSameMonth-BJzWQGR2.js";import"./isBefore-DbbOBjMf.js";import"./isSameDay-CnIkoyse.js";import"./subDays-D-snu2mw.js";import"./addDays-DbcpP0x6.js";import"./setYear-CliJVh3o.js";import"./endOfWeek-CxH9v-Wb.js";import"./startOfMonth-DfJskKPr.js";import"./addWeeks-DCzH6OaQ.js";import"./isAfter-X1VCSQ-p.js";import"./chevron-left-Bt8IqULh.js";import"./index-BdQq_4o_.js";import"./index-Bs3UMnWC.js";import"./index-Cy91vPlr.js";import"./chevron-up-xOaegNmi.js";import"./input-CJQwYE0h.js";import"./circle-check-zYGxtVka.js";import"./pencil-DQhK_CFW.js";import"./circle-check-big-BfTSBK82.js";const q=[{value:"morning",label:"Morning (8AM – 12PM)"},{value:"afternoon",label:"Afternoon (12PM – 5PM)"},{value:"evening",label:"Evening (5PM – 8PM)"}];function ue(c){var r;
1return((r=q.find(t=>t.value===c))==null?void 0:r.label)||c||""}function P(c,r){const t=U(),o=m.useRef(c);o.current=c;const n=m.useRef(r);return n.current=r,V({mutationFn:async({bookingId:a,status:l,patch:d})=>{await z.entities.Booking.update(a,{status:l,...d})},onSuccess:()=>{var a,l;t.invalidateQueries({queryKey:["bookings"]}),(a=o.current)==null||a.call(o),(l=n.current)==null||l.call(n,!1)}})}function he({open:c,onOpenChange:r,booking:t,contractor:o}){var i;const n=m.useRef(t);t!=null&&t.id&&(n.current=t);const a=n.current||{},l=P(()=>{y.success("Booking confirmed!")},r),d=()=>{a.id&&l.mutate({bookingId:a.id,status:"confirmed",patch:{confirmed_date:a.scheduled_date,confirmed_time:a.scheduled_time}})};return e.jsx(w,{open:c,onOpenChange:r,children:e.jsxs(b,{className:"max-w-sm",children:[e.jsx(M,{children:e.jsx(_,{children:"Confirm Appointment"})}),a.id&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-green-50 border border-green-200 rounded-lg p-4 text-sm text-green-800",children:[e.jsx("p",{className:"font-medium",children:(i=a.service_type)==null?void 0:i.replace(/_/g," ")}),e.jsxs("p",{className:"text-green-700 mt-1",children:[N(new Date(a.scheduled_date),"EEEE, MMMM d, yyyy")," · ",ue(a.scheduled_time)]}),e.jsx("p",{className:"text-green-700",children:a.customer_name})]}),e.jsxs("p",{className:"text-sm text-slate-600",children:["Confirming will notify ",e.jsx("strong",{children:a.customer_name})," via email and mark this appointment as confirmed."]}),e.jsxs(u,{className:"w-full bg-green-600 hover:bg-green-700",onClick:d,disabled:l.isPending,children:[l.isPending?e.jsx(C,{className:"w-4 h-4 mr-2 animate-spin"}):null,"Confirm Appointment"]})]})]})})}function fe({open:c,onOpenChange:r,booking:t,contractor:o}){const n=m.useRef(t);t!=null&&t.id&&(n.current=t);const a=n.current||{},[l,d]=m.useState(null),[i,h]=m.useState(""),x=P(()=>{d(null),h(""),y.success("New time proposed and customer notified!")},r),g=()=>{!l||!i||!a.id||x.mutate({bookingId:a.id,status:"rescheduled",patch:{proposed_date:N(l,"yyyy-MM-dd"),proposed_time:i}})};return e.jsx(w,{open:c,onOpenChange:r,children:e.jsxs(b,{className:"max-w-md",children:[e.jsx(M,{children:e.jsx(_,{children:"Propose New Time"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:"New date"}),e.jsx(se,{mode:"single",selected:l,onSelect:d,disabled:p=>p<new Date,className:"rounded-md border w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:"New time slot"}),e.jsxs(te,{value:i,onValueChange:h,children:[e.jsx(ae,{children:e.jsx(le,{placeholder:"Select a time"})}),e.jsx(re,{children:q.map(p=>e.jsx(ne,{value:p.value,children:p.label},p.value))})]})]}),e.jsxs(u,{className:"w-full bg-blue-600 hover:bg-blue-700",onClick:g,disabled:!l||!i||x.isPending,children:[x.isPending?e.jsx(C,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx($,{className:"w-4 h-4 mr-2"}),"Send Proposed Time"]})]})]})})}function je({open:c,onOpenChange:r,booking:t,contractor:o}){const n=m.useRef(t);t!=null&&t.id&&(n.current=t);const a=n.current||{},[l,d]=m.useState(""),i=P(()=>{d(""),y.success("Booking declined.")},r),h=()=>{!l.trim()||!a.id||i.mutate({bookingId:a.id,status:"cancelled",patch:{decline_reason:l}})};return e.jsx(w,{open:c,onOpenChange:r,children:e.jsxs(b,{className:"max-w-sm",children:[e.jsx(M,{children:e.jsx(_,{children:"Decline Booking"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(v,{children:["Reason for declining ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(ee,{value:l,onChange:x=>d(x.target.value),placeholder:"I'm fully booked during that period...",rows:4})]}),e.jsxs(u,{variant:"destructive",className:"w-full",onClick:h,disabled:!l.trim()||i.isPending,children:[i.isPending?e.jsx(C,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(L,{className:"w-4 h-4 mr-2"}),"Decline Booking"]})]})]})})}const A={morning:"Morning (8AM–12PM)",morning_late:"Late Morning (10AM–12PM)",afternoon:"Afternoon (12PM–5PM)",afternoon_late:"Afternoon (12PM–5PM)",evening:"Evening (5PM–8PM)",flexible:"Flexible"},R={pending:{label:"Pending",class:"bg-amber-100 text-amber-700 border-amber-200"},confirmed:{label:"Confirmed",class:"bg-green-100 text-green-700 border-green-200"},rescheduled:{label:"Rescheduled",class:"bg-blue-100 text-blue-700 border-blue-200"},cancelled:{label:"Declined",class:"bg-red-100 text-red-700 border-red-200"},completed:{label:"Completed",class:"bg-slate-100 text-slate-600 border-slate-200"}},I={pending:0,confirmed:1,rescheduled:2,completed:3,cancelled:4},ge={pending:"border-l-amber-500",confirmed:"border-l-green-500",rescheduled:"border-l-blue-500",cancelled:"border-l-red-400",completed:"border-l-slate-300"};function rs({bookings:c,isLoading:r,contractor:t}){const o=Q(),[n,a]=m.useState(null),[l,d]=m.useState(null),[i,h]=m.useState(null),[x,g]=m.useState(null);if(r)return e.jsx("div",{className:"space-y-4",children:[...Array(2)].map((s,f)=>
1e.jsx(k,{className:"h-64 rounded-xl"},f))});const p=(c||[]).slice().sort((s,f)=>{const j=(I[s.status]??99)-(I[f.status]??99);return j!==0?j:new Date(f.created_date)-new Date(s.created_date)});return p.length===0?e.jsx(T,{children:e.jsxs(E,{className:"py-12 text-center",children:[e.jsx(ce,{className:"w-12 h-12 text-slate-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-slate-900 mb-2",children:"No booking requests yet"}),e.jsx("p",{className:"text-slate-500",children:"New booking requests will appear here."})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-4",children:p.map((s,f)=>{var S,B;const j=R[s.status]||R.pending,D=s.status==="pending";return e.jsx(de.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:f*.05},children:e.jsx(T,{className:`border-l-4 ${ge[s.status]||"border-l-slate-300"}`,children:e.jsx(E,{className:"p-6",children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-start justify-between gap-6",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-900",children:(S=s.service_type)==null?void 0:S.replace(/_/g," ")}),e.jsx(G,{className:`border ${j.class}`,children:j.label}),e.jsx("span",{className:"text-sm text-slate-400",children:H(new Date(s.created_date),{addSuffix:!0})})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-3 mb-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(K,{className:"w-4 h-4 text-slate-400 shrink-0"}),N(new Date(s.scheduled_date),"EEEE, MMMM d, yyyy")]}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(X,{className:"w-4 h-4 text-slate-400 shrink-0"}),A[s.scheduled_time]||s.scheduled_time]}),e.jsxs("div",{className:"flex items-center gap-2 text-slate-600",children:[e.jsx(J,{className:"w-4 h-4 text-slate-400 shrink-0"}),s.job_location||"Location not specified"]})]}),s.status==="rescheduled"&&s.proposed_date&&e.jsxs("div",{className:"mb-3 px-3 py-2 bg-blue-50 border border-blue-200 rounded-lg text-sm text-blue-800",children:[e.jsx("span",{className:"font-medium",children:"Proposed new time: "}),N(new Date(s.proposed_date),"MMM d, yyyy"),s.proposed_time&&` · ${A[s.proposed_time]||s.proposed_time}`]}),s.status==="cancelled"&&s.decline_reason&&e.jsxs("div",{className:"mb-3 px-3 py-2 bg-red-50 border border-red-200 rounded-lg text-sm text-red-700",children:[e.jsx("span",{className:"font-medium",children:"Decline reason: "}),s.decline_reason]}),s.job_description&&e.jsx("div",{className:"mb-4 p-3 bg-slate-50 rounded-lg text-sm text-slate-700",children:s.job_description}),((B=s.images)==null?void 0:B.length)>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("p",{className:"text-xs text-slate-500 uppercase tracking-wide mb-2 flex items-center gap-1",children:[e.jsx(me,{className:"w-3 h-3"})," Photos (",s.images.length,")"]}),e.jsx("div",{className:"flex gap-2 overflow-x-auto",children:s.images.map((O,F)=>e.jsx("img",{src:O,alt:"",className:"w-20 h-20 object-cover rounded-lg shrink-0"},F))})]}),e.jsxs("div",{className:"pt-4 border-t border-slate-100",children:[e.jsx("p",{className:"text-xs text-slate-400 uppercase tracking-wide mb-2",children:"Customer"}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-700",children:[e.jsx(oe,{className:"w-4 h-4 text-slate-400"})," ",s.customer_name]}),s.customer_phone&&e.jsxs("a",{href:`tel:${s.customer_phone}`,className:"flex items-center gap-2 text-slate-700 hover:text-green-600",children:[e.jsx(xe,{className:"w-4 h-4 text-slate-400"})," ",s.customer_phone]}),s.customer_email&&e.jsxs("a",{href:`mailto:${s.customer_email}`,className:"flex items-center gap-2 text-slate-700 hover:text-green-600",children:[e.jsx(pe,{className:"w-4 h-4 text-slate-400"})," ",s.customer_email]})]})]})]}),!D&&e.jsx("div",{className:"flex lg:flex-col gap-2 lg:min-w-[140px]",children:e.jsxs(u,{variant:"outline",size:"sm",className:"flex-1",onClick:()=>g(s),children:["View Details ",e.jsx(W,{className:"w-4 h-4 ml-1"})]})}),D&&e.jsxs("div",{className:"flex lg:flex-col gap-2 lg:min-w-[168px]",children:[e.jsxs(u,{className:"flex-1 bg-green-600 hover:bg-green-700 text-white",onClick:()=>a(s),children:[e.jsx(Y,{className:"w-4 h-4 mr-1.5"}),"Confirm Appointment"]}),e.jsxs(u,{variant:"outline",className:"flex-1 border-blue-300 text-blue-700 hover:bg-blue-50",onClick:()=>d(s),children:[e.jsx($,{className:"w-4 h-4 mr-1.5"}),"Propose New Time"]}),e.jsxs(u,{variant:"outline",className:"flex-1 border-red-300 text-red-600 hover:bg-red-50",onClick:()=>h(s),children:[e.jsx(L,{className:"w-4 h-4 mr-1.5"}),"Decline"]}),s.conversation_id&&e.jsxs(u,{variant:"ghost",size:"sm",className:"flex-1 text-slate-500",onClick:()=>o(`/Messages?conversation=${s.conversation_id}`),children:[e.jsx(Z,{className:"w-4 h-4 mr-1.5"})," Message"]})]})]})})})},s.id)})}),e.jsx(he,{open:!!n,onOpenChange:s=>{s||a(null)},booking:n||{},contractor:t}),e.jsx(fe,{open:!!l,onOpenChange:s=>{s||d(null)},booking:l||{},contractor:t}),e.jsx(je,{open:!!i,onOpenChange:s=>{s||h(null)},booking:i||{},contractor:t}
1),e.jsx(ie,{booking:x,open:!!x,onOpenChange:s=>!s&&g(null)})]})}export{rs 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.