PageSourceSearch

https://tire-track-loyalty-3a0d7f0a.base44.app/assets/CustomerOrderDetails-DUPPJexZ.js

js tire-track-loyalty-3a0d7f0a.base44.app collected 2026-10-03 03:13:22 UTC 30,526 bytes, 4 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/OrderChat-BppPICB2.js","assets/index-DdU35jPJ.js","assets/index-ziLDO-qt.css","assets/button-BfxMpK8P.js","assets/index-gN4drEn4.js","assets/index-Dp3B9jqt.js","assets/clsx-B-dksMZM.js","assets/utils-DCmAa5as.js","assets/bundle-mjs-BTmSotT-.js","assets/textarea-RCbb6gBZ.js","assets/TimezoneHelper-CKaUc9lx.js","assets/index-CpcvuyT9.js","assets/format-C-2FZrE-.js","assets/index-CGPMVT10.js","assets/message-square-UZdUIYzB.js","assets/createLucideIcon-DMxicyrC.js","assets/loader-circle-B5Ydjp3O.js","assets/send-DYuvBuIV.js","assets/user-TFtzTQfw.js","assets/briefcase-sHV214ND.js","assets/shield-CNFEkWQF.js"])))=>i.map(i=>d[i]);
2import{j as e,c as Fe,r as d,b as B,L as te,t as h,_ as Te}from"./index-DdU35jPJ.js";import{c as w}from"./index-CtlYlah8.js";import{c as Oe}from"./CustomerActiveOrder-DhP4h-Q0.js";import{B as j}from"./button-BfxMpK8P.js";import{B as T}from"./badge-O5l_SoDq.js";import{D as Ie,a as Le,b as $e,c as Pe,d as Ue,e as Re}from"./dialog-gVN6KGjC.js";import{u as Me,C as qe,r as Ye}from"./customerCancelOrder-Azy4pO9U.js";import{u as ze}from"./customerTimezone-Bxa41me2.js";import{C as Ge}from"./CustomerBackLink-DASqCFe-.js";import{f as He}from"./format-D_Nl7F1K.js";import{P as O}from"./package-DYJogmeO.js";import{T as Je}from"./triangle-alert-l3tEQyle.js";import{C as ae}from"./circle-x-QpU72J1I.js";import{C as P}from"./circle-check-big-B9divPaO.js";import{T as I}from"./truck-BQgQtOKT.js";import{C as L}from"./clock-D8ofwCOI.js";import{G as Xe}from"./gift-iZbsnbdF.js";import{F as S}from"./file-text-BIInLmy-.js";import{M as Ve}
2from"./map-pin-CKcF86VS.js";import{U as $}from"./user-TFtzTQfw.js";import{C as We}from"./credit-card-BsmBHB--.js";import{P as Ke}from"./phone-BiN9hL5_.js";import{M as Qe}from"./mail-DvcgW5d2.js";import{L as re}from"./loader-circle-B5Ydjp3O.js";import{R as Ze}from"./refresh-cw-2pM8p9DH.js";import{P as es}from"./pencil-BFgvU9po.js";import{S as ss}from"./shopping-cart-vZlzvnWl.js";import"./funnelTracking-Gv10N77B.js";import"./chevron-right-PZEH6lk6.js";import"./createLucideIcon-DMxicyrC.js";import"./index-gN4drEn4.js";import"./index-Dp3B9jqt.js";import"./clsx-B-dksMZM.js";import"./utils-DCmAa5as.js";import"./bundle-mjs-BTmSotT-.js";import"./index-BhZ8ej-y.js";import"./index-12QbP6l0.js";import"./index-BsvT06Lq.js";import"./index-9bdZCgcr.js";import"./index-BvvUEucZ.js";import"./index-Bwgqm7vL.js";import"./x-DAruoHhn.js";import"./customerInvoice-CBk3OB-2.js";import"./CustomerDocumentActions-DtE-eI4R.js";import"./receipt-CEZlCW4C.js";import"./arrow-left-CoQakR5q.js";import"./chevron-left-BcAcL8kJ.js";import"./format-C-2FZrE-.js";function ts(){return e.jsx("div",{className:"min-h-screen bg-[#f8f9fc] pb-16","aria-busy":"true","aria-label":"Loading order details",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-6 sm:py-8",children:[e.jsx("div",{className:"h-4 w-36 bg-slate-100 rounded animate-pulse mb-5"}),e.jsxs("div",{className:"bg-white rounded-2xl border border-[#E5E7EB] shadow-sm overflow-hidden mb-5",children:[e.jsxs("div",{className:"px-5 sm:px-7 pt-6 pb-5 bg-gradient-to-br from-[#2563EB] to-[#1D4ED8]",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-2",children:[e.jsx("div",{className:"h-3 w-24 bg-white/30 rounded animate-pulse"}),e.jsx("div",{className:"h-8 w-48 bg-white/40 rounded animate-pulse"}),e.jsx("div",{className:"h-3 w-40 bg-white/20 rounded animate-pulse"})]}),e.jsx("div",{className:"h-7 w-28 bg-white/40 rounded-md animate-pulse shrink-0"})]}),e.jsxs("div",{className:"mt-4 flex items-baseline gap-2",children:[e.jsx("div",{className:"h-3 w-12 bg-white/30 rounded animate-pulse"}),e.jsx("div",{className:"h-7 w-28 bg-white/40 rounded animate-pulse"})]})]}),e.jsxs("div",{className:"px-5 sm:px-7 py-6 border-b border-[#E5E7EB]",children:[e.jsx("div",{className:"flex items-center justify-between",children:Array.from({length:5}).map((c,o)=>e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 bg-slate-100 rounded-full animate-pulse"}),e.jsx("div",{className:"h-2 w-12 bg-slate-100 rounded animate-pulse"})]},o))}),e.jsx("div",{className:"mt-4 h-3 w-56 bg-slate-100 rounded animate-pulse"})]})]}),e.jsxs("div",{className:"grid lg:grid-cols-3 gap-5",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-5",children:[e.jsxs("div",{className:"bg-white rounded-2xl border border-[#E5E7EB] p-5",children:[e.jsx("div",{className:"h-3 w-24 bg-slate-100 rounded animate-pulse mb-4"}),e.jsx("div",{className:"space-y-3",children:Array.from({length:2}).map((c,o)=>e.jsxs("div",{className:"flex justify-between bg-[#F8FAFC] rounded-xl p-4 border border-[#E5E7EB]",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 w-32 bg-slate-100 rounded animate-pulse"}),e.jsx("div",{className:"h-3 w-24 bg-slate-100 rounded animate-pulse"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-3 w-20 bg-slate-100 rounded animate-pulse"}),e.jsx("div",{className:"h-4 w-16 bg-slate-100 rounded animate-pulse"})]})]},o))}),e.jsx("div",{className:"mt-5 pt-5 border-t border-[#E5E7EB] space-y-2",children:Array.from({length:4}).map((c,o)=>e.jsxs("div",{className:"flex justify-between",children:[e.jsx("div",{className:"h-3 w-20 bg-slate-100 rounded animate-pulse"}),e.jsx("div",{className:"h-3 w-16 bg-slate-100 rounded animate-pulse"})]},o))})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-[#E5E7EB] p-5 space-y-3",children:[e.jsx("div",{className:"h-3 w-32 bg-slate-100 rounded animate-pulse"}),e.jsx("div",{className:"h-20 bg-slate-100 rounded-xl animate-pulse"})]})]}),e.jsx("div",{className:"space-y-5",children:Array.from({length:3}).map((c,o)=>
2e.jsxs("div",{className:"bg-white rounded-2xl border border-[#E5E7EB] p-5 space-y-3",children:[e.jsx("div",{className:"h-3 w-20 bg-slate-100 rounded animate-pulse"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 bg-slate-100 rounded-lg animate-pulse shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-2.5 w-16 bg-slate-100 rounded animate-pulse"}),e.jsx("div",{className:"h-3 w-32 bg-slate-100 rounded animate-pulse"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 bg-slate-100 rounded-lg animate-pulse shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-2.5 w-16 bg-slate-100 rounded animate-pulse"}),e.jsx("div",{className:"h-3 w-36 bg-slate-100 rounded animate-pulse"})]})]})]},o))})]})]})})}const as=d.lazy(()=>Te(()=>import("./OrderChat-BppPICB2.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]))),le="th_customer_order_detail_v2:",rs=300*1e3,is=(c,o)=>{if(!c||!o)return null;try{const l=sessionStorage.getItem(`${le}${String(c).toLowerCase()}:${o}`),n=l?JSON.parse(l):null;return n&&Date.now()-Number(n.saved_at||0)<=rs?n.data:null}catch{return null}},ls=(c,o,l)=>{if(!(!c||!o||!(l!=null&&l.order)||!(l!=null&&l.customer)))try{sessionStorage.setItem(`${le}${String(c).toLowerCase()}:${o}`,JSON.stringify({saved_at:Date.now(),data:l}))}catch{}},ie=[{key:"received",label:"Order Received"},{key:"assigned",label:"Technician Assigned"},{key:"in_progress",label:"In Progress"},{key:"on_the_way",label:"On The Way"},{key:"completed",label:"Completed"}],ns=["We've received your order","A technician has been assigned to your order","Your technician is preparing your tires","Your technician is on the way","Your order is complete"];function cs({stageIndex:c,cancelled:o}){return o?null:e.jsx("div",{className:"th-order-timeline flex items-center",children:ie.map((l,n)=>{const s=n<c,u=n===c;return e.jsxs("div",{className:"flex items-center flex-1 last:flex-none",children:[e.jsxs("div",{className:"flex flex-col items-center gap-2 shrink-0",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold border-2 transition-colors ${s?"bg-[#2563EB] border-[#2563EB] text-white":u?"bg-white border-[#2563EB] text-[#2563EB] ring-4 ring-[#2563EB]/10":"bg-white border-slate-200 text-slate-300"}`,children:s?e.jsx(P,{className:"w-4 h-4"}):n+1}),e.jsx("span",{className:`text-[10px] font-medium leading-tight text-center w-14 px-0.5 ${s||u?"text-[#17213A]":"text-slate-400"}`,children:l.label})]}),n<ie.length-1&&e.jsx("div",{className:`h-0.5 flex-1 mx-1.5 -mt-6 rounded-full ${n<c?"bg-[#2563EB]":"bg-slate-200"}`})]},l.key)})})}function C({icon:c,label:o,value:l,accent:n}){return e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 ${n||"bg-slate-50 text-slate-500"}`,children:e.jsx(c,{className:"w-4 h-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wide text-slate-500 font-semibold",children:o}),e.jsx("p",{className:"text-sm text-[#17213A] font-medium break-words",children:l||"—"})]})]})}function rt(){var V,W,K,Q,Z,ee;const{user:c}=Fe(),o=(c==null?void 0:c.email)||(c==null?void 0:c.user_email)||"",l=new URLSearchParams(window.location.search).get("id"),[n]=d.useState(()=>is(o,l)),[s,u]=d.useState(()=>(n==null?void 0:n.order)||null),[p,ne]=d.useState(()=>(n==null?void 0:n.operations_order)||null),[m,ce]=d.useState(()=>(n==null?void 0:n.customer)||null),[oe,de]=d.useState(()=>(n==null?void 0:n.sales_reps)||[]),[me,D]=d.useState(()=>!n),[xe,k]=d.useState(!1),[pe,U]=d.useState(!1),[R,M]=d.useState(!1),[A,q]=d.useState(!1),[Y,_]=d.useState(null),{invoicesByOrderId:he}=Me(l?[l]:[]),ue=he[l],[fe,z]=d.useState(!1),[ge,be]=d.useState([]),[f,je]=d.useState([]);d.useEffect(()=>{Ne(!!n)},[l]);const Ne=async(t=!1)=>{if(!l){k(!0),D(!1);return}t||D(!0),k(!1);try{const a=await B.functions.invoke("loadCustomerOrderDetailsV2",{order_id:l}),i=(a==null?void 0:a.data)??a;if(!(i!=null&&i.order)||!(i!=null&&i.customer))throw new Error("not_found");u(i.order),ne(i.operations_order||null),ce(i.customer),de(i.sales_reps||[]),ls(o,l,i)}catch(a){console.error(a),t||k(!0)}finally{t||D(!1)}},ve=async()=>
2{if(!confirm("Are you sure you want to cancel this order?"))return;q(!0),_("cancelling");const{outcome:t,latest:a,error:i}=await Ye(l);t==="rejected"?(h.error(i||"Failed to cancel order"),_(null)):t==="cancelled"?(u(a||(r=>({...r,status:"cancelled",credits_earned_status:"order_cancelled"}))),_("cancelled"),h.success("Order cancelled successfully"+((s.credits_applied||0)>0?". Credits have been refunded.":""))):(a&&u(a),_("recovering"),h("Cancellation is still being processed. Refresh in a few moments or contact support.")),q(!1)},we=()=>{localStorage.setItem("editing_order_id",s.id),localStorage.setItem("tire_cart",JSON.stringify(s.items||[])),window.location.href=w("TireShop")},_e=async()=>{if(s){M(!0);try{const t=await B.functions.invoke("resolveBuyAgain",{order_id:s.id}),a=t==null?void 0:t.data;if(!a){h.error("Failed to verify inventory. Please try again.");return}const{lines:i=[],cart_items:r=[]}=a,g=i.filter(b=>b.status!=="added");g.length>0?(be(g),je(r),z(!0)):r.length===0?h.error("None of the items from this order are currently available."):F(r)}catch(t){console.error("Error resolving buy-again",t),h.error("Failed to verify inventory. Please try again.")}finally{M(!1)}}},F=(t,a="Cart")=>{const i=(t||[]).map(r=>({tire_pricing_record_id:r.tire_pricing_record_id||r.tire_id||r.id,id:r.tire_pricing_record_id||r.tire_id||r.id,brand:r.brand,model:r.model||"",size:r.size,ply_rating:r.ply_rating||"",position:r.position||"",quantity:r.quantity,image_url:r.image_url||null}));localStorage.setItem("tire_cart",JSON.stringify(i)),localStorage.removeItem("editing_order_id"),window.dispatchEvent(new Event("cartUpdated")),h.success("Cart updated with order items!"),a&&(window.location.href=w(a))},ye=async()=>{U(!0);try{const t=await B.entities.Invoice.filter({order_id:l});if(t.length===0){h.error("Invoice not found for this order");return}const a=t[0],i=await B.functions.invoke("generateInvoicePDF",{invoice_id:a.id}),r=atob(i.data.pdf),g=new Uint8Array(r.length);for(let E=0;E<r.length;E++)g[E]=r.charCodeAt(E);const b=new Blob([g],{type:"application/pdf"}),se=window.URL.createObjectURL(b),v=document.createElement("a");v.href=se,v.download=i.data.filename||`Invoice_${a.invoice_number}.pdf`,document.body.appendChild(v),v.click(),window.URL.revokeObjectURL(se),v.remove(),h.success("Invoice downloaded")}catch{h.error("Failed to download invoice")}finally{U(!1)}},Ee=t=>u({...s,chat_messages:t}),{formatDateTime:Be,timezone:os}=ze();if(me)return e.jsx(ts,{});if(xe||!s)return e.jsx("div",{className:"th-customer-scroll-surface min-h-screen bg-[#f8f9fc] flex items-center justify-center px-4",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx(O,{className:"w-12 h-12 text-[#94A3B8] mx-auto mb-4"}),e.jsx("p",{className:"text-[#17213A] font-semibold text-lg mb-1",children:"Order not found"}),e.jsx("p",{className:"text-[#64748B] text-sm mb-4",children:"This order may have been removed or doesn't belong to your account."}),e.jsx(te,{to:w("MyOrders"),children:e.jsx(j,{className:"bg-[#2563EB] hover:bg-[#1D4ED8] text-white",children:"Back to My Orders"})})]})});const{cancelled:N,stageIndex:y,stageLabel:Se}=Oe(s,p),G=p==null?void 0:p.technician_eta,Ce=G&&y===3,H=((V=s.items)==null?void 0:V.reduce((t,a)=>t+a.quantity,0))||0,J=s.final_amount??s.total_amount??0,De=s.fulfillment_type?s.fulfillment_type.charAt(0).toUpperCase()+s.fulfillment_type.slice(1):"—",ke=s.fulfillment_type==="delivery"?s.delivery_address:(p==null?void 0:p.preferred_pick_location_address)||s.preferred_pick_location||s.delivery_address,X=p==null?void 0:p.assigned_technician_name,Ae=Be(s.order_date||s.created_date,{month:"long",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"});let x=null;if(m){const a=(m.assigned_rep_ids||[]).map(i=>oe.find(r=>r.id===i)).filter(Boolean);a.length===0&&(m.sales_rep_1_name&&a.push({name:m.sales_rep_1_name,phone:m.sales_rep_1_phone,email:m.sales_rep_1_email}),m.sales_rep_2_name&&a.push({name:m.sales_rep_2_name,phone:m.sales_rep_2_phone,email:m.sales_rep_2_email})),x=a[0]||null}return e.jsxs("div",{className:"th-customer-scroll-surface min-h-screen bg-[linear-gradient(180deg,#eff4ff_0%,#f8f9fc_30%,#f8f9fc_100%)] pb-32",children:[e.jsx(Ie,{open:fe,onOpenChange:z,children:e.jsxs(Le,{className:"bg-white border-[#
2E5E7EB] text-[#17213A] max-w-[95vw] sm:max-w-lg",children:[e.jsxs($e,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 mb-2",children:[e.jsx(Je,{className:"w-5 h-5"}),e.jsx(Pe,{children:"Some Items Unavailable"})]}),e.jsx(Ue,{className:"text-[#64748B]",children:"The following tires from your previous order are no longer available:"})]}),e.jsx("div",{className:"bg-[#F8FAFC] rounded-lg p-4 my-2 space-y-2 max-h-[200px] overflow-y-auto border border-[#E5E7EB]",children:ge.map((t,a)=>e.jsxs("div",{className:"flex justify-between items-center border-b border-[#E5E7EB] last:border-0 pb-2 last:pb-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[#17213A] font-medium",children:t.brand}),e.jsxs("p",{className:"text-[#64748B] text-xs",children:[t.size,t.quantity?` · ${t.quantity} tire${t.quantity!==1?"s":""}`:""]})]}),e.jsx(T,{variant:"outline",className:t.status==="out_of_stock"?"text-amber-600 border-amber-200 bg-amber-50":t.status==="no_access"?"text-red-600 border-red-200 bg-red-50":"text-slate-500 border-slate-200 bg-slate-50",children:t.reason||"Unavailable"})]},a))}),e.jsx("div",{className:"text-sm text-[#64748B] mb-4",children:f.length>0?`You can proceed with the ${f.length} available item(s), or go to the shop to select alternatives.`:"None of the items are currently available. Please visit the shop to find alternatives."}),e.jsxs(Re,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(j,{variant:"outline",onClick:()=>{f.length>0?F(f,"TireShop"):window.location.href=w("TireShop")},className:"w-full sm:w-auto border-[#E5E7EB] text-[#17213A] hover:bg-[#F8FAFC]",children:"Pick Another Tire"}),f.length>0&&e.jsxs(j,{onClick:()=>F(f,"Cart"),className:"w-full sm:w-auto bg-[#2563EB] hover:bg-[#1D4ED8] text-white",children:["Proceed with Available (",f.length,")"]})]})]})}),e.jsxs("div",{className:"mx-auto max-w-5xl px-3 py-4 sm:px-6 sm:py-8 lg:px-8",children:[e.jsx(Ge,{to:"MyOrders",label:"Back to My Orders"}),e.jsxs("div",{className:"mb-5 overflow-hidden rounded-[28px] border border-white/80 bg-white shadow-[0_22px_60px_-34px_rgba(37,99,235,0.5)]",children:[e.jsxs("div",{className:"th-dark-hero bg-[radial-gradient(circle_at_top_right,rgba(255,255,255,0.2),transparent_38%),linear-gradient(135deg,#2563EB,#1D4ED8_60%,#3730A3)] px-5 pb-6 pt-6 text-[#fff] sm:px-7",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"th-dark-hero__eyebrow text-white/90 text-xs font-medium uppercase tracking-wider mb-1",children:"Order Details"}),e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold leading-tight",children:["Order #",s.id.slice(-6).toUpperCase()]}),e.jsxs("p",{className:"th-dark-hero__copy text-white/90 text-sm mt-1",children:[Ae," CT · ",H," tire(s)"]})]}),e.jsx("div",{className:"shrink-0",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border text-sm font-semibold bg-white border-white ${N?"text-red-600":"text-[#1D4ED8]"}`,children:[N?e.jsx(ae,{className:"w-4 h-4"}):y===4?e.jsx(P,{className:"w-4 h-4"}):e.jsx(I,{className:"w-4 h-4"}),N?"Cancelled":Se]})})]}),e.jsxs("div",{className:"mt-4 flex items-baseline gap-2",children:[e.jsx("span",{className:"th-dark-hero__copy text-white/90 text-sm",children:"Total"}),e.jsxs("span",{className:"th-dark-hero__title text-white text-2xl font-bold",children:["$",J.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]})]}),e.jsxs("div",{className:"px-5 sm:px-7 py-6 border-b border-[#E5E7EB]",children:[e.jsx(cs,{stageIndex:y,cancelled:N}),!N&&e.jsxs("div",{className:"flex items-center gap-2 mt-4 text-sm",children:[e.jsx(L,{className:"w-4 h-4 text-[#2563EB] shrink-0"}),e.jsx("span",{className:"text-slate-500",children:"Next:"}),e.jsx("span",{className:"text-[#17213A] font-medium",children:ns[y]})]})]}),Ce&&e.jsxs("div",{className:"px-5 sm:px-7 py-4 bg-violet-50 border-b border-violet-200 flex items-center gap-3",children:[e.jsx("div",{className:"w-11 h-11 rounded-full bg-violet-100 flex items-center justify-center shrink-0",children:e.jsx(I,{className:"w-5 h-5 text-violet-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-violet-700 text-xs font-semibold uppercase tracking-wider",children:"Estimated Arrival"}),e.jsx("p",{className:"text-[#17213A] text-xl font-bold leading-tight",children:G})]})]})]}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-3 lg:gap-5",children:[e.jsxs("div",{className:"space-y-4 lg:col-span-2 lg:space-y-5",children:[e.jsxs("div",{className:"bg-white rounded-2xl border border-[#
2E5E7EB] p-5",children:[e.jsxs("h2",{className:"text-sm text-[#64748B] uppercase tracking-wider mb-4 flex items-center gap-2",children:[e.jsx(O,{className:"w-4 h-4 text-[#2563EB]"})," Order Items"]}),e.jsx("div",{className:"space-y-3",children:(W=s.items)==null?void 0:W.map((t,a)=>{var i,r;return e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-center gap-2 bg-[#F8FAFC] rounded-xl p-4 border border-[#E5E7EB]",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-[#17213A] font-semibold",children:[t.brand," ",t.model||""]}),e.jsxs("p",{className:"text-[#64748B] text-sm",children:[t.ply_rating&&e.jsxs("span",{className:"font-medium",children:[t.ply_rating," • "]}),t.size,t.position&&e.jsxs("span",{children:[" • ",t.position]})]})]}),e.jsxs("div",{className:"text-left sm:text-right",children:[e.jsxs("p",{className:"text-[#17213A]",children:[t.quantity," × $",(i=t.price)==null?void 0:i.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]}),t.original_price>t.price&&e.jsxs("p",{className:"text-red-500 text-xs line-through",children:["$",(r=t.original_price)==null?void 0:r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]}),e.jsxs("p",{className:"text-[#17213A] font-semibold",children:["$",(t.quantity*t.price).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]})]},a)})}),e.jsxs("div",{className:"mt-5 pt-5 border-t border-[#E5E7EB] space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[#64748B]",children:"Total Tires"}),e.jsx("span",{className:"text-[#17213A] font-medium",children:H})]}),(()=>{var r;const t=((r=s.items)==null?void 0:r.reduce((g,b)=>g+(b.original_price||b.price)*b.quantity,0))||0,a=s.total_amount||0,i=t-a;return i<=.01?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[#64748B]",children:"Original Price"}),e.jsxs("span",{className:"text-red-500 line-through",children:["$",t.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-emerald-600 font-medium",children:"Total Savings"}),e.jsxs(T,{variant:"outline",className:"bg-emerald-50 text-emerald-600 border-emerald-200 font-bold",children:["-$",i.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]})]})})(),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[#64748B]",children:"Subtotal"}),e.jsxs("span",{className:"text-[#2563EB] font-medium",children:["$",(K=s.total_amount)==null?void 0:K.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),(s.status==="in_progress"||s.status==="completed")&&(()=>{const t=s.fulfillment_type,a=s.delivery_fee_reason;if(t==="pickup")return e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[#64748B]",children:"Delivery"}),e.jsx("span",{className:"text-[#64748B] font-medium",children:"Pickup — no delivery fee"})]});const i=a==="free_30_plus"||a==="free_tier_2_plus"||!s.delivery_fee;return e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[#64748B]",children:"Delivery"}),i?e.jsx("span",{className:"text-emerald-600 font-bold",children:"Free delivery ($0.00)"}):e.jsxs("span",{className:"text-[#17213A] font-medium",children:["$",s.delivery_fee.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]})})(),(s.credits_applied||0)>0&&e.jsxs("div",{className:"flex justify-between text-emerald-600",children:[e.jsx("span",{children:"Credits Applied"}),e.jsxs("span",{children:["-$",(Q=s.credits_applied)==null?void 0:Q.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),e.jsxs("div",{className:"flex justify-between pt-2 border-t border-[#E5E7EB]",children:[e.jsx("span",{className:"text-[#64748B] font-medium",children:"Final Amount"}),e.jsxs("span",{className:"text-[#17213A] font-bold text-lg",children:["$",J.toLocaleStr
2ing("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),s.credits_earned>0&&s.credits_earned_status==="added"&&e.jsxs("div",{className:"flex justify-between pt-2 border-t border-[#E5E7EB]",children:[e.jsxs("span",{className:"text-emerald-600 font-medium flex items-center gap-1",children:[e.jsx(Xe,{className:"w-4 h-4"})," Credits Earned"]}),e.jsxs("span",{className:"text-emerald-600 font-bold text-lg",children:["+$",(Z=s.credits_earned)==null?void 0:Z.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),s.status==="completed"&&s.credits_earned_status==="pending"&&e.jsxs("div",{className:"flex justify-between pt-2 border-t border-[#E5E7EB]",children:[e.jsx("span",{className:"text-amber-600 font-medium",children:"Credits Earned"}),e.jsx("span",{className:"text-amber-600",children:"Processing..."})]})]})]}),(s.status==="pending"||s.status==="in_progress")&&m&&e.jsxs("div",{className:"bg-white rounded-2xl border border-[#E5E7EB] p-5",children:[e.jsxs("h2",{className:"text-sm text-[#64748B] uppercase tracking-wider mb-4 flex items-center gap-2",children:[e.jsx(S,{className:"w-4 h-4 text-[#2563EB]"})," Order Conversation"]}),e.jsx(d.Suspense,{fallback:e.jsx("div",{className:"h-28 animate-pulse rounded-xl bg-slate-100"}),children:e.jsx(as,{order:s,currentUser:{email:m.user_email,full_name:m.contact_name},userType:"customer",onMessageSent:Ee})})]}),s.customer_notes&&e.jsxs("div",{className:"bg-white rounded-2xl border border-[#E5E7EB] p-5",children:[e.jsxs("h2",{className:"text-sm text-[#64748B] uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(S,{className:"w-4 h-4 text-[#2563EB]"})," Your Notes"]}),e.jsx("p",{className:"text-[#17213A] text-sm whitespace-pre-line",children:s.customer_notes})]}),s.admin_notes&&!s.admin_notes.startsWith("⚠️ CANCELLED BY CUSTOMER")&&e.jsxs("div",{className:"bg-[#2563EB]/5 rounded-2xl border border-[#2563EB]/20 p-5",children:[e.jsxs("h2",{className:"text-sm text-[#2563EB] uppercase tracking-wider mb-3 flex items-center gap-2",children:[e.jsx(S,{className:"w-4 h-4"})," Message from Truck Haters"]}),e.jsx("p",{className:"text-[#17213A] text-sm whitespace-pre-line",children:s.admin_notes.split(`
3
4⚠️`)[0]})]})]}),e.jsxs("div",{className:"space-y-4 lg:space-y-5",children:[e.jsxs("div",{className:"bg-white rounded-2xl border border-[#E5E7EB] p-5",children:[e.jsxs("h2",{className:"text-sm text-[#64748B] uppercase tracking-wider mb-4 flex items-center gap-2",children:[e.jsx(I,{className:"w-4 h-4 text-[#2563EB]"})," Fulfillment"]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(C,{icon:O,label:"Type",value:De,accent:"bg-blue-50 text-[#2563EB]"}),e.jsx(C,{icon:L,label:"Date & Time",value:s.fulfillment_date?`${He(s.fulfillment_date,"MMMM d, yyyy")}${s.fulfillment_time?" • "+s.fulfillment_time:""}`:"—",accent:"bg-purple-50 text-purple-600"}),e.jsx(C,{icon:Ve,label:s.fulfillment_type==="delivery"?"Delivery Address":"Pickup Location",value:ke||"—",accent:"bg-emerald-50 text-emerald-600"}),!N&&X&&e.jsx(C,{icon:$,label:"Technician",value:X,accent:"bg-amber-50 text-amber-600"})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-[#E5E7EB] p-5",children:[e.jsxs("h2",{className:"text-sm text-[#64748B] uppercase tracking-wider mb-4 flex items-center gap-2",children:[e.jsx(We,{className:"w-4 h-4 text-[#2563EB]"})," Payment"]}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:((ee=s.payment_methods)==null?void 0:ee.map((t,a)=>e.jsx(T,{variant:"outline",className:"border-[#E5E7EB] text-[#64748B]",children:t},a)))||e.jsx("p",{className:"text-[#64748B] text-sm",children:"Not specified"})}),e.jsx("div",{className:"mt-3 pt-3 border-t border-[#E5E7EB]",children:e.jsx(qe,{invoice:ue,onDownload:ye,downloading:pe})})]}),x&&e.jsxs("div",{className:"bg-white rounded-2xl border border-[#E5E7EB] p-5",children:[e.jsxs("h2",{className:"text-sm text-[#64748B] uppercase tracking-wider mb-4 flex items-center gap-2",children:[e.jsx($,{className:"w-4 h-4 text-[#2563EB]"})," Your Representative"]}),e.jsxs("div",{className:"flex items-start gap-3",children:[x.photo_url?e.jsx("img",{src:x.photo_url,alt:x.name,className:"w-12 h-12 rounded-full object-cover border border-[#
4E5E7EB]"}):e.jsx("div",{className:"w-12 h-12 bg-[#2563EB]/10 rounded-full flex items-center justify-center text-[#2563EB]",children:e.jsx($,{className:"w-6 h-6"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[#17213A] font-bold",children:x.name}),e.jsxs("div",{className:"flex flex-col gap-1 mt-1",children:[x.phone&&e.jsxs("a",{href:`tel:${x.phone}`,className:"text-[#64748B] text-sm hover:text-[#2563EB] flex items-center gap-2",children:[e.jsx(Ke,{className:"w-3 h-3"})," ",x.phone]}),x.email&&e.jsxs("a",{href:`mailto:${x.email}`,className:"text-[#64748B] text-sm hover:text-[#2563EB] flex items-center gap-2",children:[e.jsx(Qe,{className:"w-3 h-3"})," ",x.email]})]})]})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-[#E5E7EB] p-5 space-y-3",children:[e.jsxs("h2",{className:"text-sm text-[#64748B] uppercase tracking-wider flex items-center gap-2",children:[e.jsx(S,{className:"w-4 h-4 text-[#2563EB]"})," Actions"]}),s.status==="completed"&&e.jsxs(j,{onClick:_e,disabled:R,variant:"outline",className:"w-full border-[#2563EB] text-[#2563EB] hover:bg-[#2563EB] hover:text-white",children:[R?e.jsx(re,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Ze,{className:"w-4 h-4 mr-2"})," Buy Again"]}),s.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-amber-50 rounded-lg p-3 border border-amber-200",children:e.jsx("p",{className:"text-amber-700 text-xs",children:'This order is pending. You can edit or cancel until it moves to "In Progress".'})}),e.jsxs(j,{onClick:we,variant:"outline",className:"w-full border-[#E5E7EB] text-[#17213A] hover:bg-[#F8FAFC]",children:[e.jsx(es,{className:"w-4 h-4 mr-2"})," Edit Items"]}),e.jsxs(j,{onClick:ve,disabled:A,variant:"outline",className:"w-full border-red-200 text-red-600 hover:bg-red-50 hover:text-red-700",children:[A?e.jsx(re,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(ae,{className:"w-4 h-4 mr-2"}),A?"Cancelling your order…":"Cancel Order"]})]}),Y==="cancelled"&&e.jsxs("div",{className:"rounded-lg bg-emerald-50 border border-emerald-200 p-3 flex items-start gap-2",children:[e.jsx(P,{className:"w-4 h-4 text-emerald-600 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-emerald-700 text-xs font-medium leading-snug",children:"Order cancelled successfully."})]}),Y==="recovering"&&e.jsxs("div",{className:"rounded-lg bg-amber-50 border border-amber-200 p-3 flex items-start gap-2",children:[e.jsx(L,{className:"w-4 h-4 text-amber-600 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-amber-700 text-xs font-medium leading-snug",children:"Cancellation is still being processed. Refresh in a few moments or contact support."})]}),e.jsx(te,{to:w("TireShop"),className:"block",children:e.jsxs(j,{variant:"ghost",className:"w-full text-[#64748B] hover:text-[#17213A] hover:bg-[#F8FAFC]",children:[e.jsx(ss,{className:"w-4 h-4 mr-2"})," Shop More Tires"]})})]})]})]})]})]})}export{rt 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.