PageSourceSearch

https://stone-profit-flow.base44.app/assets/ServiceCasesPage-pHT0yphD.js

js stone-profit-flow.base44.app collected 2026-10-03 03:11:09 UTC 8,528 bytes, 1 lines download raw bytes

1import{a as c,u as k,d as H,j as e}from"./vendor-query-B-_nDQQY.js";import{L as S,B as O,I as o,h as d,i as m,j as u,k as x,l as a,C as T,d as L,f as M,e as j,n as Q,O as V,W,b as g}from"./index-D8ww6b7J.js";import{T as B}from"./textarea-Bhj0eADY.js";import{D as E,f as $,a as A,b as K,c as U}from"./dialog-BQWtAG_x.js";import"./tabs-DfRYzyJY.js";import"./avatar-BM2plWIe.js";import{P as Y}from"./plus-MQo5wr8n.js";import{F as z}from"./funnel-Dec4yW_G.js";import{f as G}from"./format-C2V2JF1Z.js";import{P as J}from"./PageHeader-DOQecRZi.js";import{H as X,T as Z}from"./TeamNav-BriM7U0R.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";import"./constants-yGZMfuMC.js";import"./navigation-TAQUAeuu.js";import"./hammer-Burg9xO0.js";const ee={urgent:"bg-red-500",high:"bg-orange-500",medium:"bg-amber-500",low:"bg-slate-400"},se={open:"bg-blue-500",in_progress:"bg-amber-500",waiting_customer:"bg-purple-500",resolved:"bg-emerald-500",closed:"bg-slate-400"};function ae(){const[n,P]=c.useState(""),[h,D]=c.useState("all"),[I,v]=c.useState(!1),[t,r]=c.useState({customer_name:"",customer_email:"",customer_phone:"",subject:"",description:"",type:"repair",priority:"medium"}),[f,b]=c.useState(!1),C=k(),{data:l=[],isLoading:R}=H({queryKey:["service-cases"],queryFn:()=>g.entities.ServiceCase.list("-created_date",100),refetchOnWindowFocus:!1}),F=async()=>{if(!t.customer_name||!t.subject)return;b(!0);const s=l.length+1;await g.entities.ServiceCase.create({...t,case_number:`CASE-${String(s).padStart(4,"0")}`,status:"open",activity_log:[{action:"created",by_name:"System",timestamp:new Date().toISOString(),note:"Case created"}]}),v(!1),r({customer_name:"",customer_email:"",customer_phone:"",subject:"",description:"",type:"repair",priority:"medium"}),b(!1),C.invalidateQueries({queryKey:["service-cases"]})},q=async(s,i)=>{const p=[...s.activity_log||[],{action:"status_change",by_name:"Team",timestamp:new Date().toISOString(),note:`Status changed to ${i.replace("_"," ")}`}];await g.entities.ServiceCase.update(s.id,{status:i,activity_log:p}),C.invalidateQueries({queryKey:["service-cases"]})},N=l.filter(s=>{var y,w,_;const i=!n||((y=s.customer_name)==null?void 0:y.toLowerCase().includes(n.toLowerCase()))||((w=s.case_number)==null?void 0:w.toLowerCase().includes(n.toLowerCase()))||((_=s.subject)==null?void 0:_.toLowerCase().includes(n.toLowerCase())),p=h==="all"||s.status===h;return i&&p});return R?e.jsx("div",{className:"flex justify-center py-16",children:e.jsx(S,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Service Cases"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track warranty claims, repairs, and customer issues"})]}),e.jsxs(E,{open:I,onOpenChange:v,children:[e.jsx($,{asChild:!0,children:e.jsxs(O,{className:"gap-2",children:[e.jsx(Y,{className:"w-4 h-4"})," New Case"]})}),e.jsxs(A,{className:"sm:max-w-lg",children:[e.jsx(K,{children:e.jsx(U,{children:"Create Service Case"})}),e.jsxs("div",{className:"space-y-3 py-4",children:[e.jsx(o,{placeholder:"Customer name *",value:t.customer_name,onChange:s=>r({...t,customer_name:s.target.value})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(o,{placeholder:"Email",value:t.customer_email,onChange:s=>r({...t,customer_email:s.target.value})}),e.jsx(o,{placeholder:"Phone",value:t.customer_phone,onChange:s=>r({...t,customer_phone:s.target.value})})]}),e.jsx(o,{placeholder:"Subject *",value:t.subject,onChange:s=>r({...t,subject:s.target.value})}),e.jsx(B,{placeholder:"Description",value:t.description,onChange:s=>r({...t,description:s.target.value})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(d,{value:t.type,onValueChange:s=>r({...t,type:s}),children:[e.jsx(m,{children:e.jsx(u,{})}),e.jsxs(x,{children:[e.jsx(a,{value:"warranty",children:"Warranty"}),e.jsx(a,{value:"repair",children:"Repair"}),e.jsx(a,{value:"complaint",children:"Complaint"}),e.jsx(a,{value:"question",children:"Question"}),e.jsx(a,{value:"follow_up",children:"Follow-up"}),e.jsx(a,{value:"other",children:"Other"})]})]}),e.jsxs(d,{value:t.priority,onValueChange:s=>r({...t,priority:s}),children:[e.jsx(m,{children:e.jsx(u,{})}),e.jsxs(x,{children:[e.jsx(a,{value:"low",children:"Low"}),e.jsx(a,{value:"medium",children:"Medium"}),e.jsx(a,{value:"high",children:"High"}),e.jsx(a,{value:"urgent",children:"Urgent"})]})]})]}),e.jsx(O,{onClick:F,disabled:f||!t.customer_name||!t.subject,className:"w-full",children:f?e.jsx(S,{className:"w-4 h-4 animate-spin"}):"Create Case"})]})]})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{label:"Open",count:l.filter(s=>s.status==="open").length,color:"text-blue-500"},{label:"In Progress",count:l.filter(s=>s.status==="in_progress").length,color:"text-amber-500"},{label:"Resolved",count:l.filter(s=>s.status==="resolved").length,color:"text-emerald-500"},{label:"Total",count:l.length,color:"text-slate-500"}].map(s=>e.jsx(T,{children:e.jsxs(L,{className:"pt-4 pb-4 text-center",children:[e.jsx("p",{className:`text-2xl font-bold ${s.color}`,children:s.count}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s.label})]})},s.label))}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(M,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(o,{placeholder:"Search by customer or case number...",value:n,onChange:s=>P(s.target.value),className:"pl-10"})]}),e.jsxs(d,{value:h,onValueChange:D,children:[e.jsxs(m,{className:"w-40",children:[e.jsx(z,{className:"w-3.5 h-3.5 mr-1"})," ",e.jsx(u,{})]}),e.jsxs(x,{children:[e.jsx(a,{value:"all",children:"All Status"}),e.jsx(a,{value:"open",children:"Open"}),e.jsx(a,{value:"in_progress",children:"In Progress"}),e.jsx(a,{value:"waiting_customer",children:"Waiting"}),e.jsx(a,{value:"resolved",children:"Resolved"}),e.jsx(a,{value:"closed",children:"Closed"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[N.map(s=>e.jsx(T,{className:"hover:shadow-md transition-shadow",children:e.jsx(L,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`w-2 h-2 rounded-full mt-2 ${se[s.status]||"bg-slate-400"}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs font-mono text-muted-foreground",children:s.case_number}),e.jsx(j,{className:ee[s.priority]+" text-white text-[10px]",children:s.priority}),e.jsx(j,{variant:"secondary",className:"text-[10px]",children:s.type.replace("_"," ")})]}
1),e.jsx("p",{className:"font-medium mt-1",children:s.subject}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.customer_name}),s.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:s.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 pt-2 border-t text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Q,{className:"w-3 h-3"})," ",G(new Date(s.created_date),"MMM d")]}),e.jsxs(d,{value:s.status,onValueChange:i=>q(s,i),children:[e.jsx(m,{className:"h-6 text-[10px] w-32 border-0 bg-muted px-2",children:e.jsx(u,{})}),e.jsxs(x,{children:[e.jsx(a,{value:"open",children:"Open"}),e.jsx(a,{value:"in_progress",children:"In Progress"}),e.jsx(a,{value:"waiting_customer",children:"Waiting Customer"}),e.jsx(a,{value:"resolved",children:"Resolved"}),e.jsx(a,{value:"closed",children:"Closed"})]})]}),s.related_job_label&&e.jsxs(j,{variant:"outline",className:"text-[10px]",children:[e.jsx(V,{className:"w-2.5 h-2.5 mr-0.5"}),s.related_job_label]})]})]})]})})},s.id)),N.length===0&&e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(W,{className:"w-10 h-10 mx-auto mb-3 opacity-20"}),e.jsx("p",{className:"text-sm",children:"No cases found"})]})]})]})}function Ne(){return e.jsxs("div",{className:"p-3 sm:p-6 space-y-4",children:[e.jsx(J,{icon:X,title:"Service Cases",subtitle:"Track and resolve customer service issues"}),e.jsx(Z,{currentPath:"/service-cases"}),e.jsx(ae,{})]})}export{Ne 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.