1import{r as S,j as e}from"./vendor-react-DKbe1Umz.js";import{u as $}from"./vendor-data-CjSe2wkl.js";import{y as E,cH as P,ay as L,C as c,v as l,s as T,t as U,w as F,aG as O,D as R,c as B,d as H,e as V,l as i}from"./index-DZ74KeH3.js";import{ay as n,bF as m,Y as j,bz as N,a7 as f,k as w,d8 as Y,J as A}from"./vendor-ui-DMaW9-Ov.js";import"./vendor-charts-DWX9qznF.js";import"./vendor-dates-5UNeOyFW.js";import"./vendor-forms-C2vWC2ab.js";function K(){const{user:o}=E(),[t,p]=S.useState(null);if(!P(o==null?void 0:o.role))return e.jsx(L,{to:"/dashboard"});const{data:a,isLoading:b}=$({queryKey:["/api/vendor/schedule"]}),h=s=>{switch(s){case"in_progress":return e.jsxs(i,{className:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200","data-testid":`badge-status-${s}`,children:[e.jsx(n,{className:"w-3 h-3 mr-1"}),"In Progress"]});case"completed":return e.jsxs(i,{className:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200","data-testid":`badge-status-${s}`,children:[e.jsx(j,{className:"w-3 h-3 mr-1"}),"Completed"]});case"delayed":return e.jsxs(i,{variant:"destructive","data-testid":`badge-status-${s}`,children:[e.jsx(A,{className:"w-3 h-3 mr-1"}),"Delayed"]});default:return e.jsxs(i,{variant:"outline","data-testid":`badge-status-${s}`,children:[e.jsx(n,{className:"w-3 h-3 mr-1"}),"Upcoming"]})}},g=s=>new Date(s).toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"}),v=(s,x)=>{const r=new Date(s),u=new Date(x),d={month:"short",day:"numeric"};return r.getFullYear()!==new Date().getFullYear()&&(d.year="numeric"),`${r.toLocaleDateString("en-US",d)} â ${u.toLocaleDateString("en-US",d)}`},y=(s,x)=>{const r=new Date(s),u=new Date(x),d=Math.round((u.getTime()-r.getTime())/(1e3*60*60*24));return d===0?"Same day":`${d} day${d!==1?"s":""}`},D=(a==null?void 0:a.filter(s=>s.status==="upcoming"))??[],k=(a==null?void 0:a.filter(s=>s.status==="in_progress"))??[],C=(a==null?void 0:a.filter(s=>s.status==="completed"))??[];return e.jsxs("div",{className:"p-6 space-y-6 max-w-5xl mx-auto",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold","data-testid":"text-page-title",children:"Schedule"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"View your upcoming delivery windows, scheduled work dates, and project milestones from contractors."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(c,{"data-testid":"card-stat-upcoming",children:e.jsx(l,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-blue-100 dark:bg-blue-900",children:e.jsx(n,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upcoming"}),e.jsx("p",{className:"text-2xl font-bold","data-testid":"text-upcoming-count",children:D.length})]})]})})}),e.jsx(c,{"data-testid":"card-stat-active",children:e.jsx(l,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-green-100 dark:bg-green-900",children:e.jsx(m,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"In Progress"}),e.jsx("p",{className:"text-2xl font-bold","data-testid":"text-active-count",children:k.length})]})]})})}),e.jsx(c,{"data-testid":"card-stat-completed",children:e.jsx(l,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-purple-100 dark:bg-purple-900",children:e.jsx(j,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Completed"}),e.jsx("p",{className:"text-2xl font-bold","data-testid":"text-completed-count",children:C.length})]})]})})})]}),e.jsxs(c,{children:[e.jsxs(T,{children:[e.jsx(U,{"data-testid":"text-schedule-title",children:"Scheduled Events"}),e.jsx(F,{children:"Click any event to see full details"})]}),e.jsx(l,{children:b?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(s=>e.jsx(O,{className:"h-20 w-full"},s))}):a&&a.length>0?e.jsx("div",{className:"space-y-3",children:a.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg cursor-pointer hover:bg-muted/50 transition-colors","data-testid":`row-event-${s.id}`,onClick:()=>p(s),children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-2 rounded bg-muted",children:e.jsx(m,{className:"w-5 h-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium","data-testid":`text-event-name-${s.id}`,children:s.description}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(N,{className:"w-3 h-3"}),e.jsx("span",{children:s.contractorOrgName}),e.jsx("span",{children:"·"}),e.jsx("span",{children:s.projectName})]}),e.jsxs("div",{className:"flex items-center gap-3 text-sm text-muted-foreground mt-0.5",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(n,{className:"w-3 h-3"}
1),v(s.startDate,s.endDate)]}),s.location&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(f,{className:"w-3 h-3"}),s.location]})]})]})]}),h(s.status)]},s.id))}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(m,{className:"w-12 h-12 mx-auto text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-muted-foreground","data-testid":"text-no-events",children:"No scheduled events yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"When contractors schedule deliveries or work windows involving your services, they'll appear here."})]})})]}),e.jsx(R,{open:!!t,onOpenChange:s=>{s||p(null)},children:e.jsxs(B,{className:"max-w-lg","data-testid":"modal-event-detail",children:[e.jsx(H,{children:e.jsxs(V,{className:"flex items-center gap-2",children:[e.jsx(m,{className:"w-5 h-5 text-primary"}),"Event Details"]})}),t&&e.jsxs("div",{className:"space-y-5 pt-1",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Description"}),e.jsx("p",{className:"text-base font-semibold","data-testid":"text-modal-description",children:t.description})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Status"}),h(t.status)]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Duration"}),e.jsx("p",{className:"text-sm font-medium","data-testid":"text-modal-duration",children:y(t.startDate,t.endDate)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[e.jsx(w,{className:"w-3 h-3"})," Start Date"]}),e.jsx("p",{className:"text-sm","data-testid":"text-modal-start-date",children:g(t.startDate)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[e.jsx(w,{className:"w-3 h-3"})," End Date"]}),e.jsx("p",{className:"text-sm","data-testid":"text-modal-end-date",children:g(t.endDate)})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[e.jsx(Y,{className:"w-3 h-3"})," Project"]}),e.jsx("p",{className:"text-sm font-medium","data-testid":"text-modal-project",children:t.projectName})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[e.jsx(N,{className:"w-3 h-3"})," Contractor"]}),e.jsx("p",{className:"text-sm","data-testid":"text-modal-contractor",children:t.contractorOrgName})]}),t.location&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[e.jsx(f,{className:"w-3 h-3"})," Location"]}),e.jsx("p",{className:"text-sm","data-testid":"text-modal-location",children:t.location})]})]})]})})]})}export{K 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.