1import{c as Pe,r as I,u as Te,E as ke,a9 as Le,x as G,j as e,C as l,b as x,d as y,e as m,I as Ee,B as u,J as W,D as j}from"./index-PoezL6ES.js";import{o as Me}from"./operatorInvoice-Bb25VnZN.js";import{P as Qe,a as Ae}from"./PaymentHistory-C68gsuWD.js";import{h as Ue,R as Fe}from"./receiptAvailability-YJb-RoUU.js";import{o as Z,s as $,c as ee,U as se}from"./orderStatusDisplay-B_CKNKYQ.js";import{S as te}from"./separator-CXX0-AW0.js";import{L as Ye}from"./Layout-BcC4k5XS.js";import{O as Be,a as He}from"./AdjustmentDisplay-Dg4SjReu.js";import{S as re}from"./ShippingLabelDisplay-CrrgReHt.js";import{Q as De}from"./QuotePriceSummary-BnCadH2X.js";import{S as Ve}from"./search-CfTFAZri.js";import{M as C}from"./message-square-Dhbn9UXD.js";import{M as ae}from"./map-pin-DR0JPs5m.js";import{P as ze}from"./package-PqA1FGEh.js";import{C as Je}from"./calendar-BoKWtaJi.js";import{C as ie}from"./paymentClassification-CVWiFSIg.js";import{M as ne}from"./minus-p1hQDmq8.js";import{T as oe}from"./trash-2-CU89lXRj.js";import{T as Ke}from"./truck-BwnEtdIx.js";import{C as ce}from"./clock-BfEl87gl.js";import{C as Xe}from"./circle-check-DmitUVA1.js";import"./r1SelectionCarrier-IeuQI9kW.js";import"./dates-CJHRM7CQ.js";import"./format-DODwXckt.js";import"./parseISO-CjBCa20h.js";import"./repairStatusClassification-YIoQKMLS.js";import"./useQuery-DyXb1ZmJ.js";import"./settings-C3snpZNB.js";import"./alert-vaGWg3nF.js";import"./refresh-cw-D2XhFFlK.js";import"./download-CMU_g_rn.js";import"./printer-DTbffh0W.js";import"./external-link-C51ZBlGb.js";/** 2 * @license lucide-react v0.564.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Ge=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],We=Pe("lock",Ge);function Ps(){var L,E,M,Q,A,U,F,Y,B,H,D,V,z;const[q,R]=I.useState(""),[c,_]=I.useState(""),[de,P]=I.useState(null),{isAuthenticated:h,hasRole:le}=Te(),{toast:d}=ke(),v=Le(),S=le(["operator","manager","superuser"]);I.useEffect(()=>{const r=new URLSearchParams(window.location.search).get("orderNumber");r&&(R(r),_(r))},[]);const{data:t,isLoading:T,error:k,refetch:me,isFetching:ue}=G({queryKey:["repair-tracking",c],queryFn:async({signal:s})=>{if(!c)return null;try{const r=`/api/track-repair?orderNumber=${encodeURIComponent(c)}`,i=await fetch(r,{signal:s,credentials:"include"});if(!i.ok){if(i.status===404)throw new Error("Order not found");const a=await i.text();throw new Error(`${i.status}: ${a}`)}return await i.json()}catch(r){if(r instanceof Error&&r.name==="AbortError")return null;throw r}},enabled:!!c,retry:!1,staleTime:3e4}),n=!k&&Ue(t==null?void 0:t.receiptSummary)?t.receiptSummary:null,O=(L=t==null?void 0:t.invoice)!=null&&L.operatorEntered?Me(t.invoice.status,n==null?void 0:n.balances.outstandingBalanceCents,n==null?void 0:n.balances):null,he=n&&((E=t==null?void 0:t.invoice)!=null&&E.operatorEntered?O==="payable":n.balances.outstandingBalanceCents>=50),pe=n&&((M=t==null?void 0:t.invoice)!=null&&M.operatorEntered?O==="below_minimum":n.balances.outstandingBalanceCents>0&&n.balances.outstandingBalanceCents<50),p=((Q=t==null?void 0:t.invoice)==null?void 0:Q.status)==="quote_required"||((A=t==null?void 0:t.repairs)==null?void 0:A.some(s=>s.status==="quote_required")),xe=!p&&((U=t==null?void 0:t.invoice)==null?void 0:U.status)==="pending_review"&&((F=t==null?void 0:t.repairs)==null?void 0:F.some(s=>s.processes.some(r=>r.status==="quote_required"))),{data:g}=G({queryKey:["dropoff-tracking",c],queryFn:async()=>{if(!c)return null;try{const s=await fetch(`/api/customer/dropoff-tracking?orderNumber=${encodeURIComponent(c)}`,{credentials:"include"});return s.ok?await s.json():null}catch(s){return console.warn("Failed to fetch dropoff tracking:",s),null}},enabled:!!c,retry:!1,staleTime:3e4}),b=h&&!((Y=t==null?void 0:t.invoice)!=null&&Y.operatorEntered)&&["pending_payment","pending_review"].includes((B=t==null?void 0:t.invoice)==null?void 0:B.status)&&!(((D=(H=t==null?void 0:t.receiptSummary)==null?void 0:H.balances)==null?void 0:D.totalPaidCents)>0),ye=async(s,r)=>{P(s);try{const a=await(await fetch("/graphql",{method:"POST",headers:{"Content-Type":"application/json","x-requested-with":"XMLHttpRequest"},credentials:"include",body:JSON.stringify({query:`mutation RemoveInvoiceItem($invoiceId: Int!, $repairId: Int!) { 7 removeInvoiceItem(invoiceId: $invoiceId, repairId: $repairId) { 8 success message orderCancelled 9 } 10 }`,variables:{invoiceId:r,repairId:s}})})).json();if(a.errors)throw new Error(a.errors[0].message);
10v.invalidateQueries({queryKey:["repair-tracking",c]});const o=a.data.removeInvoiceItem;o.orderCancelled?d({title:"Order cancelled",description:"All items were removed."}):d({title:"Item removed",description:o.message,action:e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>je(s,r),children:[e.jsx(se,{className:"h-3 w-3 mr-1"})," Undo"]}),duration:1e4})}catch(i){d({title:"Error",description:i.message,variant:"destructive"})}finally{P(null)}},je=async(s,r)=>{try{const a=await(await fetch("/graphql",{method:"POST",headers:{"Content-Type":"application/json","x-requested-with":"XMLHttpRequest"},credentials:"include",body:JSON.stringify({query:`mutation RestoreInvoiceItem($invoiceId: Int!, $repairId: Int!) { 11 restoreInvoiceItem(invoiceId: $invoiceId, repairId: $repairId) { 12 success message 13 } 14 }`,variables:{invoiceId:r,repairId:s}})})).json();if(a.errors)throw new Error(a.errors[0].message);v.invalidateQueries({queryKey:["repair-tracking",c]}),d({title:"Item restored",description:"The item has been restored to your order."})}catch(i){d({title:"Error",description:i.message,variant:"destructive"})}},ve=async(s,r)=>{try{const a=await(await fetch("/graphql",{method:"POST",headers:{"Content-Type":"application/json","x-requested-with":"XMLHttpRequest"},credentials:"include",body:JSON.stringify({query:`mutation RemoveInvoiceOrderItem($invoiceId: Int!, $orderItemId: Int!) { 15 removeInvoiceOrderItem(invoiceId: $invoiceId, orderItemId: $orderItemId) { 16 success message orderCancelled 17 } 18 }`,variables:{invoiceId:r,orderItemId:s}})})).json();if(a.errors)throw new Error(a.errors[0].message);v.invalidateQueries({queryKey:["repair-tracking",c]});const o=a.data.removeInvoiceOrderItem;o.orderCancelled?d({title:"Order cancelled",description:"All items were removed."}):d({title:"Item removed",description:o.message,action:e.jsxs(u,{variant:"outline",size:"sm",onClick:()=>fe(s,r),children:[e.jsx(se,{className:"h-3 w-3 mr-1"})," Undo"]}),duration:1e4})}catch(i){d({title:"Error",description:i.message,variant:"destructive"})}},fe=async(s,r)=>{try{const a=await(await fetch("/graphql",{method:"POST",headers:{"Content-Type":"application/json","x-requested-with":"XMLHttpRequest"},credentials:"include",body:JSON.stringify({query:`mutation RestoreInvoiceOrderItem($invoiceId: Int!, $orderItemId: Int!) { 19 restoreInvoiceOrderItem(invoiceId: $invoiceId, orderItemId: $orderItemId) { 20 success message 21 } 22 }`,variables:{invoiceId:r,orderItemId:s}})})).json();if(a.errors)throw new Error(a.errors[0].message);v.invalidateQueries({queryKey:["repair-tracking",c]}),d({title:"Item restored",description:"The item has been restored to your order."})}catch(i){d({title:"Error",description:i.message,variant:"destructive"})}},ge=async(s,r,i)=>{try{const o=await(await fetch("/graphql",{method:"POST",headers:{"Content-Type":"application/json","x-requested-with":"XMLHttpRequest"},credentials:"include",body:JSON.stringify({query:`mutation UpdateInvoiceOrderItemQuantity($invoiceId: Int!, $orderItemId: Int!, $quantity: Int!) { 23 updateInvoiceOrderItemQuantity(invoiceId: $invoiceId, orderItemId: $orderItemId, quantity: $quantity) { 24 success message 25 } 26 }`,variables:{invoiceId:r,orderItemId:s,quantity:i}})})).json();if(o.errors)throw new Error(o.errors[0].message);v.invalidateQueries({queryKey:["repair-tracking",c]}),d({title:"Quantity updated",description:o.data.updateInvoiceOrderItemQuantity.message})}catch(a){d({title:"Error",description:a.message,variant:"destructive"})}},be=async(s,r,i)=>{try{const o=await(await fetch("/graphql",{method:"POST",headers:{"Content-Type":"application/json","x-requested-with":"XMLHttpRequest"},credentials:"include",body:JSON.stringify({query:`mutation UpdateInvoiceItemQuantity($invoiceId: Int!, $repairId: Int!, $quantity: Int!) { 27 updateInvoiceItemQuantity(invoiceId: $invoiceId, repairId: $repairId, quantity: $quantity) { 28 success message 29 } 30 }`,variables:{invoiceId:r,repairId:s,quantity:i}})})).json();if(o.errors)throw new Error(o.errors[0].message);
30v.invalidateQueries({queryKey:["repair-tracking",c]}),d({title:"Quantity updated",description:o.data.updateInvoiceItemQuantity.message})}catch(a){d({title:"Error",description:a.message,variant:"destructive"})}},Ne=s=>{s.preventDefault(),q.trim()&&_(q.trim())},N=s=>new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),we=s=>{switch(s.toLowerCase()){case"completed":return e.jsx(Xe,{className:"h-4 w-4 text-green-600"});case"in_progress":return e.jsx(ce,{className:"h-4 w-4 text-blue-600"});case"pending":return e.jsx(W,{className:"h-4 w-4 text-yellow-600"});default:return e.jsx(ce,{className:"h-4 w-4 text-gray-600"})}},Ie=s=>{switch(s){case"customer_to_warehouse":return"Customer â Fulfillment Center";case"warehouse_to_customer":return"Fulfillment Center â Customer";case"prepaid_mailer_to_customer":return"Prepaid Mailer â Customer";case"dropoff_pickup":return"Dropoff Location";case"revision_reship":return"Revision re-ship â You";default:return s.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}},Ce=()=>{var r,i,a;return!t||!g?!1:((((i=(r=t.receiptSummary)==null?void 0:r.balances)==null?void 0:i.totalPaidCents)??0)>0||(((a=t.invoice.adjustmentSummary)==null?void 0:a.totalPaid)??0)>0)&&g.dropoffStatus==="pending_confirmation"},qe=s=>{switch(s){case"pending_confirmation":return"Awaiting your dropoff confirmation";case"location_confirmed":return"Dropoff location confirmed";case"direct_ship_confirmed":return"Direct shipping confirmed";case"items_dropped_off":return"Items dropped off";case"items_shipped_direct":return"Items shipped directly";case"received_at_upkept":return"Items received at Upkept";default:return s.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}},Se=(s,r)=>{if(h)return`${s} ${r}`;const i=s.charAt(0).toUpperCase(),a=r.charAt(0).toUpperCase(),o=i+"*".repeat(Math.max(1,s.length-1)),w=a+"*".repeat(Math.max(1,r.length-1));return`${o} ${w}`},Oe=s=>{if(h)return s;const[r,i]=s.split("@");return`${r.charAt(0)+"*".repeat(Math.max(1,r.length-2))+r.charAt(r.length-1)}@${i}`},f=((V=t==null?void 0:t.invoice)==null?void 0:V.status)==="pending_payment",$e=f?"Complete Your Repair Order":"Track My Repair",Re=f?"Your repair details are saved â finish checkout to get started":S?"Enter your order number to view detailed repair status and shipping information":"View detailed repair status and shipping information for your orders";return e.jsx(Ye,{title:$e,subtitle:Re,children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[S&&e.jsxs(l,{className:"mb-8",children:[e.jsx(x,{children:e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"h-5 w-5"}),"Find Your Repair Order"]})}),e.jsxs(m,{children:[e.jsxs("form",{onSubmit:Ne,className:"flex gap-4",children:[e.jsx(Ee,{type:"text",placeholder:"Enter your order number (e.g., ORD-1234567890-ABC)",value:q,onChange:s=>R(s.target.value),className:"flex-1",required:!0}),e.jsx(u,{type:"submit",disabled:T,children:T?"Searching...":"Track Order"})]}),e.jsx("p",{className:"text-sm text-gray-500 mt-2",children:"Your order number can be found in your confirmation email or receipt."})]})]}),!S&&!c&&e.jsx(l,{className:"mb-8 border-blue-200 bg-blue-50",children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"bg-blue-100 rounded-full p-3",children:e.jsx(C,{className:"h-8 w-8 text-blue-600"})})}),e.jsx("h2",{className:"text-xl font-semibold text-blue-900 mb-2",children:"Access Your Order Status"}),e.jsx("p",{className:"text-blue-800 mb-4",children:"To view your order details, please use the tracking link provided in your confirmation email or magic link from our notifications."}),e.jsxs("div",{className:"text-sm text-blue-700 bg-blue-100 p-3 rounded",children:[e.jsx("p",{className:"font-medium mb-1",children:"Don't have your email?"}),e.jsxs("p",{children:["Visit the"," ",e.jsx("a",{href:"/my-orders",className:"underline font-medium",children:"My Orders"})," ","page to request a new access link."]})]})]})})}),k&&!t&&e.jsx(l,{className:"mb-8",children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center text-red-600",children:[e.jsx(W,{className:"h-12 w-12 mx-auto mb-4"}),e.jsx("p",{className:"font-medium",children:"Order not found"}),e.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Please check your order number and try again."})]})})}),t&&e.jsxs("div",{className:"space-y-6",children:[(p||xe)&&e.jsx(l,{className:"border-amber-300 bg-gradient-to-r from-amber-50 to-yellow-50 shadow-lg",children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"bg-amber-100 rounded-full p-3",children:e.jsx(C,{className:"h-8 w-8 text-amber-600"})})}
30),e.jsx("h2",{className:"text-2xl font-bold text-amber-900 mb-2",children:p?"Custom Quote Required":"Your Quote is Ready"}),e.jsx("p",{className:"text-lg text-amber-800 mb-4",children:p?e.jsx(e.Fragment,{children:"Your repair requires a custom quote due to its unique requirements. Our team will review your submission and provide you with a personalized quote soon."}):h?e.jsx(e.Fragment,{children:"Your quote is ready to review. Review the charges below and pay when you're ready to proceed."}):e.jsx(e.Fragment,{children:"Your quote is ready. Log in to My Orders to review it and pay when you're ready to proceed."})})]})})}),Ce()&&e.jsxs(l,{className:"border-blue-200 bg-blue-50",children:[e.jsx(x,{children:e.jsxs(y,{className:"flex items-center gap-2 text-blue-800",children:[e.jsx(ae,{className:"h-5 w-5"}),"Get Your Items to Us"]})}),e.jsx(m,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{variant:"outline",className:"border-blue-300 text-blue-700",children:qe(g.dropoffStatus)}),e.jsxs("span",{className:"text-sm text-blue-600",children:["Method:"," ",g.dropoffMethod==="direct_ship"?"Ship Directly":"Partner Location"]})]}),e.jsxs("p",{className:"text-sm text-blue-700",children:['Your payment has been processed successfully! Now you need to get your items to us so we can begin the repair process. Once you drop off your item at one of our local dropboxes or with your carrier of choice, click "Confirm Dropoff Details" so we can retrieve your order.'," "]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(u,{className:"bg-blue-600 hover:bg-blue-700 text-white",onClick:()=>window.location.href=`/dropoff-status?orderNumber=${t.invoice.orderNumber}`,children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),"Confirm Dropoff Details"]}),e.jsx(u,{variant:"outline",className:"border-blue-300 text-blue-700 hover:bg-blue-100",onClick:()=>window.open("/local-dropoff","_blank"),children:"View Dropoff Options"})]})]})})]}),e.jsxs(l,{children:[e.jsx(x,{children:e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(ze,{className:"h-5 w-5"}),"Order Details"]})}),e.jsxs(m,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold text-lg",children:["Order #",t.invoice.orderNumber]}),e.jsxs("div",{className:"space-y-2 mt-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Je,{className:"h-4 w-4 text-gray-500"}),e.jsxs("span",{className:"text-sm",children:["Placed on ",N(t.invoice.createdAt)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{variant:$(t.invoice.status),children:Z(t.invoice.status)}),e.jsx("div",{className:"text-lg font-semibold",children:h?p?e.jsx(De,{amountCents:n==null?void 0:n.totals.grandTotalCents}):n?e.jsxs("span",{className:"text-green-600",children:["$",(n.totals.grandTotalCents/100).toFixed(2)]}):e.jsx("span",{className:"text-sm",children:"Total unavailable"}):e.jsx("span",{className:"text-green-600",children:"****"})})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900",children:"Customer"}),e.jsx("p",{className:"text-sm text-gray-600",children:Se(t.invoice.customer.firstName,t.invoice.customer.lastName)}),e.jsx("p",{className:"text-sm text-gray-600",children:Oe(t.invoice.customer.email)}),!h&&e.jsxs("div",{className:"mt-3 space-y-2",children:[e.jsxs(u,{variant:"outline",className:`w-full ${f?"border-amber-300 bg-amber-50 text-amber-800 hover:bg-amber-100 hover:text-amber-900":"border-gray-300 bg-gray-50 text-gray-700 hover:bg-gray-100 hover:text-gray-900"}`,onClick:()=>window.location.href="/my-orders",children:[e.jsx(We,{className:"h-4 w-4 mr-2"}),f?"Log in to complete your order":"Log in to view order details"]}),e.jsx("p",{className:"text-xs text-gray-500 text-center",children:f?"You'll be directed to the My Orders page, where you can request a login link sent to your provided email, and you can complete your order.":"Log in to view your full receipt, payment history, and order details."})]})]})]}),h&&n&&e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsx(te,{}),O==="closed"&&n.balances.outstandingBalanceCents>0&&e.jsx("p",{children:"Online payment is unavailable for this refunded or closed order. Please contact us if you need help."}),pe&&!p&&e.jsx("p",{children:"The remaining balance is below the $0.50 card minimum. Please contact us to resolve this balance."}),he&&!p&&e.jsxs(u,{className:"w-full",onClick:()=>{var a;const s=n.balances.outstandingBalanceCents,r=Number((s/100).toFixed(2)),i={orderNumber:t.invoice.orderNumber,invoiceId:t.invoice.id,amountDue:r,amountDueCents:s,type:"adjustment_payment",anyRequiresShipping:((a=t.invoice.adjustmentSummary)==null?void 0:a.anyRequiresShipping)??!1};sessionStorage.setItem("adjustmentCart",JSON.stringify(i)),window.location.href="/checkout?type=adjustment"},children:[e.jsx(ie,{className:"h-4 w-4 mr-2"}),"Pay Amount Due ($",(n.balances.outstandingBalanceCents/100).toFixed(2),")"]}),e.jsx(Be,{receipt:n,hideFinancials:!!p})]}),h&&!n&&e.jsx("div",{className:"mt-6",children:e.jsx(Fe,{retry:()=>
30void me(),pending:ue})})]})]}),e.jsxs(l,{children:[e.jsx(x,{children:e.jsx(y,{children:"Repair Items & Status"})}),e.jsx(m,{children:e.jsx("div",{className:"space-y-6",children:t.repairs.map((s,r)=>{var i;return e.jsxs("div",{children:[r>0&&e.jsx(te,{className:"my-6"}),e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:`font-medium text-lg flex items-center gap-2 ${s.status==="cancelled"?"text-gray-400":""}`,children:[we(s.status),e.jsx("span",{className:s.status==="cancelled"?"line-through":"",children:s.itemDescription})]}),e.jsx("p",{className:`mt-1 whitespace-pre-wrap ${s.status==="cancelled"?"text-gray-400 line-through":"text-gray-600"}`,children:s.serviceDescription}),e.jsx("div",{className:"flex items-center gap-2 mt-2",children:s.status==="cancelled"?e.jsx(j,{variant:"destructive",className:"bg-red-100 text-red-700 border-red-300",children:"Cancelled"}):e.jsx(j,{variant:$(s.status),children:ee(s.status)})}),(()=>{var w,J,K,X;const a=((J=(w=s.calculatedPricing)==null?void 0:w.serverValidated)==null?void 0:J.quantityAttributes)||((X=(K=s.calculatedPricing)==null?void 0:K.clientProvided)==null?void 0:X.quantityAttributes),o=a?Math.max(...Object.values(a).map(_e=>Number(_e)||1)):0;return o>1&&b?e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:["Qty: ",o]}),e.jsx(u,{variant:"outline",size:"sm",className:"h-6 w-6 p-0",onClick:()=>be(s.id,t.invoice.id,o-1),children:e.jsx(ne,{className:"h-3 w-3"})})]}):o>0?e.jsxs("span",{className:"text-sm text-gray-600 mt-2 block",children:["Qty: ",o]}):null})()]}),b&&((i=t==null?void 0:t.repairs)==null?void 0:i.length)>0&&s.status!=="cancelled"&&e.jsx(u,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-700 hover:bg-red-50",onClick:()=>ye(s.id,t.invoice.id),disabled:de===s.id,children:e.jsx(oe,{className:"h-4 w-4"})})]})}),s.processes.length>0&&e.jsxs("div",{children:[e.jsxs("h4",{className:"font-medium mb-3 flex items-center gap-2",children:[e.jsx(C,{className:"h-4 w-4"}),"Status Updates"]}),e.jsx("div",{className:"space-y-3",children:s.processes.map(a=>e.jsxs("div",{className:`border-l-2 pl-4 pb-3 ${a.status==="cancelled"?"border-red-300":"border-gray-200"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.status==="cancelled"?e.jsx(j,{variant:"destructive",className:"bg-red-100 text-red-700 border-red-300",children:"Cancelled"}):e.jsx(j,{variant:"outline",children:ee(a.status)}),e.jsx("span",{className:"text-xs text-gray-500",children:N(a.createdAt)})]}),a.customerVisibleMessage&&e.jsx("p",{className:"text-sm text-[#393b42]",children:a.customerVisibleMessage}),a.actualCompletionDate&&e.jsxs("p",{className:"text-xs text-green-600 mt-1",children:["Completed:"," ",N(a.actualCompletionDate)]})]},a.id))})]})]},s.id)})})})]}),((z=t.orderItems)==null?void 0:z.filter(s=>s.isActive!==!1).length)>0&&e.jsxs(l,{children:[e.jsx(x,{children:e.jsx(y,{children:"Products & Add-ons"})}),e.jsx(m,{children:e.jsx("div",{className:"space-y-3",children:t.orderItems.filter(s=>s.isActive!==!1).map(s=>{var r,i,a,o;return e.jsx("div",{className:"border rounded-lg p-3 bg-gray-50",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium",children:((r=s.snapshot)==null?void 0:r.productName)||((i=s.snapshot)==null?void 0:i.variantName)||((a=s.productVariant)==null?void 0:a.productName)||((o=s.productVariant)==null?void 0:o.variantName)||s.productName||s.itemType}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:["Qty: ",s.quantity||1]}),b&&(s.quantity||1)>1&&e.jsx(u,{variant:"outline",size:"sm",className:"h-6 w-6 p-0",onClick:()=>ge(s.id,t.invoice.id,(s.quantity||1)-1),children:e.jsx(ne,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.priceAtPurchase?e.jsxs("p",{className:"text-sm font-medium",children:["$",(Number(s.priceAtPurchase)/100).toFixed(2)]}):e.jsx("p",{className:"text-sm font-medium text-gray-500",children:"â"}),b&&e.jsx(u,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-700 hover:bg-red-50",onClick:()=>ve(s.id,t.invoice.id),children:e.jsx(oe,{className:"h-4 w-4"})})]})]})},s.id)})})})]}),t.invoice.payments&&t.invoice.payments.length>0&&e.jsxs(l,{children:[e.jsx(x,{children:e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(ie,{className:"h-5 w-5"}),"Payment History"]})}),e.jsxs(m,{children:[e.jsx(Qe,{payments:t.invoice.payments}),h&&e.jsx(Ae,{balances:n==null?void 0:n.balances})]})]}),t.invoice.adjustments&&t.invoice.adjustments.length>0&&e.jsxs(l,{children:[e.jsx(x,{children:e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(C,{className:"h-5 w-5"}),"Pricing Updates"]})}),e.jsx(m,{children:e.jsx(He,{adjustments:t.invoice.adjustments,maxItems:5,orderNumber:t.invoice.orderNumber})})]}),e.jsx(re,{shippingLegs:t.shippingLegs,orderNumber:t.invoice.orderNumber}),t.shippingLegs.length>0&&e.jsxs(l,{children:[e.jsx(x,{children:e.jsxs(y,{className:"flex items-center gap-2",children:[e.jsx(Ke,{className:"h-5 w-5"}),"Shipping Information"]})}),e.jsx(m,{children:e.jsx("div",{className:"space-y-4",children:t.shippingLegs.filter(s=>s.legType==="warehouse_to_customer"||s.legType==="prepaid_mailer_to_customer"?!0:s.legType==="customer_to_warehouse"?s.trackingNumber&&s.trackingNumber.trim()!=="":!0).map(s=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("h4",{className:"font-medium",children:["Step ",s.legNumber,":"," ",Ie(s.legType)]}
30),e.jsx(j,{variant:$(s.status),children:Z(s.status)})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Carrier:"})," ",s.carrier]}),s.trackingNumber&&e.jsxs("p",{children:[e.jsx("strong",{children:"Tracking Number:"})," ",e.jsx("code",{className:"bg-gray-100 px-2 py-1 rounded text-xs",children:s.trackingNumber})]})]}),e.jsx("div",{children:s.actualDelivery&&e.jsxs("p",{className:"text-green-600",children:[e.jsx("strong",{children:"Delivered:"})," ",N(s.actualDelivery)]})})]}),e.jsx(re,{shippingLegs:[s],orderNumber:t.invoice.orderNumber})]},s.id))})})]})]})]})})}export{Ps 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.