1import{j as e}from"./vendor-query-ENmfDhBq.js";import{r as f,h as be,e as we}from"./vendor-react-Cmo9WzyS.js";import{C as S,f as W,g as V,B as n,L as b,I as ue,i as _,d,l as J,e as xe,b as Ce,S as De}from"./index-CznMJwf7.js";import{B as Z}from"./badge-D-GfAQVU.js";import{S as ee}from"./skeleton-CLOVS70K.js";import{T as Q}from"./textarea-CgE0Hb_n.js";import{S as P,a as O,b as F,c as U,d as k}from"./select-CRKHhgwN.js";import{D as te,e as re,a as ie,c as ne,b as le,f as ce,d as de}from"./dialog-BdhnzXUn.js";import{u as Y,f as Se,g as _e,a as Ie,d as he,P as pe,S as je,e as Ae}from"./SLATimer-L7K2ROsu.js";import{A as qe,a as Re,b as ke,c as Te,d as Pe,e as Oe,f as Fe,g as Ue}from"./alert-dialog-CRTfzClU.js";import{u as Me}from"./useTeamMembers-DQxDVI9M.js";import{E as Le}from"./EntityUpdatesPanel-Bv5GBxz5.js";import{$ as ye,P as Ee,aj as oe,L as ze,U as We,cX as Ve,o as Ne,a as $e,D as Be,b5 as se,K as He,M as Qe,O as Ye,A as Ge,cP as Xe,C as ge,aO as Ke,X as Je,at as Ze,Q as es,B as ss,aa as fe,ae as as,a0 as ts}from"./vendor-ui-DI8clteo.js";import{I as rs}from"./image-viewer-dialog-BA-fuwAQ.js";import{d as is}from"./storageFiles-DGNFiNvN.js";import{o as ns}from"./imageOptimize-025OWTwn.js";import{a as ae}from"./format-fTIrYzIB.js";import{d as ls}from"./differenceInHours-DwAy5T5E.js";import"./vendor-pdf-CnsmIwn4.js";import"./vendor-radix-OnsNJ2sB.js";import"./vendor-supabase-INnzmioh.js";import"./vendor-charts-CNk8afJ_.js";import"./vendor-auth-Ftfj713I.js";import"./differenceInMinutes-BxOusk35.js";import"./differenceInMilliseconds-hzrVw4lV.js";import"./en-US-DNi5-IO7.js";import"./checkbox-C9WExSsm.js";import"./MentionInput-BjBS-vWf.js";import"./avatar-CVK7Zzds.js";import"./dropdown-menu-BMt4_Rju.js";import"./attachment-gallery-Df-IcpGg.js";import"./fileTypes-BSaqUDb3.js";import"./vendor-xlsx-D0Y3NUfP.js";
1import"./useFileViewer-Ch5G2IEC.js";import"./react-CNmCGiw2.js";import"./popover-BTpQwQxN.js";import"./formatDistanceToNow-CzwL-M4D.js";import"./constructNow-_pvTjsCy.js";import"./differenceInCalendarMonths-DKVg4QLa.js";import"./endOfDay-g9o8G-gE.js";import"./endOfMonth-Bgn270oE.js";import"./startOfDay-DJ_G3h2O.js";function cs({requestId:w,items:c=[],isEditing:s}){const[v,y]=f.useState(!1),[o,x]=f.useState({product_name:"",quantity:1,issue_description:""}),l=Y(),h=async()=>{if(!o.product_name){d.error("Please enter a product name");return}const i=[...c,{...o,id:crypto.randomUUID()}];try{await l.mutateAsync({id:w,items:i}),d.success("Item added"),y(!1),x({product_name:"",quantity:1,issue_description:""})}catch(p){d.error("Failed to add item: "+p.message)}},N=async i=>{const p=c.filter(r=>r.id!==i);try{await l.mutateAsync({id:w,items:p}),d.success("Item removed")}catch(r){d.error("Failed to remove item: "+r.message)}};return e.jsxs(S,{children:[e.jsxs(W,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(V,{className:"text-base",children:"Related Items / ç¸å
³äº§å"}),s&&e.jsxs(te,{open:v,onOpenChange:y,children:[e.jsx(re,{asChild:!0,children:e.jsxs(n,{variant:"outline",size:"sm",children:[e.jsx(ye,{className:"mr-1 h-4 w-4"}),"Add Item"]})}),e.jsxs(ie,{children:[e.jsxs(ne,{children:[e.jsx(le,{children:"Add Service Item"}),e.jsx(ce,{children:"Add a product related to this service request"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Product Name / 产ååç§° *"}),e.jsx(ue,{value:o.product_name,onChange:i=>x({...o,product_name:i.target.value}),placeholder:"Enter product name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Quantity / æ°é"}),e.jsx(ue,{type:"number",min:1,value:o.quantity,onChange:i=>x({...o,quantity:parseInt(i.target.value)||1})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Issue Description / é®é¢æè¿°"}),e.jsx(Q,{value:o.issue_description,onChange:i=>x({...o,issue_description:i.target.value}),placeholder:"Describe the issue with this product",rows:3})]})]}),e.jsxs(de,{children:[e.jsx(n,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e.jsx(n,{onClick:h,disabled:l.isPending,children:"Add Item"})]})]})]})]}),e.jsx(_,{children:c.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-6 text-muted-foreground",children:[e.jsx(Ee,{className:"h-8 w-8 mb-2"}),e.jsx("p",{className:"text-sm",children:"No items added yet"})]}):e.jsx("div",{className:"space-y-3",children:c.map(i=>e.jsxs("div",{className:"flex items-start justify-between p-3 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-medium",children:i.product_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Qty: ",i.quantity]}),i.issue_description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:i.issue_description})]}),s&&e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>N(i.id),children:e.jsx(oe,{className:"h-4 w-4"})})]},i.id))})})]})}function ds({requestId:w,attachments:c=[],isEditing:s}){var A,T;const[v,y]=f.useState(!1),[o,x]=f.useState(!1),[l,h]=f.useState(!1),[N,i]=f.useState(0),p=f.useRef(null),r=Y(),u=c.filter(t=>t.type.startsWith("image/")),C=async t=>{if(t.length===0)return;y(!0);const g=[...c];try{for(const m of t){let D=m;if(m.type.startsWith("image/"))try{D=(await ns(m,{maxSide:2400,minShortSide:900,quality:.92})).file}catch(R){const z=String((R==null?void 0:R.message)||"");if(z.startsWith("LOW_RES:")){const a=z.replace("LOW_RES:","");if(!window.confirm(`This image is low resolution (${a}) and may look blurry in full view. Upload anyway?`))continue}else throw R}const B=D.type.startsWith("image/")?m.name.replace(/\.[^/.]+$/,"")+".webp":m.name,L=`${w}/${Date.now()}-${B}`,{error:E}=await xe.storage.from("product-photos").upload(L,D,{contentType:D.type});if(E)throw E;const{data:H}=xe.storage.from("product-photos").getPublicUrl(L);g.push({id:crypto.randomUUID(),name:m.name,url:H.publicUrl,type:D.type,uploaded_at:new Date().toISOString()})}await r.mutateAsync({id:w,attachments:g}),d.success(`${t.length} file(s) uploaded`)}catch(m){d.error("Upload failed: "+m.message)}finally{y(!1),p.current&&(p.current.value="")}},M=async t=>{const g=t.target.files;!g||g.length===0||await C(Array.from(g))},j=t=>{t.preventDefault(),t.stopPropagation(),s&&!v&&x(!0)},q=t=>{t.preventDefault(),t.stopPropagation(),x(!1)},G=t=>{t.preventDefault(),t.stopPropagation()},X=async t=>{if(t.preventDefault(),t.stopPropagation(),x(!1),!s||v)return;const g=Array.from(t.dataTransfer.files);g.length>0&&await C(g)},K=async t=>{const g=c.filter(m=>m.id!==t);try{await r.mutateAsync({id:w,attachments:g}),d.success("Attachment removed")}catch(m){d.error("Failed to remove attachment: "+m.message)}},$=t=>
1{i(t),h(!0)},I=t=>t.startsWith("image/");return e.jsxs(e.Fragment,{children:[e.jsxs(S,{onDragEnter:j,onDragLeave:q,onDragOver:G,onDrop:X,className:J("transition-colors",o&&s&&"ring-2 ring-primary ring-offset-2"),children:[e.jsxs(W,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(V,{className:"text-base",children:"Attachments / éä»¶"}),s&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"file",ref:p,onChange:M,className:"hidden",multiple:!0,accept:"image/*,.pdf,.doc,.docx,.xls,.xlsx"}),e.jsxs(n,{variant:"outline",size:"sm",onClick:()=>{var t;return(t=p.current)==null?void 0:t.click()},disabled:v,children:[v?e.jsx(ze,{className:"mr-1 h-4 w-4 animate-spin"}):e.jsx(We,{className:"mr-1 h-4 w-4"}),"Upload"]})]})]}),e.jsx(_,{children:c.length===0?e.jsxs("div",{className:J("flex flex-col items-center justify-center py-6 text-muted-foreground rounded-lg border-2 border-dashed transition-colors",o&&s?"border-primary bg-primary/5":"border-transparent"),children:[e.jsx(Ve,{className:"h-8 w-8 mb-2"}),e.jsx("p",{className:"text-sm",children:o?"Drop files here":s?"Drop files or click Upload":"No attachments yet"})]}):e.jsx("div",{className:J("grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3 p-2 rounded-lg border-2 border-dashed transition-colors",o&&s?"border-primary bg-primary/5":"border-transparent"),children:c.map((t,g)=>{const m=u.findIndex(D=>D.id===t.id);return e.jsxs("div",{className:"relative group border rounded-lg overflow-hidden",children:[I(t.type)?e.jsx("img",{src:t.url,alt:t.name,className:"w-full h-20 object-cover cursor-pointer",onClick:()=>$(m)}):e.jsx("div",{className:"w-full h-20 flex items-center justify-center bg-muted",children:e.jsx(Ne,{className:"h-8 w-8 text-muted-foreground"})}),e.jsxs("div",{className:"absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",children:[I(t.type)&&e.jsx(n,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:()=>$(m),title:"View",children:e.jsx($e,{className:"h-4 w-4"})}),e.jsx(n,{variant:"secondary",size:"icon",className:"h-8 w-8",onClick:()=>is(t.url,t.name),title:"Download",children:e.jsx(Be,{className:"h-4 w-4"})}),s&&e.jsx(n,{variant:"destructive",size:"icon",className:"h-8 w-8",onClick:()=>K(t.id),children:e.jsx(oe,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"text-xs p-1 truncate bg-background",children:t.name})]},t.id)})})})]}),e.jsx(rs,{imageUrl:((A=u[N])==null?void 0:A.url)||null,onClose:()=>h(!1),alt:(T=u[N])==null?void 0:T.name,images:u.map(t=>({url:t.url,name:t.name})),currentIndex:N,onNavigate:i,open:l})]})}const ve=[{value:"call",label:"Phone Call",icon:He},{value:"email",label:"Email",icon:Qe},{value:"whatsapp",label:"WhatsApp",icon:se},{value:"wechat",label:"WeChat",icon:Ye}];function os({requestId:w,attachments:c=[]}){const{user:s,profile:v}=Ce(),y=Y(),[o,x]=f.useState(!1),[l,h]=f.useState({type:"call",direction:"outbound",summary:""}),N=(c||[]).filter(r=>r.type==="communication").sort((r,u)=>new Date(u.created_at).getTime()-new Date(r.created_at).getTime()),i=async()=>{if(!l.summary){d.error("Please provide a summary");return}const r={id:crypto.randomUUID(),type:l.type,direction:l.direction,summary:l.summary,created_by:(s==null?void 0:s.id)||"",created_by_name:(v==null?void 0:v.display_name)||"Unknown",created_at:new Date().toISOString()},u=[...c,{...r,type:"communication"}];try{await y.mutateAsync({id:w,attachments:u}),d.success("Communication logged"),x(!1),h({type:"call",direction:"outbound",summary:""})}catch(C){d.error("Failed to log communication: "+C.message)}},p=r=>{const u=ve.find(M=>M.value===r),C=(u==null?void 0:u.icon)||se;return e.jsx(C,{className:"h-4 w-4"})};return e.jsxs(S,{children:[e.jsxs(W,{className:"flex flex-row items-center justify-between pb-2",children:[e.jsx(V,{className:"text-base",children:"Communication Log / æ²éè®°å½"}),e.jsxs(te,{open:o,onOpenChange:x,children:[e.jsx(re,{asChild:!0,children:e.jsxs(n,{variant:"outline",size:"sm",children:[e.jsx(ye,{className:"mr-1 h-4 w-4"}),"Log"]})}),e.jsxs(ie,{children:[e.jsxs(ne,{children:[e.jsx(le,{children:"Log Communication"}),e.jsx(ce,{children:"Record a call, email, or message with the customer"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Type"}),e.jsxs(P,{value:l.type,onValueChange:r=>h({...l,type:r}),children:[e.jsx(O,{children:e.jsx(F,{})}),e.jsx(U,{children:ve.map(r=>e.jsx(k,{value:r.value,children:r.label},r.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Direction"}),e.jsxs(P,{value:l.direction,onValueChange:r=>h({...l,direction:r}),children:[e.jsx(O,{children:e.jsx(F,{})}),e.jsxs(U,{children:[e.jsx(k,{value:"inbound",children:"Inbound (Customer)"}),e.jsx(k,{value:"outbound",children:"Outbound (We)"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Summary / æè¦ *"}),e.jsx(Q,{value:l.summary,onChange:r=>h({...l,summary:r.target.value}),placeholder:"What was discussed?",rows:4})]})]}),e.jsxs(de,{children:[e.jsx(n,{variant:"outline",onClick:()=>x(!1),children:"Cancel"}),e.jsx(n,{onClick:i,disabled:y.isPending,children:"Log Communication"})]})]})]})]}),e.jsx(_,{children:N.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-6 text-muted-foreground",children:[e.jsx(se,{className:"h-8 w-8 mb-2"}),e.jsx("p",{className:"text-sm",children:"No communications logged yet"})]}):e.jsx("div",{className:"space-y-3 max-h-[300px] overflow-y-auto",children:N.map(r=>e.jsxs("div",{className:"flex gap-3 p-3 bg-muted/50 rounded-lg",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center text-primary",children:p(r.type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-medium capitalize",children:r.type}),e.jsx("span",{className:"text-muted-foreground",children:"â¢"}),e.jsx("span",{className:"text-muted-foreground",children:r.direction==="inbound"?"From customer":"To customer"})]}),e.jsx("p",{className:"text-sm mt-1",children:r.summary}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[r.created_by_name," ⢠",ae(new Date(r.created_at),"MMM dd, HH:mm")]})]})]},r.id))})})]})}function Zs(){var m,D,B,L,E,H,R,z;const{id:w}=be(),c=we(),{data:s,isLoading:v}=Se(w),y=Y(),o=_e(),x=Ie(),{data:l}=Me(),[h,N]=f.useState(!1),[i,p]=f.useState(!1),[r,u]=f.useState(!1),[C,M]=f.useState(""),[j,q]=f.useState({status:"",priority:"",request_type:"",description:"",assigned_to:""}),G=()=>{s&&(q({status:s.status,priority:s.priority,request_type:s.request_type,description:s.description||"",assigned_to:s.assigned_to||""}),N(!0))},X=async()=>
1{if(s)try{await y.mutateAsync({id:s.id,...j,assigned_to:j.assigned_to||null}),N(!1),d.success("Request updated / 请æ±å·²æ´æ°")}catch(a){d.error("Failed to update: "+a.message)}},K=async()=>{if(!s||!C){d.error("Please provide resolution notes");return}try{await o.mutateAsync({id:s.id,resolution_notes:C}),p(!1),d.success("Request resolved / 请æ±å·²è§£å³")}catch(a){d.error("Failed to resolve: "+a.message)}},$=()=>{var a;s&&c(`/dashboard/qc/corrective-actions?from=service-request&order=${((a=s.order)==null?void 0:a.id)||""}`)};if(v)return e.jsxs("div",{className:"space-y-6",children:[e.jsx(ee,{className:"h-10 w-48"}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:Array.from({length:4}).map((a,me)=>e.jsx(ee,{className:"h-24"},me))}),e.jsx(ee,{className:"h-96"})]});if(!s)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Request not found"}),e.jsx(n,{variant:"link",onClick:()=>c("/dashboard/qc/after-sales"),children:"Back to After-Sales"})]});const I=he.find(a=>a.value===s.status),A=pe.find(a=>a.value===s.priority),T=je.find(a=>a.value===s.request_type),t=ls(new Date,new Date(s.created_at)),g=t>=48&&s.status!=="resolved"&&s.status!=="closed";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(n,{variant:"ghost",size:"icon",onClick:()=>c("/dashboard/qc/after-sales"),children:e.jsx(Ge,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Service Request"}),e.jsx(Z,{className:`${A==null?void 0:A.color} text-white`,children:A==null?void 0:A.label.split(" / ")[0]}),e.jsx(Z,{variant:"outline",className:`${I==null?void 0:I.color} text-white border-0`,children:I==null?void 0:I.label.split(" / ")[0]}),e.jsx(Ae,{createdAt:s.created_at,status:s.status})]}),e.jsxs("p",{className:"text-muted-foreground",children:[T==null?void 0:T.label," ⢠",(m=s.customer)==null?void 0:m.company_name]})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(n,{variant:"outline",className:"text-destructive border-destructive/30 hover:bg-destructive/10",onClick:()=>u(!0),children:[e.jsx(oe,{className:"mr-2 h-4 w-4"}),"Delete"]}),s.request_type==="quality_complaint"&&((D=s.order)==null?void 0:D.id)&&e.jsxs(n,{variant:"outline",onClick:$,children:[e.jsx(Xe,{className:"mr-2 h-4 w-4"}),"Create NCR"]}),s.status!=="resolved"&&s.status!=="closed"&&e.jsxs(te,{open:i,onOpenChange:p,children:[e.jsx(re,{asChild:!0,children:e.jsxs(n,{variant:"outline",children:[e.jsx(ge,{className:"mr-2 h-4 w-4"}),"Resolve"]})}),e.jsxs(ie,{children:[e.jsxs(ne,{children:[e.jsx(le,{children:"Resolve Service Request"}),e.jsx(ce,{children:"Provide resolution notes before closing this request"})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Resolution Notes / è§£å³è¯´æ *"}),e.jsx(Q,{value:C,onChange:a=>M(a.target.value),placeholder:"Describe how the issue was resolved...",rows:4})]})}),e.jsxs(de,{children:[e.jsx(n,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),e.jsx(n,{onClick:K,disabled:o.isPending,children:"Mark Resolved"})]})]})]}),h?e.jsxs(e.Fragment,{children:[e.jsxs(n,{variant:"outline",onClick:()=>N(!1),children:[e.jsx(Je,{className:"mr-2 h-4 w-4"}),"Cancel"]}),e.jsxs(n,{onClick:X,disabled:y.isPending,children:[e.jsx(Ze,{className:"mr-2 h-4 w-4"}),"Save"]})]}):e.jsxs(n,{variant:"outline",onClick:G,children:[e.jsx(Ke,{className:"mr-2 h-4 w-4"}),"Edit"]})]})]}),g&&e.jsx(S,{className:"border-red-500 bg-red-50 dark:bg-red-950",children:e.jsx(_,{className:"pt-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(es,{className:"h-5 w-5 text-red-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-red-800 dark:text-red-200",children:"SLA Overdue"}),e.jsxs("p",{className:"text-sm text-red-600 dark:text-red-300",children:["This request has been open for ",t," hours. Please prioritize resolution."]})]})]})})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(S,{children:e.jsx(_,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(ss,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Customer"}),e.jsx("p",{className:"font-medium truncate",children:(B=s.customer)==null?void 0:B.company_name})]})]})})}),e.jsx(S,{children:e.jsx(_,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-orange-500/10 rounded-lg",children:e.jsx(Ne,{className:"h-5 w-5 text-orange-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Order"}
1),s.order?e.jsx(Z,{variant:"outline",className:"font-mono cursor-pointer",onClick:()=>{var a;return c(`/dashboard/orders/${(a=s.order)==null?void 0:a.id}`)},children:s.order.order_number}):e.jsx("p",{className:"font-medium",children:"N/A"})]})]})})}),e.jsx(S,{children:e.jsx(_,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-blue-500/10 rounded-lg",children:e.jsx(fe,{className:"h-5 w-5 text-blue-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Assigned To"}),e.jsx("p",{className:"font-medium",children:((L=s.assigned_profile)==null?void 0:L.display_name)||"Unassigned"})]})]})})}),e.jsx(S,{children:e.jsx(_,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-green-500/10 rounded-lg",children:e.jsx(as,{className:"h-5 w-5 text-green-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Created"}),e.jsx("p",{className:"font-medium",children:ae(new Date(s.created_at),"MMM dd, yyyy")})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(S,{children:[e.jsx(W,{children:e.jsx(V,{children:"Request Details / 请æ±è¯¦æ
"})}),e.jsx(_,{className:"space-y-6",children:h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Status"}),e.jsxs(P,{value:j.status,onValueChange:a=>q({...j,status:a}),children:[e.jsx(O,{children:e.jsx(F,{})}),e.jsx(U,{children:he.map(a=>e.jsx(k,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Priority"}),e.jsxs(P,{value:j.priority,onValueChange:a=>q({...j,priority:a}),children:[e.jsx(O,{children:e.jsx(F,{})}),e.jsx(U,{children:pe.map(a=>e.jsx(k,{value:a.value,children:a.label},a.value))})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Request Type"}),e.jsxs(P,{value:j.request_type,onValueChange:a=>q({...j,request_type:a}),children:[e.jsx(O,{children:e.jsx(F,{})}),e.jsx(U,{children:je.map(a=>e.jsx(k,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Assigned To"}),e.jsxs(P,{value:j.assigned_to,onValueChange:a=>q({...j,assigned_to:a}),children:[e.jsx(O,{children:e.jsx(F,{placeholder:"Select team member"})}),e.jsx(U,{children:l==null?void 0:l.map(a=>e.jsx(k,{value:a.user_id,children:a.display_name},a.user_id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Description / æè¿°"}),e.jsx(Q,{value:j.description,onChange:a=>q({...j,description:a.target.value}),rows:4})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Description / æè¿°"}),e.jsx("p",{className:"whitespace-pre-wrap",children:s.description||"No description provided"})]}),s.resolution_notes&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsxs("div",{className:"bg-green-50 dark:bg-green-950 border border-green-200 dark:border-green-800 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ge,{className:"h-5 w-5 text-green-600"}),e.jsx("h4",{className:"font-medium text-green-800 dark:text-green-200",children:"Resolution Notes"})]}),e.jsx("p",{className:"whitespace-pre-wrap text-green-700 dark:text-green-300",children:s.resolution_notes}),s.resolved_at&&e.jsxs("p",{className:"text-xs text-green-600 mt-2",children:["Resolved on ",ae(new Date(s.resolved_at),"MMM dd, yyyy HH:mm")]})]})]})]})})]}),e.jsx(cs,{requestId:s.id,items:s.items||[],isEditing:h}),e.jsxs(S,{children:[e.jsx(W,{children:e.jsx(V,{children:"Customer Information"})}),e.jsx(_,{children:e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Company"}),e.jsx("p",{className:"font-medium",children:(E=s.customer)==null?void 0:E.
1company_name})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Contact Person"}),e.jsx("p",{className:"font-medium",children:(H=s.customer)==null?void 0:H.contact_person})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Email"}),e.jsx("p",{className:"font-medium",children:(R=s.customer)==null?void 0:R.email})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Created By"}),e.jsx("div",{className:"flex items-center gap-2",children:s.created_on_behalf?e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Sales (",(z=s.created_by_profile)==null?void 0:z.display_name,")"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ts,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:"Customer Portal"})]})})]})]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(ds,{requestId:s.id,attachments:(s.attachments||[]).filter(a=>a.type!=="communication"),isEditing:h}),e.jsx(os,{requestId:s.id,attachments:s.attachments||[]}),e.jsx(Le,{entityType:"order",entityId:w})]})]}),e.jsx(qe,{open:r,onOpenChange:u,children:e.jsxs(Re,{children:[e.jsxs(ke,{children:[e.jsx(Te,{children:"Delete Service Request?"}),e.jsx(Pe,{children:"This action cannot be undone. This will permanently delete the service request and all associated data."})]}),e.jsxs(Oe,{children:[e.jsx(Fe,{children:"Cancel"}),e.jsx(Ue,{onClick:async()=>{try{await x.mutateAsync(s.id),d.success("Service request deleted"),c("/dashboard/qc/after-sales")}catch(a){d.error("Failed to delete: "+a.message)}},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}export{Zs 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.