PageSourceSearch

https://tasksprout.ai/assets/Visits-CPIclCSK.js

js tasksprout.ai collected 2026-10-05 14:45:45 UTC 24,574 bytes, 1 lines download raw bytes

1import{r as a,j as s}from"./ui-DZy4HMEw.js";import{u as qs,t as o,a as l,Y as zs,B as n,I as y,C as Is,i as Gs,j as Hs,U as _s,a8 as Xs,a9 as Ys,aa as Js,ab as b,a4 as Z,ao as E,b as Ks,aq as $,al as Ws,ar as Zs,$ as ss,a0 as es,a1 as ts,a2 as as,d,a6 as O,a3 as se}from"./index-DqpwcGVt.js";import{T as is}from"./textarea-LY0IgGCR.js";import{B as P}from"./badge-DZCpMzYg.js";import{S as L,a as A,b as U,c as R,d as j}from"./select-BDDRXW8D.js";import{C as ee}from"./checkbox-BgzbOflm.js";import{C as te}from"./ConfirmDialog-B0LybP3r.js";import{P as ws}from"./plus-DPzgrrnP.js";import{S as ae}from"./search-BGcx1ZA-.js";import{E as ie}from"./ellipsis-vertical-sftlDB3m.js";import{C as ys}from"./circle-x-Bo97CQu_.js";import{P as ce}from"./pencil-BAoQBp88.js";import{T as le}from"./trash-2-Cb74scM_.js";import{C as ne}from"./calendar-days-CsdVzkZ8.js";import{E as re}from"./external-link-D8Ahy1Ye.js";import"./charts-B0yh2avS.js";import"./stripe-DwV5RDXX.js";const bs=["scheduled","in-progress","completed","cancelled","no-show"],oe={scheduled:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200","in-progress":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200",completed:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",cancelled:"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200","no-show":"bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200"};function Se(){const[,cs]=qs(),[Ss,B]=a.useState(!1),[Ds,h]=a.useState(!1),[ks,S]=a.useState(!1),[D,Q]=a.useState(null),[x,f]=a.useState(null),[p,q]=a.useState(null),[z,G]=a.useState(null),[C,Ts]=a.useState(""),[N,Ms]=a.useState("all"),[c,g]=a.useState({contractId:"",clientId:"",visitDate:"",status:"scheduled",notes:"",duration:""}),[ls,ns]=a.useState(""),[rs,os]=a.useState(""),[m,V]=a.useState([]),[ds,I]=a.useState(null),[Fs,k]=a.useState(null),[T,M]=a.useState(""),[H,xs]=a.useState("cancelled"),[ps,gs]=a.useState(!1),[w,F]=a.use
1State(null),r=o.useUtils(),{data:_=[],isLoading:Es}=o.visits.list.useQuery(),{data:X=[]}=o.clientContracts.list.useQuery(),{data:ms=[]}=o.clients.list.useQuery(),v=a.useMemo(()=>{const e={};return ms.forEach(t=>{e[t.id]=t.name}),e},[ms]),u=a.useMemo(()=>{const e={};return X.forEach(t=>{e[t.id]=t}),e},[X]),us=u[Number(c.contractId)],hs=a.useMemo(()=>{let e=_;if(N!=="all"&&(e=e.filter(t=>t.status===N)),C){const t=C.toLowerCase();e=e.filter(i=>v[i.clientId]?.toLowerCase().includes(t)||u[i.contractId]?.name?.toLowerCase().includes(t)||i.notes?.toLowerCase().includes(t))}return e},[_,C,N,v,u]),Vs=o.visits.create.useMutation({onSuccess:()=>{r.visits.list.invalidate(),l.success("Visit created"),J()},onError:e=>l.error(`Failed to create visit: ${e.message}`)}),vs=o.visits.update.useMutation({onSuccess:()=>{r.visits.list.invalidate(),l.success("Visit updated"),J()},onError:e=>l.error(`Failed to update visit: ${e.message}`)}),js=o.visits.complete.useMutation({onSuccess:e=>{r.visits.list.invalidate(),r.invoices.list.invalidate(),e.invoiceId?(I(e.invoiceId),k(e.invoiceTotal||null),r.clientContracts.invoiceOccurrences.invalidate(),l.success("Visit completed — invoice available")):(l.success("Visit completed"),h(!1),f(null))},onError:e=>l.error(`Failed to complete visit: ${e.message}`)}),fs=o.visits.cancelVisit.useMutation({onSuccess:e=>{r.visits.list.invalidate(),e.pushedInvoiceId?l.success(`Visit cancelled. Invoice due date pushed to ${new Date(e.newDueDate).toLocaleDateString()}`):l.success("Visit cancelled"),S(!1),q(null),M("")},onError:e=>l.error(`Failed to cancel visit: ${e.message}`)}),$s=o.visits.delete.useMutation({onSuccess:()=>{r.visits.list.invalidate(),l.success("Visit deleted"),G(null)},onError:e=>l.error(`Failed to delete visit: ${e.message}`)});function Y(e){e?(Q(e),g({contractId:String(e.contractId),clientId:String(e.clientId),visitDate:e.visitDate?new Date(e.visitDate).toISOString().split("T")[0]:"",status:e.status,notes:e.notes||"",duration:e.duration||""})):(Q(null),g({contractId:"",clientId:"",visitDate:new Date().toISOString().split("T")[0],status:"scheduled",notes:"",duration:""})),B(!0)}function J(){B(!1),Q(null)}async function Os(e){f(e),ns(e.notes||""),os(e.duration||""),I(null),k(null),F(null),gs(!1);try{const t=await r.clientContracts.get.fetch({id:e.contractId});gs(t?.contractType==="recurring"&&t.invoiceTiming==="after_visit"&&!e.invoiceId),t?.services?V(t.services.filter(i=>i.included).map(i=>({serviceCatalogId:i.serviceCatalogId,completed:!1,notes:""}))):V([])}catch{V([])}try{const t=await r.visits.get.fetch({id:e.id});t?.services&&t.services.length>0&&V(t.services.map(i=>({serviceCatalogId:i.serviceCatalogId,completed:i.completed,notes:i.notes||""})))}catch{}h(!0)}function Ps(e){q(e),M(""),xs("cancelled"),S(!0)}function Ls(e){V(t=>t.map(i=>i.serviceCatalogId===e?{...i,completed:!i.completed}:i)),F(null)}function As(e,t){V(i=>i.map(W=>W.serviceCatalogId===e?{...W,notes:t}:W))}async function Us(){if(!(!x||m.length===0))try{const e=await r.visits.previewInvoice.fetch({id:x.id,services:m.map(t=>({serviceCatalogId:t.serviceCatalogId,completed:t.completed}))});F({total:e.total,dueDate:$(e.dueDate),lineItems:e.lineItems})}catch(e){l.error(e instanceof Error?e.message:"Could not preview the invoice.")}}function Rs(e){e.preventDefault();const t=us?us.clientId:Number(c.clientId),i={contractId:Number(c.contractId),clientId:t,visitDate:c.visitDate,status:c.status,notes:c.notes||void 0,duration:c.duration||void 0};D?vs.mutate({id:D.id,...i}):Vs.mutate(i)}function Bs(){x&&js.mutate({id:x.id,notes:ls||void 0,duration:rs||void 0,services:m.length>0?m.map(e=>({serviceCatalogId:e.serviceCatalogId,completed:e.completed,notes:e.notes||void 0})):void 0})}function Qs(){!p||!T.trim()||fs.mutate({id:p.id,reason:T.trim(),status:H})}const{data:Cs=[]}=o.serviceCatalog.list.useQuery(),K=a.useMemo(()=>{const e={};return Cs.forEach(t=>{e[t.id]=t.name}),e},[Cs]),Ns=m.some(e=>e.completed);return s.jsxs(zs,{"data-loc":"client/src/pages/Visits.tsx:335",children:[s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:336",className:"flex flex-col gap-6 p-4 md:p-6",children:[s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:338",className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:339",children:[s.jsx("h1",{"data-loc":"client/src/pages/Visits.tsx:340",className:"text-2xl font-bold",children:"Visits"}),s.jsx("p",{"data-loc":"client/src/pages/Visits.tsx:341",className:"text-muted-foreground",children:"Track and complete service visits"})]}),s.jsxs(n,{"data-loc":"client/src/pages/Visits.tsx:343",onClick:()=>Y(),children:[s.jsx(ws,{"data-loc":"client/src/pages/Visits.tsx:344",className:"h-4 w-4 mr-2"}),"New Visit"]})]}),_.length>0&&s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:351",className:"flex flex-col sm:flex-row gap-3",children:[s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:352",className:"relative flex-1",children:[s.jsx(ae,{"data-loc":"client/src/pages/Visits.tsx:353",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),s.jsx(y,{"data-loc":"client/src/pages/Visits.tsx:354",placeholder:"Search visits...",value:C,onChange:e=>Ts(e.target.value),className:"pl-10"})]}),s.jsxs(L,{"data-loc":"client/src/pages/Visits.tsx:361",value:N,onValueChange:Ms,children:[s.jsx(A,{"data-loc":"client/src/pages/Visits.tsx:362",className:"w-[160px]",children:s.jsx(U,{"data-loc":"client/src/pages/Visits.tsx:363",placeholder:"Filter status"})}),s.jsxs(R,{"data-loc":"client/src/pages/Visits.tsx:365",children:[s.jsx(j,{"data-loc":"client/src/pages/Visits.tsx:366",value:"all",children:"All Statuses"}),bs.map(e=>s.jsx(j,{"data-loc":"client/src/pages/Visits.tsx:368",value:e,children:e.charAt(0).toUpperCase()+e.slice(1).replace("-"," ")},e))]})]})]}),Es?s.jsx("div",{"data-loc":"client/src/pages/Visits.tsx:379",className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(e=>s.jsx(Is,{"data-loc":"client/src/pages/Visits.tsx:381",className:"skeleton h-48"},e))}):hs.length>0?s.jsx("div",{"data-loc":"client/src/pages/Visits.tsx:385",className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:hs.map(e=>s.jsxs(Is,{"data-loc":"client/src/pages/Visits.tsx:387",children:[s.jsxs(Gs,{"data-loc":"client/src/pages/Visits.tsx:388",className:"flex flex-row items-start justify-between pb-2",children:[s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:389",className:"min-w-0 flex-1",children:[s.jsx(Hs,{"data-loc":"client/src/pages/Visits.tsx:390",className:"text-base truncate",children:u[e.contractId]?.name||`Visit #${e.id}`}),s.jsxs("p",{"data-loc":"client/src/pages/Visits.tsx:393",className:"text-sm text-muted-foreground flex items-center gap-1 mt-1",children:[s.jsx(_s,{"data-loc":"client/src/pages/Visits.tsx:394",className:"h-3 w-3"}),v[e.clientId]||"Unknown Client"]})]}),s.jsxs(Xs,{"data-loc":"client/src/pages/Visits.tsx:398",children:[s.jsx(Ys,{"data-loc":"client/src/pages/Visits.tsx:399",asChild:!0,children:s.jsx(n,{"data-loc":"client/src/pages/Visits.tsx:400","aria-label":`Actions for visit ${e.id}`,variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:s.jsx(ie,{"data-loc":"client/src/pages/Visits.tsx:401",className:"h-4 w-4"})})}),s.jsxs(Js,{"data-loc":"client/src/pages/Visits.tsx:404",align:"end",children:[e.status!=="completed"&&e.status!=="c
1ancelled"&&e.status!=="no-show"&&s.jsxs(s.Fragment,{children:[s.jsxs(b,{"data-loc":"client/src/pages/Visits.tsx:407",onClick:()=>Os(e),children:[s.jsx(Z,{"data-loc":"client/src/pages/Visits.tsx:408",className:"h-4 w-4 mr-2"})," Complete Visit"]}),s.jsxs(b,{"data-loc":"client/src/pages/Visits.tsx:410",onClick:()=>Ps(e),children:[s.jsx(ys,{"data-loc":"client/src/pages/Visits.tsx:411",className:"h-4 w-4 mr-2"})," Cancel Visit"]})]}),e.invoiceId&&s.jsxs(b,{"data-loc":"client/src/pages/Visits.tsx:416",onClick:()=>cs("/invoices"),children:[s.jsx(E,{"data-loc":"client/src/pages/Visits.tsx:417",className:"h-4 w-4 mr-2"})," View Invoice"]}),s.jsxs(b,{"data-loc":"client/src/pages/Visits.tsx:420",onClick:()=>Y(e),children:[s.jsx(ce,{"data-loc":"client/src/pages/Visits.tsx:421",className:"h-4 w-4 mr-2"})," Edit"]}),s.jsxs(b,{"data-loc":"client/src/pages/Visits.tsx:423",className:"text-destructive",onClick:()=>G(e.id),children:[s.jsx(le,{"data-loc":"client/src/pages/Visits.tsx:427",className:"h-4 w-4 mr-2"})," Delete"]})]})]})]}),s.jsxs(Ks,{"data-loc":"client/src/pages/Visits.tsx:432",className:"space-y-2",children:[s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:433",className:"flex items-center gap-2 flex-wrap",children:[s.jsx(P,{"data-loc":"client/src/pages/Visits.tsx:434",className:oe[e.status]||"",children:e.status.replace("-"," ")}),s.jsxs(P,{"data-loc":"client/src/pages/Visits.tsx:437",variant:"outline",className:"gap-1",children:[s.jsx(ne,{"data-loc":"client/src/pages/Visits.tsx:438",className:"h-3 w-3"}),e.visitDate?$(e.visitDate):"No date"]}),e.duration&&s.jsxs(P,{"data-loc":"client/src/pages/Visits.tsx:442",variant:"secondary",className:"gap-1",children:[s.jsx(Ws,{"data-loc":"client/src/pages/Visits.tsx:443",className:"h-3 w-3"}),e.duration,"h"]}),e.invoiceId&&s.jsxs(P,{"data-loc":"client/src/pages/Visits.tsx:448",variant:"secondary",className:"gap-1 bg-emerald-100 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-200",children:[s.jsx(E,{"data-loc":"client/src/pages/Visits.tsx:449",className:"h-3 w-3"}),"Invoiced"]})]}),e.notes&&s.jsx("p",{"data-loc":"client/src/pages/Visits.tsx:455",className:"text-xs text-muted-foreground line-clamp-2",children:e.notes})]})]},e.id))}):C||N!=="all"?s.jsx("div",{"data-loc":"client/src/pages/Visits.tsx:462",className:"text-center py-12 text-muted-foreground",children:"No visits found matching your filters."}):s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:466",className:"text-center py-12",children:[s.jsx(Zs,{"data-loc":"client/src/pages/Visits.tsx:467",className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),s.jsx("h3",{"data-loc":"client/src/pages/Visits.tsx:468",className:"text-lg font-medium mb-2",children:"No visits yet"}),s.jsx("p",{"data-loc":"client/src/pages/Visits.tsx:469",className:"text-muted-foreground mb-4",children:"Create a visit to start tracking your service calls."}),s.jsxs(n,{"data-loc":"client/src/pages/Visits.tsx:470",onClick:()=>Y(),children:[s.jsx(ws,{"data-loc":"client/src/pages/Visits.tsx:471",className:"h-4 w-4 mr-2"}),"New Visit"]})]})]}),s.jsx(ss,{"data-loc":"client/src/pages/Visits.tsx:479",open:Ss,onOpenChange:B,children:s.jsxs(es,{"data-loc":"client/src/pages/Visits.tsx:480",children:[s.jsx(ts,{"data-loc":"client/src/pages/Visits.tsx:481",children:s.jsx(as,{"data-loc":"client/src/pages/Visits.tsx:482",children:D?"Edit Visit":"New Visit"})}),s.jsxs("form",{"data-loc":"client/src/pages/Visits.tsx:484",onSubmit:Rs,className:"space-y-4",children:[s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:485",className:"space-y-2",children:[s.jsx(d,{"data-loc":"client/src/pages/Visits.tsx:486",htmlFor:"contractId",children:"Service *"}),s.jsxs(L,{"data-loc":"client/src/pages/Visits.tsx:487",value:c.contractId,onValueChange:e=>{const t=u[Number(e)];g({...c,contractId:e,clientId:t?String(t.clientId):c.clientId})},children:[s.jsx(A,{"data-loc":"client/src/pages/Visits.tsx:498",children:s.jsx(U,{"data-loc":"client/src/pages/Visits.tsx:499",placeholder:"Select service"})}),s.jsx(R,{"data-loc":"client/src/pages/Visits.tsx:501",children:X.filter(e=>e.status==="active").map(e=>s.jsxs(j,{"data-loc":"client/src/pages/Visits.tsx:503",value:String(e.id),children:[e.name," — ",v[e.clientId]||"Unknown"]},e.id))})]})]}),s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:511",className:"grid sm:grid-cols-2 gap-4",children:[s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:512",className:"space-y-2",children:[s.jsx(d,{"data-loc":"client/src/pages/Visits.tsx:513",htmlFor:"visitDate",children:"Visit Date *"}),s.jsx(y,{"data-loc":"client/src/pages/Visits.tsx:514",id:"visitDate",type:"date",value:c.visitDate,onChange:e=>g({...c,visitDate:e.target.value}),required:!0})]}),s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:522",className:"space-y-2",children:[s.jsx(d,{"data-loc":"client/src/pages/Visits.tsx:523",htmlFor:"status",children:"Status"}),s.jsxs(L,{"data-loc":"client/src/pages/Visits.tsx:524",value:c.status,onValueChange:e=>g({...c,status:e}),children:[s.jsx(A,{"data-loc":"client/src/pages/Visits.tsx:528",children:s.jsx(U,{"data-loc":"client/src/pages/Visits.tsx:529"})}),s.jsx(R,{"data-loc":"client/src/pages/Visits.tsx:531",children:bs.map(e=>s.jsx(j,{"data-loc":"client/src/pages/Visits.tsx:533",value:e,children:e.charAt(0).toUpperCase()+e.slice(1).replace("-"," ")},e))})]})]})]}),s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:542",className:"space-y-2",children:[s.jsx(d,{"data-loc":"client/src/pages/Visits.tsx:543",htmlFor:"duration",children:"Duration (hours)"}),s.jsx(y,{"data-loc":"client/src/pages/Visits.tsx:544",id:"duration",type:"number",step:"0.25",value:c.duration,onChange:e=>g({...c,duration:e.target.value}),placeholder:"e.g. 1.5"})]}),s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:554",className:"space-y-2",children:[s.jsx(d,{"data-loc":"client/src/pages/Visits.tsx:555",htmlFor:"notes",children:"Notes"}),s.jsx(is,{"data-loc":"client/src/pages/Visits.tsx:556",id:"notes",value:c.notes,onChange:e=>g({...c,notes:e.target.value}),placeholder:"Visit notes...",rows:2})]}),s.jsxs(O,{"data-loc":"client/src/pages/Visits.tsx:565",children:[s.jsx(n,{"data-loc":"client/src/pages/Visits.tsx:566",type:"button",variant:"outline",onClick:J,children:"Cancel"}),s.jsx(n,{"data-loc":"client/src/pages/Visits.tsx:567",type:"submit",disabled:Vs.isPending||vs.isPending,children:D?"Update":"Create"})]})]})]})}),s.jsx(ss,{"data-loc":"client/src/pages/Visits.tsx:576",open:Ds,onOpenChange:e=>{e||(h(!1),f(null),I(null),k(null),F(null))},children:s.jsxs(es,{"data-loc":"client/src/pages/Visits.tsx:585",className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[s.jsx(ts,{"data-loc":"client/src/pages/Visits.tsx:586",children:s.jsx(as,{"data-loc":"client/src/pages/Visits.tsx:587",children:ds?"Visit Completed":"Complete Visit"})}),ds?s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:594",className:"space-y-4",children:[s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:595",className:"rounded-lg border bg-emerald-50 dark:bg-emerald-950 p-4 space-y-2",children:[s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:596",className:"flex items-center gap-2 text-emerald-700 dark:text-emerald-300",children:[s.jsx(Z,{"data-loc":"client/src/pages/Visits.tsx:597",className:"h-5 w-5"}),s.jsx("span",{"data-loc":"client/src/pages/Visits.tsx:598",className:"font-medium",children:"Invoice Generated"})]}),s.jsxs("p",{"data-loc":"client/src/pages/Visits.tsx:600",className:"text-sm text-muted-foreground",children:["An invoice for ",s.jsxs("span",{"data-loc":"client/src/pages/Visits.tsx:601",className:"font-semibold",children:["$",Fs]})," has been created as a draft."]}),s.jsxs(n,{"data-loc":"client/src/pages/Visits.tsx:603",variant:"outline",size:"sm",className:"mt-2",onClick:()=>{h(!1),f(null),I(null),cs("/invoices")},children:[s.jsx(re,{"data-loc":"client/src/pages/Visits.tsx:614",className:"h-4 w-4 mr-2"}),"View Invoice"]})]}),s.jsx(O,{"data-loc":"client/src/pages/Visits.tsx:618",children:s.jsx(n,{"data-loc":"client/src/pages/Visits.tsx:619",onClick:()=>{h(!1),f(null),I(null),k(null)},children:"Done"})})]}):s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:630",className:"space-y-4",children:[x&&s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:632",className:"text-sm text-muted-foreground",children:[s.jsx("span",{"data-loc":"client/src/pages/Visits.tsx:633",className:"font-medium text-foreground",children:u[x.contractId]?.name})," · ",v[x.clientId]," · ",x.visitDate?$(x.visitDate):""]}),m.length>0&&s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:645",className:"space-y-2",children:[s.jsx(d,{"data-loc":"client/src/pages/Visits.tsx:646",children:"Services Performed"}),s.jsx("div",{"data-loc":"client/src/pages/Visits.tsx:647",className:"border rounded-lg divide-y",children:m.map(e=>s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:649",className:"p-3 space-y-2",children:[s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:650",className:"flex items-center gap-3",children:[s.jsx(ee,{"data-loc":"client/src/pages/Visits.tsx:651","aria-label":`Completed ${K[e.serviceCatalogId]||`Service ${e.serviceCatalogId}`}`,checked:e.completed,onCheckedChange:()=>Ls(e.serviceCatalogId)}),s.jsx("span",{"data-loc":"client/src/pages/Visits.tsx:656",className:`text-sm flex-1 ${e.completed?"font-medium":"text-muted-foreground"}`,children:K[e.serviceCatalogId]||`Service #${e.serviceCatalogId}`})]}),e.completed&&s.jsx(y,{"data-loc":"client/src/pages/Visits.tsx:661","aria-label":`Notes for ${K[e.serviceCatalogId]||`Service ${e.serviceCatalogId}`}`,placeholder:"Service notes (optional)",value:e.notes,onChange:t=>As(e.serviceCatalogId,t.target.value),className:"ml-7 h-8 w-[calc(100%-1.75rem)] text-xs"})]},e.serviceCatalogId))})]}),s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:675",className:"space-y-2",children:[s.jsx(d,{"data-loc":"client/src/pages/Visits.tsx:676",htmlFor:"completeDuration",children:"Duration (hours)"}),s.jsx(y,{"data-loc":"client/src/pages/Visits.tsx:677",id:"completeDuration",type:"number",step:"0.25",value:rs,onChange:e=>os(e.target.value),placeholder:"e.g. 1.5"})]}),s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:687",className:"space-y-2",children:[s.jsx(d,{"data-loc":"client/src/pages/Visits.tsx:688",htmlFor:"completeNotes",children:"Visit Summary"}),s.jsx(is,{"data-loc":"client/src/pages/Visits.tsx:689",id:"completeNotes",value:ls,onChange:e=>ns(e.target.value),placeholder:"Summary notes for this visit...",rows:3})]}),ps&&Ns&&!w&&s.jsxs(n,{"data-loc":"client/src/pages/Visits.tsx:700",type:"button",variant:"outline",size:"sm",onClick:Us,className:"w-full",children:[s.jsx(E,{"data-loc":"client/src/pages/Visits.tsx:707",className:"h-4 w-4 mr-2"}),"Preview Invoice"]}),w&&s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:713",className:"rounded-lg border bg-muted/50 p-3 space-y-2 text-sm",children:[s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:714",className:"flex items-center gap-2 font-medium",children:[s.jsx(E,{"data-loc":"client/src/pages/Visits.tsx:715",className:"h-4 w-4"}),"Invoice Preview"]}),s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:718",className:"space-y-1 pl-6",children:[w.lineItems.map((e,t)=>s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:720",className:"flex justify-between",children:[s.jsx("span",{"data-loc":"client/src/pages/Visits.tsx:721",children:e.name}),s.jsxs("span",{"data-loc":"client/src/pages/Visits.tsx:722",className:"font-medium",children:["$",e.price]})]},t)),s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:725",className:"border-t pt-1 mt-1 flex justify-between font-semibold",children:[s.jsx("span",{"data-loc":"client/src/pages/Visits.tsx:726",children:"Total"}),s.jsxs("span",{"data-loc":"client/src/pages/Visits.tsx:727",children:["$",w.total]})]}),s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:729",className:"text-muted-foreground text-xs",children:["Due date: ",w.dueDate]})]})]}),ps&&Ns&&s.jsx("p",{"data-loc":"client/src/pages/Visits.tsx:737",className:"text-xs text-muted-foreground",children:"An invoice will be saved for the completed services. Email delivery follows the contract’s auto-send setting."}),s.jsxs(O,{"data-loc":"client/src/pages/Visits.tsx:742",children:[s.jsx(n,{"data-loc":"client/src/pages/Visits.tsx:743",variant:"outline",onClick:()=>h(!1),children:"Cancel"}),s.jsxs(n,{"data-loc":"client/src/pages/Visits.tsx:744",onClick:Bs,disabled:js.isPending,children:[s.jsx(Z,{"data-loc":"client/src/pages/Visits.tsx:745",className:"h-4 w-4 mr-2"}),"Complete Visit"]})]})]})]})}),s.jsx(ss,{"data-loc":"client/src/pages/Visits.tsx:755",open:ks,onOpenChange:e=>{e||(S(!1),q(null),M(""))},children:s.jsxs(es,{"data-loc":"client/src/pages/Visits.tsx:762",children:[s.jsxs(ts,{"data-loc":"client/src/pages/Visits.tsx:763",children:[s.jsx(as,{"data-loc":"client/src/pages/Visits.tsx:764",children:"Cancel Visit"}),s.jsx(se,{"data-loc":"client/src/pages/Visits.tsx:765",children:p&&s.jsxs(s.Fragment,{children:[u[p.contractId]?.name," · ",v[p.clientId]," · ",p.visitDate?$(p.visitDate):""]})})]}),s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:773",className:"space-y-4",children:[s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:774",className:"space-y-2",children:[s.jsx(d,{"data-loc":"client/src/pages/Visits.tsx:775",children:"Cancellation Type"}),s.jsxs(L,{"data-loc":"client/src/pages/Visits.tsx:776",value:H,onValueChange:e=>xs(e),children:[s.jsx(A,{"data-loc":"client/src/pages/Visits.tsx:777",children:s.jsx(U,{"data-loc":"client/src/pages/Visits.tsx:778"})}),s.jsxs(R,{"data-loc":"client/src/pages/Visits.tsx:780",children:[s.jsx(j,{"data-loc":"client/src/pages/Visits.tsx:781",value:"cancelled",children:"Cancelled"}),s.jsx(j,{"data-loc":"client/src/pages/Visits.tsx:782",value:"no-show",children:"No-Show"})]})]})]}),s.jsxs("div",{"data-loc":"client/src/pages/Visits.tsx:787",className:"space-y-2",children:[s.jsx(d,{"data-loc":"client/src/pages/Visits.tsx:788",htmlFor:"cancelReason",children:"Reason *"}),s.jsx(is,{"data-loc":"client/src/pages/Visits.tsx:789",id:"cancelReason",value:T,onChange:e=>M(e.target.value),placeholder:"Reason for cancellation...",rows:3})]}),p?.invoiceId&&s.jsx("div",{"data-loc":"client/src/pages/Visits.tsx:799",className:"rounded-lg border border-yellow-200 bg-yellow-50 dark:bg-yellow-950 dark:border-yellow-800 p-3 text-sm text-yellow-800 dark:text-yellow-200",children:"Invoice due date will be automatically pushed to the next scheduled visit."}),s.jsxs(O,{"data-loc":"client/src/pages/Visits.tsx:804",children:[s.jsx(n,{"data-loc":"client/src/pages/Visits.tsx:805",variant:"outline",onClick:()=>S(!1),children:"Go Back"}),s.jsxs(n,{"data-loc":"client/src/pages/Visits.tsx:806",variant:"destructive",onClick:Qs,disabled:!T.trim()||fs.isPending,children:[s.jsx(ys,{"data-loc":"client/src/pages/Visits.tsx:811",className:"h-4 w-4 mr-2"}),H==="no-show"?"Mark No-Show":"Cancel Visit"]})]})]})]})}),s.jsx(te,{"data-loc":"client/src/pages/Visits.tsx:820",open:z!==null,onCancel:()=>G(null),title:"Delete Visit",description:"Are you sure you want to delete this visit? This action cannot be undone.",confirmLabel:"Delete",onConfirm:()=>{z&&$s.mutate({id:z})},destructive:!0})]})}export{Se 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.