PageSourceSearch

https://stone-profit-flow.base44.app/assets/ProductionWorkflow-CdPSyNKg.js

js stone-profit-flow.base44.app collected 2026-10-03 03:10:42 UTC 17,928 bytes, 1 lines download raw bytes

1import{j as e,a as _,u as Y,d as F,e as Z}from"./vendor-query-B-_nDQQY.js";import{C as I,d as T,e as b,h as q,i as S,j as P,k,l as d,B as K,a as O,ah as ee,_ as se,r as te,m as ae,U as B,n as M,c as le,R as ne,s as Q,f as ie,I as re,b as w}from"./index-D8ww6b7J.js";import{R as de}from"./ruler-Bcj6zKuq.js";import{F as ce}from"./file-image-sDRH1efz.js";import{S as oe}from"./scan-line-pHKVaVqS.js";import{U as D}from"./user-CHo1Apvy.js";import{A as me}from"./arrow-right-BeikyhzV.js";import{C as R}from"./circle-check-big-4Ew-rpqG.js";import{L as xe}from"./layout-list-DTPf8B3H.js";import"./vendor-three-1K-S22da.js";import"./vendor-charts-i-522T5A.js";import"./vendor-react-BUIlT3ms.js";import"./vendor-pdf-Bwkk3Ew0.js";import"./vendor-radix-X0WMATEu.js";function ue({piece:s,employees:g,onStageChange:m,onAssignEmployee:p}){const c={template:"Template",cnc_programming:"CNC Program",cutting:"Cutting",polishing:"Polishing",qc_pending:"QC Pending",qc_passed:"QC Passed",ready_for_install:"Ready"},N={template:"bg-slate-100 text-slate-700 border-slate-300",cnc_programming:"bg-blue-100 text-blue-700 border-blue-300",cutting:"bg-orange-100 text-orange-700 border-orange-300",polishing:"bg-yellow-100 text-yellow-700 border-yellow-300",qc_pending:"bg-purple-100 text-purple-700 border-purple-300",qc_passed:"bg-green-100 text-green-700 border-green-300",ready_for_install:"bg-emerald-100 text-emerald-700 border-emerald-300"},l=["template","cnc_programming","cutting","polishing","qc_pending","qc_passed","ready_for_install"],o=l.indexOf(s.status),r=o<l.length-1,x=()=>{if(r){const n=l[o+1];m(s.id,n)}},i=n=>n?new Date(n).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):null;return e.jsx(I,{className:"border-2 hover:shadow-md transition-all",children:e.jsx(T,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b,{className:"font-semibold",children:s.piece_number}),e.jsx("h4",{className:"font-medium",children:s.piece_name}),s.room&&e.jsx(b,{variant:"outline",className:"text-xs",children:s.room})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(de,{className:"w-3 h-3"}),e.jsxs("span",{children:[s.length,'" × ',s.width,'"']})]}),e.jsx("div",{className:"flex items-center gap-2 text-muted-foreground",children:e.jsx("span",{className:"font-medium",children:s.material_type})}),s.drawing_image_url&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ce,{className:"w-3 h-3"}),e.jsxs("span",{children:["Page ",s.drawing_page_number]})]}),s.barcode&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(oe,{className:"w-3 h-3"}),e.jsx("span",{className:"font-mono text-xs",children:s.barcode})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-4 text-xs",children:[s.cutting_employee_name&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(D,{className:"w-3 h-3 text-orange-600"}),e.jsx("span",{className:"text-muted-foreground",children:"Cut:"}),e.jsx("span",{className:"font-medium",children:s.cutting_employee_name}),s.cutting_completed_at&&e.jsxs("span",{className:"text-muted-foreground",children:["(",i(s.cutting_completed_at),")"]})]}),s.polishing_employee_name&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(D,{className:"w-3 h-3 text-yellow-600"}),e.jsx("span",{className:"text-muted-foreground",children:"Polish:"}),e.jsx("span",{className:"font-medium",children:s.polishing_employee_name}),s.polishing_completed_at&&e.jsxs("span",{className:"text-muted-foreground",children:["(",i(s.polishing_completed_at),")"]})]}),s.qc_employee_name&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(D,{className:"w-3 h-3 text-purple-600"}),e.jsx("span",{className:"text-muted-foreground",children:"QC:"}),e.jsx("span",{className:"font-medium",children:s.qc_employee_name})]})]})]}),e.jsxs("div",{className:"flex flex-col items-center gap-2 min-w-[180px]",children:[e.jsx(b,{className:N[s.status],variant:"outline",children:c[s.status]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(q,{value:s.status,onValueChange:n=>m(s.id,n),children:[e.jsx(S,{className:"w-36 text-xs",children:e.jsx(P,{})}),e.jsx(k,{children:l.map(n=>e.jsx(d,{value:n,children:c[n]},n))})]}),r&&e.jsxs(K,{size:"sm",onClick:x,className:"h-8",children:[e.jsx(me,{className:"w-3 h-3 mr-1"}),"Advance"]})]}),e.jsx("div",{className:"w-full",children:e.jsxs(q,{value:s.status==="cutting"?s.cutting_employee_id:s.status==="polishing"?s.polishing_employee_id:s.status==="qc_pending"?s.qc_employee_id:"",onValueChange:n=>p(s.id,s.status,n),children:[e.jsx(S,{className:"w-full text-xs h-7",children:e.jsx(P,{placeholder:"Assign employee"})}),e.jsx(k,{children:g.map(n=>e.jsx(d,{value:n.id,children:n.name},n.id))})]})})]})]})})})}function he({job:s,pieces:g,employees:m,isExpanded:p,onToggleExpand:c,onStageChange:N,onAssignEmployee:l,statusCounts:o}){const r=g.length,x=g.filter(j=>["qc_passed","ready_for_install"].includes(j.status)).length,i=r>0?Math.round(x/r*100):0,n={template:"bg-slate-100 text-slate-700",cnc_programming:"bg-blue-100 text-blue-700",cutting:"bg-orange-100 text-orange-700",polishing:"bg-yellow-100 text-yellow-700",qc_pending:"bg-purple-100 text-purple-700",qc_passed:"bg-green-100 text-green-700",ready_for_install:"bg-emerald-100 text-emerald-700"};return e.jsxs(I,{className:"hover:shadow-md transition-shadow",children:[e.jsxs(O,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:c,className:"p-1",children:p?e.jsx(ee,{className:"w-5 h-5"}):e.jsx(se,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:s.customer_name}),s.job_date&&e.jsxs(b,{variant:"outline",className:"flex items-center gap-1",children:[e.jsx(te,{className:"w-3 h-3"}),new Date(s.job_date).toLocaleDateString()]}),s.job_address&&e.jsxs(b,{variant:"outline",className:"flex items-center gap-1",children:[e.jsx(ae,{className:"w-3 h-3"}),s.job_address.split(",")[0]]})]}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-sm text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(B,{className:"w-3 h-3"}),r," piece",r!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(R,{className:"w-3 h-3"}),x," complete"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(M,{className:"w-3 h-3"}),i,"% progress"]})]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:Object.entries(o).map(([j,L])=>e.jsx(b,{className:n[j]||"bg-gray-100 text-gray-700",children:L},j))})]}),e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground mb-1",children:[e.jsx("span",{children:"Production Progress"}),e.jsxs("span",{children:[x,"/",r," pieces"]})]}),e.jsx("div",{className:"w-full h-2 bg-secondary rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary transition-all duration-300",style:{width:`${i}%`}})})]})]}),p&&e.jsx(T,{children:e.jsx("div",{className:"space-y-3",children:g.map(j=>e.jsx(ue,{piece:j,employees:m,onStageChange:N,onAssignEmployee:l},j.id))})})]})}function ge({pieces:s,employees:g,activities:m}){const p=new Date().toISOString().split("T")[0],c=m.filter(l=>{var r;return((r=l.scheduled_date)==null?void 0:r.split("T")[0])===p}),N=g.map(l=>{const o=s.filter(i=>i.cutting_employee_id===l.id&&!i.cutting_completed_at),r=s.filter(i=>i.polishing_employee_id===l.id&&!i.polishing_completed_at),x=s.filter(i=>i.qc_employee_id===l.id&&i.status==="qc_pending");return{employee:l,cutting:o.length,polishing:r.length,qc:x.length,total:o.length+r.length+x.length}}).sort((l,o)=>o.total-l.total);return e.jsxs(I,{className:"sticky top-6",children:[e.jsx(O,{children:e.jsxs(le,{className:"flex items-center gap-2",children:[e.jsx(B,{className:"w-5 h-5"}),"Employee Workload"]})}),e.jsxs(T,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold mb-2",children:"Today's Schedule"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(M,{className:"w-4 h-4 text-muted-foreground"}),e.jsxs("span",{children:[c.length," activities scheduled"]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold mb-2",children:"Current Workload"}),e.jsx("div",{className:"space-y-3",children:N.map(({employee:l,cutting:o,polishing:r,qc:x,total:i})=>e.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"font-medium text-sm",children:l.name}),e.jsxs(b,{variant:i>3?"destructive":"secondary",children:[i," tasks"]})]}),e.jsxs("div",{className:"space-y-1 text-xs text-muted-foreground",children:[o>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-orange-500"}),e.jsxs("span",{children:["Cutting: ",o]})]}),r>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-yellow-500"}),e.jsxs("span",{children:["Polishing: ",r]})]}),x>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-purple-500"}),e.jsxs("span",{children:["QC: ",x]})]}),i===0&&e.jsxs("div",{className:"flex items-center gap-2 text-green-600",children:[e.jsx(R,{className:"w-3 h-3"}),e.jsx("span",{children:"No pending tasks"})]})]})]},l.id))})]}),e.jsx("div",{className:"pt-4 border-t",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"text-center p-2 bg-muted rounded",children:[e.jsx("div",{className:"text-2xl font-bold",children:s.filter(l=>l.status==="cutting").length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"In Cutting"})]}),e.jsxs("div",{className:"text-center p-2 bg-muted rounded",children:[e.jsx("div",{className:"text-2xl font-bold",children:s.filter(l=>l.status==="polishing").length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"In Polishing"})]}),e.jsxs("div",{className:"text-center p-2 bg-muted rounded",children:[e.jsx("div",{className:"text-2xl font-bold",children:s.filter(l=>l.status==="qc_pending").length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"QC Pending"})]}),e.jsxs("div",{className:"text-center p-2 bg-muted rounded",children:[e.jsx("div",{className:"text-2xl font-bold",children:s.filter(l=>l.status==="ready_for_install").length}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Ready"})]})]})})]})]})}function Ae(){const[s,g]=_.useState(""),[m,p]=_.useState("all"),[c,N]=_.useState("all"),[l,o]=_.useState("by-job"),[r,x]=_.useState({}),i=Y(),{data:n=[],isLoading:j}=F({queryKey:["production-pieces"],queryFn:()=>w.entities.ProductionPiece.list(),refetchInterval:15e3}),{data:L=[],isLoading:W}=F({queryKey:["jobs"],queryFn:()=>w.entities.Job.list(),refetchInterval:15e3}),{data:E=[],isLoading:U}=F({queryKey:["employees"],queryFn:()=>w.entities.Employee.list()}),{data:z=[],isLoading:pe}=F({queryKey:["scheduledActivities"],queryFn:()=>w.entities.ScheduledActivity.list(),refetchInterval:15e3}),J=Z({mutationFn:({id:t,data:a})=>w.entities.ProductionPiece.update(t,a),onSuccess:()=>{i.invalidateQueries({queryKey:["production-pieces"]}),i.invalidateQueries({queryKey:["jobs"]}),i.invalidateQueries({queryKey:["scheduledActivities"]})}}),$=(t,a)=>{const u={status:a};a==="cutting_complete"?u.cutting_completed_at=new Date().toISOString():a==="polishing_complete"?u.polishing_completed_at=new Date().toISOString():(a==="qc_passed"||a==="qc_failed")&&(u.qc_completed_at=new Date().toISOString()),J.mutate({id:t,data:u})},H=(t,a,u)=>{const h=E.find(v=>v.id===u),f={};a==="cutting"||a==="cutting_complete"?(f.cutting_employee_id=u,f.cutting_employee_name=(h==null?void 0:h.name)||""):a==="polishing"||a==="polishing_complete"?(f.polishing_employee_id=u,f.polishing_employee_name=(h==null?void 0:h.name)||""):(a==="qc_pending"||a==="qc_passed"||a==="qc_failed")&&(f.qc_employee_id=u,f.qc_employee_name=(h==null?void 0:h.name)||""),J.mutate({id:t,data:f})},G=t=>{x(a=>({...a,[t]:!a[t]}))},A=_.useMemo(()=>{const t={};
1return n.forEach(a=>{t[a.job_id]||(t[a.job_id]=[]),t[a.job_id].push(a)}),t},[n]),X=t=>{const a={};return t.forEach(u=>{a[u.status]=(a[u.status]||0)+1}),a},V=_.useMemo(()=>L.filter(t=>{var h;const a=A[t.id]||[];return!(!(t.customer_name.toLowerCase().includes(s.toLowerCase())||((h=t.job_address)==null?void 0:h.toLowerCase().includes(s.toLowerCase())))||m!=="all"&&!a.some(v=>v.status===m)||c!=="all"&&!a.some(v=>v.cutting_employee_id===c||v.polishing_employee_id===c||v.qc_employee_id===c))}),[L,A,s,m,c]);if(j||W||U)return e.jsx("div",{className:"flex items-center justify-center h-screen",children:e.jsx("div",{className:"w-8 h-8 border-4 border-slate-200 border-t-slate-800 rounded-full animate-spin"})});const y={total:n.length,pending:n.filter(t=>t.status==="pending").length,in_progress:n.filter(t=>["cutting","polishing","qc_pending"].includes(t.status)).length,complete:n.filter(t=>["qc_passed","ready_for_install"].includes(t.status)).length,failed:n.filter(t=>t.status==="qc_failed").length};return e.jsxs("div",{className:"p-3 sm:p-6 space-y-3 sm:space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between flex-wrap gap-3",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:"Production Workflow"}),e.jsx("p",{className:"text-xs sm:text-sm text-muted-foreground",children:"Manage fabrication from template to installation"})]})}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-5 gap-2 sm:gap-4",children:[e.jsx(C,{stat:"Total",value:y.total,icon:ne,color:"blue"}),e.jsx(C,{stat:"Pending",value:y.pending,icon:M,color:"slate"}),e.jsx(C,{stat:"In Progress",value:y.in_progress,icon:Q,color:"amber"}),e.jsx(C,{stat:"Complete",value:y.complete,icon:R,color:"green"}),e.jsx(C,{stat:"Failed",value:y.failed,icon:Q,color:"red"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 sm:gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(ie,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(re,{placeholder:"Search by customer or address...",value:s,onChange:t=>g(t.target.value),className:"pl-10 h-10"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(q,{value:m,onValueChange:p,children:[e.jsx(S,{className:"w-full sm:w-[150px] h-10",children:e.jsx(P,{placeholder:"Status"})}),e.jsxs(k,{children:[e.jsx(d,{value:"all",children:"All Status"}),e.jsx(d,{value:"pending",children:"Pending"}),e.jsx(d,{value:"cutting",children:"Cutting"}),e.jsx(d,{value:"cutting_complete",children:"Cutting Complete"}),e.jsx(d,{value:"polishing",children:"Polishing"}),e.jsx(d,{value:"polishing_complete",children:"Polishing Complete"}),e.jsx(d,{value:"qc_pending",children:"QC Pending"}),e.jsx(d,{value:"qc_passed",children:"QC Passed"}),e.jsx(d,{value:"qc_failed",children:"QC Failed"}),e.jsx(d,{value:"ready_for_install",children:"Ready for Install"})]})]}),e.jsxs(q,{value:c,onValueChange:N,children:[e.jsxs(S,{className:"w-full sm:w-[150px] h-10",children:[e.jsx(B,{className:"w-4 h-4 mr-2"}),e.jsx(P,{placeholder:"Employee"})]}),e.jsxs(k,{children:[e.jsx(d,{value:"all",children:"All Employees"}),E.map(t=>e.jsx(d,{value:t.id,children:t.name},t.id))]})]}),e.jsxs(q,{value:l,onValueChange:o,children:[e.jsxs(S,{className:"w-full sm:w-[150px] h-10",children:[e.jsx(xe,{className:"w-4 h-4 mr-2"}),e.jsx(P,{placeholder:"View"})]}),e.jsxs(k,{children:[e.jsx(d,{value:"by-job",children:"By Job"}),e.jsx(d,{value:"by-stage",children:"By Stage"}),e.jsx(d,{value:"by-employee",children:"By Employee"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-4 sm:gap-6",children:[e.jsx("div",{className:"lg:col-span-3",children:V.length===0?e.jsxs("div",{className:"text-center py-12 sm:py-16 text-muted-foreground border-2 border-dashed rounded-xl",children:[e.jsx(Q,{className:"w-10 h-10 sm:w-12 sm:h-12 mx-auto mb-3 sm:mb-4 opacity-40"}),e.jsx("p",{className:"font-medium mb-1 text-sm sm:text-base",children:"No jobs found"}),e.jsx("p",{className:"text-xs sm:text-sm",children:"No production jobs match your current filters."})]}):e.jsx("div",{className:"space-y-3 sm:space-y-4",children:V.map(t=>e.jsx(he,{job:t,pieces:A[t.id]||[],employees:E,isExpanded:r[t.id]||!1,onToggleExpand:()=>G(t.id),onStageChange:$,onAssignEmployee:H,statusCounts:X(A[t.id]||[])},t.id))})}),e.jsx("div",{className:"hidden lg:block lg:col-span-1",children:e.jsx(ge,{pieces:n,employees:E,activities:z})})]})]})}function C({stat:s,value:g,icon:m,color:p}){const c={blue:"bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-400",slate:"bg-slate-50 text-slate-700 dark:bg-slate-900/20 dark:text-slate-400",amber:"bg-amber-50 text-amber-700 dark:bg-amber-900/20 dark:text-amber-400",green:"bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-400",red:"bg-red-50 text-red-700 dark:bg-red-900/20 dark:text-red-400"};
1return e.jsx("div",{className:`p-2 sm:p-4 rounded-lg border ${c[p]}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs sm:text-sm font-medium",children:s}),e.jsx("p",{className:"text-lg sm:text-2xl font-bold",children:g})]}),e.jsx(m,{className:"w-5 h-5 sm:w-8 sm:h-8 opacity-50"})]})})}export{Ae 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.