1import{cl as g,j as e,R as m,bU as ue}from"./vendor-ct_YKIP6_bundle.js";import{t as u,rB as ge}from"./registration-BfOA5mCx_bundle.js";import"./moment-DyvZl3Ud_bundle.js";import{j as be,C as he,W as xe,Y as je,ci as fe,cj as ye,aE as _e,az as Ne,ck as ve,H as Se,J as we,ay as G,q as Ce}from"./speedboat-vendor-DBIVks5t_bundle.js";import{mV as h,lg as De,c as j,nm as ke}from"./index-BiagCLbs_bundle.js";import{A as Te,a as Je,b as Pe,d as Ee,e as Le,f as Ae,g as Re,h as Ie}from"./AlertDialog-WWsmw_yy_bundle.js";import{B as L}from"./Button-CgrHqwU2_bundle.js";import{C as Ke,a as Be,d as Oe,e as He}from"./Card-CC2OyXRV_bundle.js";import{D as w,a as ze}from"./DataTable-uF2mc6oU_bundle.js";import{D as Y,a as W,b as q,c as T,f as Me,e as Fe,d as Ge}from"./DropdownMenu-DEmPX796_bundle.js";import{I as Ue,a as $e,b as Ve}from"./InputGroup-ByLJr-2v_bundle.js";import{L as Qe}from"./ListPagination-CQp02ttX_bundle.js";import{P as Ye}from"./PageHeader-C9O9jzJh_bundle.js";import{P as J}from"./PageState-DtpmvJeu_bundle.js";import{S as We}from"./SpeedboatPage-DYBZ2zvb_bundle.js";import{T as d}from"./Text-B2BbGQxe_bundle.js";import{u as X}from"./companyDates-Dl1L5068_bundle.js";import{u as qe}from"./useCurrentCompanyRole-B8oCX-IK_bundle.js";import{t as x}from"./analytics-Bx8GuRNa_bundle.js";import"./useSageStore-BO85gJVX_bundle.js";import{u as Xe}from"./useDebouncedValue-3IKAS9NO_bundle.js";import{m as Ze}from"./slackIntegration-mZcBTumD_bundle.js";import"./useSpeedboatLayoutStore-DlBUjk6G_bundle.js";import"./cacheInvalidation-CBJ-aFQu_bundle.js";import{L as Z}from"./Link-DZWVo5WQ_bundle.js";import{J as ee,u as es}from"./JobStatusBadge-Do2uVDt-_bundle.js";import{f as P}from"./jobDates-Bk9fDVL7_bundle.js";import{P as ss}from"./Progress-d4uBjgZF_bundle.js";import{S as U}from"./Skeleton-S1mHjS99_bundle.js";import{u as as}from"./useJobScoresQuery-B7LCT6HU_bundle.js";import{u as ts}from"./useJobsQuery-_I2CVCLh_bundle.js";import"./sentry-DLDmuXKN_bundle.js";import"./datadog-DxmyjtSX_bundle.js";import"./stripe-BA7RN6Z4_bundle.js";import"./Input-BkDyWfPc_bundle.js";import"./Select-CgJf-0iD_bundle.js";import"./Table-UsUTmpjE_bundle.js";import"./Empty-BGOBZB-E_bundle.js";import"./useCurrentUser-fx9q9yAY_bundle.js";import"./useLocationsTreeQuery-DbkPFKXr_bundle.js";import"./locations.api-sCu28iOe_bundle.js";import"./useMasterItemsCatalogQuery-hVW8nS0Q_bundle.js";import"./activityHistory.api-CcFZLS9T_bundle.js";import"./useJobQuery-C-icdYHg_bundle.js";import"./StatusBadge-CAJiTYPe_bundle.js";import"./Badge-CWDeSV2F_bundle.js";function $(){const{t:a}=g();return e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(he,{className:"size-3.5 shrink-0 text-[var(--color-success-text)]","aria-hidden":"true"}),e.jsx(d,{as:"span",variant:"body-sm",weight:"semibold",tone:"success",children:a("speedboat.pages.jobs.plan_readiness.ready")})]})}function ns({statusKey:a,score:n,isLoading:t,isError:s}){const{t:o}=g(),r=e.jsx(d,{as:"span",variant:"body-sm",tone:"subtle","aria-label":o("speedboat.pages.jobs.plan_readiness.aria.not_applicable"),children:"â"});if(a===h.Archived)return e.jsx($,{});if(a!==h.NotStarted)return r;if(t)return e.jsxs("div",{className:"flex items-center gap-2.5",role:"status","aria-label":o("speedboat.pages.jobs.plan_readiness.aria.loading"),children:[e.jsx(U,{className:"h-2 w-[120px] rounded-full"}),e.jsx(U,{className:"h-3.5 w-8 rounded"})]});if(s||!n)return e.jsx(d,{as:"span",variant:"body-sm",tone:"danger",children:o("speedboat.pages.jobs.plan_readiness.error_short")});if(n.plannedItems.length===0)return r;const c=Math.round(n.readiness.percent);if(c>=100)return e.jsx($,{});const l=n.plannedItems.some(p=>p.masterItemDeletedAt);return e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(ss,{value:c,className:"h-2 w-[120px]","aria-label":`${o("speedboat.pages.jobs.plan_readiness.aria.percent_label")}: ${c}%`}),e.jsx(d,{as:"span",variant:"body-sm",weight:"semibold",children:`${c}%`}),l&&e.jsx(be,{className:"size-3.5 shrink-0 text-warning-text","aria-label":o("speedboat.pages.jobs.plan_readiness.blocked_by_deleted")})]})}const E=12,os=[h.NotStarted,h.InProgress,h.Completed];function rs(){return qe()?.roleType===ge.OWNER}function se({jobId:a,jobTitle:n}){const{t}=g(),s=es(),[o,r]=m.useState(!1),c=rs(),l=b=>{r(b),s.reset()},p=b=>{b.preventDefault(),s.mutate(a,{onSuccess:()=>{G.success(t("speedboat.pages.jobs.delete_dialog.success")),r(!1)},onError:N=>{ke(N)&&(G.error(t("speedboat.pages.jobs.delete_dialog.error_has_inventory",{name:n})),l(!1))}})};return e.jsxs(e.Fragment,{children:[e.jsxs(Y,{children:[e.jsx(W,{asChild:!0,children:e.jsx(L,{variant:"ghost",size:"icon-sm","aria-label":t("speedboat.pages.jobs.actions.open"),children:e.jsx(fe,{})})}),e.jsxs(q,{align:"end",children:[e.jsx(T,{asChild:!0,children:e.jsxs(Z,{to:`/jobs/${a}`,children:[e.jsx(ye,{}),t("speedboat.pages.jobs.actions.view")]})}),c&&e.jsxs(T,{variant:"destructive",onSelect:()=>r(!0),children:[e.jsx(_e,{}),t("speedboat.pages.jobs.actions.delete")]})]})]}),c&&e.jsx(Te,{open:o,onOpenChange:l,children:e.jsxs(Je,{children:[e.jsxs(Pe,{children:[e.jsx(Ee,{children:t("speedboat.pages.jobs.delete_dialog.title")}),e.jsx(Le,{children:t("speedboat.pages.jobs.delete_dialog.description",{name:n})})]}
1),s.isError&&e.jsx(d,{variant:"body-sm",tone:"danger",children:t("speedboat.pages.jobs.delete_dialog.error")}),e.jsxs(Ae,{children:[e.jsx(Re,{disabled:s.isPending,children:t("speedboat.pages.jobs.delete_dialog.cancel")}),e.jsx(Ie,{onClick:p,disabled:s.isPending,children:s.isPending?t("speedboat.pages.jobs.delete_dialog.deleting"):t("speedboat.pages.jobs.delete_dialog.confirm")})]})]})})]})}function V({date:a}){const n=X(),t=a?P(a,n):"";return t?e.jsx("span",{className:"text-[13px] leading-[18px] text-foreground-soft",children:t}):null}function is({job:a}){const n=X(),t=a.startDate?P(a.startDate,n):"",s=a.endDate?P(a.endDate,n):"";return!t&&!s?null:e.jsxs("div",{className:"flex items-center gap-2 text-[13px] leading-[18px] text-foreground-soft",children:[t?e.jsx("span",{children:t}):null,t&&s?e.jsx(Ce,{className:"size-3.5 shrink-0 text-muted-foreground"}):null,s?e.jsx("span",{children:s}):null]})}const ae=new Set([h.NotStarted]),Q={title:"name",statusKey:"status",startDate:"start_date",endDate:"end_date"},C=()=>({ascending:u("speedboat.components.table.sort_ascending"),descending:u("speedboat.components.table.sort_descending")}),ls=({isScoresError:a,isScoresLoading:n,scoresById:t})=>[{accessorKey:"jobNumber",header:()=>u("speedboat.pages.jobs.columns.job_id"),cell:({row:s})=>s.original.jobNumber?e.jsxs(d,{as:"span",variant:"body-sm",tone:"muted",className:"font-mono whitespace-nowrap",children:["#",s.original.jobNumber]}):e.jsx("span",{className:"text-[13px] leading-[18px] text-foreground-soft",children:"â"}),enableSorting:!1,enableHiding:!1},{accessorKey:"title",header:({column:s})=>e.jsx(w,{column:s,title:u("speedboat.pages.jobs.columns.name"),labels:C()}),cell:({row:s})=>e.jsx(d,{variant:"body",weight:"medium",truncate:!0,className:"min-w-[220px]",children:s.original.title}),enableSorting:!0,enableHiding:!1},{accessorKey:"customerName",header:()=>u("speedboat.pages.jobs.columns.customer"),cell:({row:s})=>s.original.customerName?e.jsx(d,{as:"span",variant:"body-sm",tone:"default",truncate:!0,children:s.original.customerName}):e.jsx("span",{className:"text-[13px] leading-[18px] text-foreground-soft",children:"â"}),enableSorting:!1,enableHiding:!1},{accessorKey:"jobType",header:()=>u("speedboat.pages.jobs.columns.job_type"),cell:({row:s})=>s.original.jobType?e.jsx(d,{as:"span",variant:"body-sm",tone:"default",children:s.original.jobType}):e.jsx("span",{className:"text-[13px] leading-[18px] text-foreground-soft",children:"â"}),enableSorting:!1,enableHiding:!1},{accessorKey:"startDate",header:({column:s})=>e.jsx(w,{column:s,title:u("speedboat.pages.jobs.columns.start_date"),labels:C()}),cell:({row:s})=>e.jsx(V,{date:s.original.startDate}),enableSorting:!0,enableHiding:!1},{accessorKey:"endDate",header:({column:s})=>e.jsx(w,{column:s,title:u("speedboat.pages.jobs.columns.end_date"),labels:C()}),cell:({row:s})=>e.jsx(V,{date:s.original.endDate}),enableSorting:!0,enableHiding:!1},{accessorKey:"statusKey",header:({column:s})=>e.jsx(w,{column:s,title:u("speedboat.pages.jobs.columns.status"),labels:C()}),cell:({row:s})=>e.jsx(ee,{statusKey:s.original.statusKey,statusLabel:s.original.statusLabel}),enableSorting:!0,enableHiding:!1},{id:"planReadiness",header:()=>u("speedboat.pages.jobs.columns.plan_readiness"),cell:({row:s})=>{const o=s.original.statusKey,r=o!==void 0&&ae.has(o);return e.jsx(ns,{statusKey:o,score:t?.get(s.original.id),isLoading:r&&n,isError:r&&a})},enableSorting:!1,enableHiding:!1},{id:"actions",cell:({row:s})=>e.jsx("div",{className:"flex justify-end",onClick:o=>o.stopPropagation(),children:e.jsx(se,{jobId:s.original.id,jobTitle:s.original.title})}),enableSorting:!1,enableHiding:!1}],ds=Object.values(h).filter(a=>a!==h.Archived);function cs({statuses:a,onToggleStatus:n,onClearStatuses:t}){const{t:s}=g();return e.jsxs(Y,{children:[e.jsx(W,{asChild:!0,children:e.jsxs(L,{variant:"secondary","aria-label":s("speedboat.pages.jobs.filters.status_aria"),className:"w-full font-medium text-foreground-soft lg:w-auto",children:[s("speedboat.pages.jobs.filters.status"),a.length>0&&e.jsx("span",{className:"inline-flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-brand px-1",children:e.jsx(d,{as:"span",variant:"caption",weight:"semibold",tone:"inverse",children:a.length})}),e.jsx(Ne,{className:"size-3 text-muted-foreground"})]})}),e.jsxs(q,{className:"w-48",align:"start",children:[e.jsx(Me,{children:s("speedboat.pages.jobs.filters.status")}),ds.map(o=>e.jsx(Fe,{checked:a.includes(o),onCheckedChange:()=>n(o),onSelect:r=>r.preventDefault(),children:s(`speedboat.pages.jobs.status.${o}`)},o)),a.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ge,{}),e.jsx(T,{onSelect:t,children:s("speedboat.pages.jobs.filters.clear")})]})]})]})}function ps({onViewModeChange:a,viewMode:n}){const{t}=g(),s="group/button inline-flex h-[38px] w-[42px] shrink-0 items-center justify-center transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring";return e.jsxs("div",{className:"ml-auto inline-flex h-10 shrink-0 items-center overflow-hidden rounded-lg border border-input bg-background",role:"group","aria-label":t("speedboat.pages.jobs.view.choose"),children:[e.jsx("button",{type:"button",className:j(s,n==="list"&&"bg-accent"),"aria-label":t("speedboat.pages.jobs.view.list"),"aria-pressed":n==="list",onClick:()=>a("list"),children:e.jsx(ve,{className:j("size-4",n==="list"?"text-foreground":"text-muted-foreground")})}),e.jsx("div",{className:"h-6 w-px shrink-0 bg-border","aria-hidden":"true"}),e.jsx("button",{type:"button",className:j(s,n==="grid"&&"bg-accent"),"aria-label":t("speedboat.pages.jobs.view.grid"),"aria-pressed":n==="grid",onClick:()=>a("grid"),children:e.jsx(Se,{className:j("size-4",n==="grid"?"text-foreground":"text-muted-foreground")})})]})}function ms({onSearchChange:a,onToggleStatus:n,onClearStatuses:t,onViewModeChange:s,searchQuery:o,statuses:r,viewMode:c}){const{t:l}=g();return e.jsxs("div",{"data-testid":"sb-filter-bar",className:"flex flex-col gap-3 lg:flex-row lg:items-center",children:[e.jsxs("label",{htmlFor:"jobs-search",className:"w-full shrink-0 lg:w-80",children:[e.jsx("span",{className:"sr-only",children:l("speedboat.pages.jobs.search_label")}),e.jsxs(Ue,{className:"h-10",children:[e.jsx($e,{align:"inline-start",children:e.jsx(je,{className:"size-4 text-muted-foreground","aria-hidden":"true"})}),e.jsx(Ve,{id:"jobs-search","data-testid":"sb-search-input",value:o,onChange:p=>a(p.target.value),placeholder:l("speedboat.pages.jobs.search_placeholder")})]})]}),e.jsx(cs,{statuses:r,onToggleStatus:n,onClearStatuses:t}),e.jsx(ps,{viewMode:c,onViewModeChange:s})]})}function us({columns:a,jobs:n,pagination:t,sorting:s,onSortingChange:o}){const{t:r}=g(),c=ue();return e.jsx(ze,{onRowClick:l=>c(`${Ze}/jobs/${l.original.id}`),columns:a,data:n,getRowId:l=>l.id,pageSize:E,className:"flex min-h-0 flex-1 flex-col gap-4 space-y-0",emptyMessage:r("speedboat.pages.jobs.empty.title"),sorting:s,onSortingChange:o,manualSorting:!0,containerClassName:"min-h-64 flex-1 overflow-y-auto",tableClassName:j("[&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10","[&_th:nth-child(1)]:w-[104px] [&_th:nth-child(3)]:w-[180px]","[&_th:nth-child(4)]:w-[150px] [&_th:nth-child(5)]:w-[130px]","[&_th:nth-child(6)]:w-[130px] [&_th:nth-child(7)]:w-[140px]","[&_th:nth-child(8)]:w-[220px] [&_th:nth-child(9)]:w-14"),renderPagination:()=>t})}function gs({job:a}){const{t:n}=g(),t=!!(a.startDate||a.endDate);return e.jsxs(Ke,{size:"sm",className:"min-h-[204px] gap-4 shadow-card",children:[e.jsxs(Be,{className:"!flex flex-row items-start gap-3",children:[e.jsx("div",{className:j("flex size-[38px] shrink-0 items-center justify-center rounded-lg","bg-muted text-foreground-soft"),children:e.jsx(we,{className:"size-[18px]"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(d,{variant:"body",weight:"medium",lineClamp:2,children:a.title}),a.customerName&&e.jsx(d,{as:"span",variant:"caption",tone:"muted",truncate:!0,className:"mt-0.5 block",children:a.customerName}),a.jobNumber&&e.jsxs(d,{as:"span",variant:"caption",tone:"muted",className:"mt-0.5 block font-mono",children:["#",a.jobNumber]})]}),e.jsx(se,{jobId:a.id,jobTitle:a.title})]}),e.jsxs(Oe,{className:"gap-4",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:e.jsx(ee,{statusKey:a.statusKey,statusLabel:a.statusLabel})}),e.jsx("div",{className:"h-px bg-border"})]}),e.jsx(He,{className:"mt-auto justify-between gap-4 pt-0",children:t?e.jsxs("div",{className:"min-w-0",children:[e.jsx(d,{as:"span",variant:"caption",tone:"subtle",weight:"semibold",className:"block tracking-[0.04em] uppercase",children:n("speedboat.pages.jobs.card.timeline")}),e.jsx(is,{job:a})]}):null})]})}function bs({jobs:a,pagination:n}){const{t}=g();return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[e.jsx("div",{className:"min-h-64 flex-1 overflow-y-auto",children:a.length?e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 2xl:grid-cols-4",children:a.map(s=>e.jsx(gs,{job:s},s.id))}):e.jsx(J,{kind:"empty",title:t("speedboat.pages.jobs.empty.title"),description:t("speedboat.pages.jobs.empty.description")})}),n]})}function la(){const{t:a}=g(),[n,t]=m.useState("list"),[s,o]=m.useState(""),[r,c]=m.useState([]),[l,p]=m.useState(1),b=Xe(s.trim()),{activeJobs:N,jobLimit:A,limitState:R,isPlanLoaded:I}=De(),K=m.useRef(!1);m.useEffect(()=>{K.current||!I||(K.current=!0,x("view_job_listing_page",{jobs_limit_state:R,jobs_limit:A,jobs_active:N}))},[R,A,N,I]),m.useEffect(()=>{b&&x("search_jobs",{keyword_length:b.length})},[b]);const[D,te]=m.useState([]),v=D[0],ne=(()=>
1{if(v)return v.desc?"desc":"asc"})(),oe=i=>{const y=typeof i=="function"?i(D):i;te(y),p(1);const _=y[0];_&&x("sort_jobs",{sort_by:Q[_.id],sort_direction:_.desc?"desc":"asc"})},{data:S,isError:B,isFetching:re,isLoading:k,refetch:ie}=ts({page:l,perPage:E,keyword:b||void 0,statuses:r.length>0?r:os,sortBy:v?Q[v.id]:void 0,sortDirection:ne}),f=S?.jobs??[],O=S?.meta.offset??(l-1)*E,le=m.useMemo(()=>f.filter(i=>i.statusKey!==void 0&&ae.has(i.statusKey)).map(i=>i.id),[f]),{data:H,isError:z,isLoading:M}=as(le),de=m.useMemo(()=>ls({isScoresError:z,isScoresLoading:M,scoresById:H}),[z,M,H]),ce=i=>{o(i),p(1)},pe=i=>{const y=r.includes(i)?r.filter(_=>_!==i):[...r,i];x("filter_jobs",{statuses:y}),c(y),p(1)},me=()=>{x("filter_jobs",{statuses:[]}),c([]),p(1)},F=e.jsx(Qe,{page:l,hasPrev:S?.meta.hasPrev??!1,hasNext:S?.meta.hasNext??!1,rangeStart:f.length?O+1:0,rangeEnd:O+f.length,onPageChange:i=>{x("change_jobs_page",{page:i}),p(i)},rangeEmptyLabel:a("speedboat.pages.jobs.pagination.range_empty")});return e.jsxs(We,{contentClassName:"min-h-0",children:[e.jsx(Ye,{title:a("speedboat.pages.jobs.title"),subtitle:a("speedboat.pages.jobs.description"),actions:e.jsx(L,{action:"create",asChild:!0,children:e.jsxs(Z,{to:"/jobs/new",children:[e.jsx(xe,{}),e.jsx(d,{as:"span",variant:"body",weight:"semibold",tone:"inherit",children:a("speedboat.pages.jobs.new_job")})]})})}),e.jsx(ms,{onSearchChange:ce,onToggleStatus:pe,onClearStatuses:me,onViewModeChange:i=>{x("change_jobs_view",{view:i}),t(i)},searchQuery:s,statuses:r,viewMode:n}),k&&e.jsx(J,{kind:"loading",loadingLabel:a("speedboat.pages.jobs.loading")}),!k&&B&&e.jsx(J,{kind:"error",title:a("speedboat.pages.jobs.error.title"),description:a("speedboat.pages.jobs.error.description"),retryLabel:a("speedboat.pages.jobs.error.retry"),onRetry:()=>ie()}),!k&&!B&&e.jsx("div",{className:j("flex min-h-0 flex-1 flex-col",re&&"opacity-60"),children:n==="list"?e.jsx(us,{columns:de,jobs:f,pagination:F,sorting:D,onSortingChange:oe}):e.jsx(bs,{jobs:f,pagination:F})})]})}export{la as default}; 2//# sourceMappingURL=speedboat_jobs-DaOnTM2a_bundle.js.map
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.