(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,75157,e=>{"use strict";e.s(["formatPrice",0,function(e){let s="string"==typeof e?parseFloat(e):e;return new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:0,maximumFractionDigits:0}).format(s)}])},44851,e=>{"use strict";var s=e.i(43476),t=e.i(71645),r=e.i(18566),a=e.i(75157);function l(){let e=(0,r.useSearchParams)(),[l,n]=(0,t.useState)(e.get("order")||""),[i,c]=(0,t.useState)(""),[d,o]=(0,t.useState)(null),[m,x]=(0,t.useState)(""),[u,h]=(0,t.useState)(!1),p=async e=>{e.preventDefault(),h(!0),x(""),o(null);let s=await fetch(`/api/orders/${l}?phone=${i}`);s.ok?o(await s.json()):x("Order not found. Please check your order number and phone number."),h(!1)},j=["Processing","Shipped","Delivered"],f=d?j.indexOf(d.status):-1;return(0,s.jsxs)("div",{className:"max-w-2xl mx-auto px-4 md:px-6 py-12 md:py-16",children:[(0,s.jsxs)("div",{className:"text-center mb-10 md:mb-12",children:[(0,s.jsx)("p",{className:"text-gold text-xs tracking-[0.3em] uppercase mb-3",children:"Order Status"}),(0,s.jsx)("h1",{className:"font-serif text-3xl md:text-4xl text-charcoal",children:"Track Your Order"})]}),(0,s.jsxs)("form",{onSubmit:p,className:"space-y-4 mb-12",children:[(0,s.jsx)("input",{value:l,onChange:e=>n(e.target.value),placeholder:"Order Number (e.g. AM-XXX-XXX)",className:"w-full border border-gray-200 rounded-xl px-4 py-3.5 text-sm focus:outline-none focus:border-gold transition-colors",required:!0}),(0,s.jsx)("input",{value:i,onChange:e=>c(e.target.value),placeholder:"Phone Number",className:"w-full border border-gray-200 rounded-xl px-4 py-3.5 text-sm focus:outline-none focus:border-gold transition-colors",required:!0}),(0,s.jsx)("button",{type:"submit",disabled:u,className:"w-full bg-charcoal text-white py-3.5 text-sm tracking-[0.25em] uppercase rounded-xl hover:bg-gold transition-colors disabled:opacity-50",children:u?"Searching...":"Track Order"})]}),m&&(0,s.jsx)("p",{className:"text-center text-red-500 text-sm",children:m}),d&&(0,s.jsxs)("div",{className:"animate-fade-in",children:["Cancelled"!==d.status&&(0,s.jsxs)("div",{className:"flex items-center justify-between mb-10 relative",children:[(0,s.jsx)("div",{className:"absolute top-4 left-0 right-0 h-[2px] bg-gray-200",children:(0,s.jsx)("div",{className:"h-full bg-gold transition-all duration-500",style:{width:`${50*Math.max(0,f)}%`}})}),j.map((e,t)=>(0,s.jsxs)("div",{className:"relative flex flex-col items-center",children:[(0,s.jsx)("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xs font-medium z-10 ${t<=f?"bg-gold text-white":"bg-gray-200 text-gray-400"}`,children:t<=f?(0,s.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):t+1}),(0,s.jsx)("span",{className:`mt-2 text-xs ${t<=f?"text-gold":"text-gray-400"}`,children:e})]},e))]}),"Cancelled"===d.status&&(0,s.jsx)("div",{className:"text-center mb-8 p-4 bg-red-50 rounded-lg",children:(0,s.jsx)("p",{className:"text-red-600 font-medium",children:"This order has been cancelled."})}),(0,s.jsxs)("div",{className:"bg-cream rounded-2xl p-5 md:p-6 space-y-4",children:[(0,s.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,s.jsx)("span",{className:"text-gray-500",children:"Order Number"}),(0,s.jsx)("span",{className:"font-medium",children:d.orderNumber})]}),(0,s.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,s.jsx)("span",{className:"text-gray-500",children:"Customer"}),(0,s.jsx)("span",{children:d.customerName})]}),(0,s.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,s.jsx)("span",{className:"text-gray-500",children:"Payment"}),(0,s.jsx)("span",{children:d.paymentMethod})]}),(0,s.jsxs)("div",{className:"flex justify-between text-sm",children:[(0,s.jsx)("span",{className:"text-gray-500",children:"Date"}),(0,s.jsx)("span",{children:new Date(d.createdAt).toLocaleDateString("en-IN")})]}),(0,s.jsxs)("div",{className:"border-t border-gray-200 pt-4",children:[(0,s.jsx)("p",{className:"text-sm font-medium mb-3",children:"Items"}),d.items.map((e,t)=>(0,s.jsxs)("div",{className:"flex justify-between text-sm py-1",children:[(0,s.jsxs)("span",{children:[e.productName," ×",e.quantity]}),(0,s.jsx)("span",{children:(0,a.formatPrice)(parseFloat(e.price)*e.quantity)})]},t))]}),(0,s.jsxs)("div",{className:"border-t border-gray-200 pt-3 flex justify-between font-medium",children:[(0,s.jsx)("span",{children:"Total"}),(0,s.jsx)("span",{children:(0,a.formatPrice)(d.total)})]})]})]})]})}e.s(["default",0,function(){return(0,s.jsx)(t.Suspense,{fallback:(0,s.jsx)("div",{className:"text-center py-20",children:"Loading..."}),children:(0,s.jsx)(l,{})})}])}]);