module.exports=[52631,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(50944),e=a.i(87682),f=a.i(17171),g=a.i(40695),h=a.i(54161),i=a.i(59848),j=a.i(64037),k=a.i(35984);let l=Object.keys(k.ORDER_STATUS_LABELS);a.s(["OrderStatusControl",0,function({orderId:a,currentStatus:m,isSuperAdmin:n,refundAvailable:o,hasPaidPayment:p}){let q=(0,d.useRouter)(),{toast:r}=(0,j.useToast)(),[s,t]=(0,c.useState)(!1),[u,v]=(0,c.useState)(!1),[w,x]=(0,c.useState)(!1);async function y(b){t(!0);let c=await fetch(`/api/admin/orders/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:b})}),d=await c.json().catch(()=>null);(t(!1),c.ok)?(r({variant:"success",title:"Status updated"}),q.refresh()):r({variant:"error",title:d?.error??"Could not update status"})}async function z(){x(!0);let b=await fetch(`/api/admin/orders/${a}/refund`,{method:"POST"}),c=await b.json().catch(()=>null);(x(!1),v(!1),b.ok)?(r({variant:"success",title:"Order refunded"}),q.refresh()):r({variant:"error",title:c?.error??"Refund failed"})}return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-end gap-3",children:[(0,b.jsxs)("div",{className:"w-56",children:[(0,b.jsx)(f.Label,{htmlFor:"order-status",children:"Status"}),(0,b.jsx)(e.Select,{id:"order-status",value:m,disabled:s,onChange:a=>y(a.target.value),children:l.map(a=>(0,b.jsx)("option",{value:a,disabled:!(a=>{if(a===m)return!0;if("CANCELLED"===a)return n&&("PENDING_PAYMENT"===m||"PAID"===m);if("REFUNDED"===a)return!1;let b=k.ORDER_STATUS_FLOW.indexOf(m),c=k.ORDER_STATUS_FLOW.indexOf(a);return -1!==b&&c>b})(a),className:"disabled:hidden",children:k.ORDER_STATUS_LABELS[a]},a))})]}),(0,b.jsx)(h.Badge,{variant:"COMPLETED"===m?"success":"CANCELLED"===m||"REFUNDED"===m?"danger":"PENDING_PAYMENT"===m?"warning":"info",children:k.ORDER_STATUS_LABELS[m]})]}),(0,b.jsx)("p",{className:"text-xs text-muted",children:n?"Super admin can cancel pending or paid orders; refunds process via Stripe.":"Super admin only: cancel or refund orders."}),o&&p&&"PAID"===m&&n&&(0,b.jsx)(g.Button,{variant:"danger",loading:w,onClick:()=>v(!0),children:"Refund order"}),(0,b.jsx)(i.ConfirmDialog,{open:u,onClose:()=>v(!1),onConfirm:z,loading:w,title:"Refund this order?",message:"The payment will be refunded via Stripe and stock will be restored. This cannot be undone.",confirmLabel:"Refund order"})]})}])},54161,a=>{"use strict";var b=a.i(87924);let c={neutral:"bg-primary/10 text-foreground",success:"bg-green-100 text-green-800",warning:"bg-amber-100 text-amber-800",danger:"bg-red-100 text-red-800",info:"bg-blue-100 text-blue-800"};a.s(["Badge",0,function({variant:a="neutral",className:d="",...e}){return(0,b.jsx)("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${c[a]} ${d}`,...e})}])},59848,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(32324),e=a.i(40695);a.s(["ConfirmDialog",0,function({open:a,title:f,message:g,confirmLabel:h="Delete",cancelLabel:i="Cancel",loading:j=!1,error:k,onConfirm:l,onClose:m}){let[n]=(0,c.useState)(!1);return(0,b.jsxs)(d.Modal,{open:a,onClose:m,title:f,children:[(0,b.jsx)("p",{className:"mb-6 text-sm text-muted",children:g}),k&&(0,b.jsx)("p",{className:"-mt-4 mb-4 text-sm text-red-600",role:"alert",children:k}),(0,b.jsxs)("div",{className:"flex justify-end gap-3",children:[(0,b.jsx)(e.Button,{variant:"ghost",onClick:m,disabled:j,children:i}),(0,b.jsx)(e.Button,{variant:"danger",onClick:l,loading:j,children:h})]})]})}])},87682,a=>{"use strict";var b=a.i(87924);let c=(0,a.i(72131).forwardRef)(function({invalid:a=!1,className:c="",children:d,...e},f){return(0,b.jsx)("select",{ref:f,"aria-invalid":a||void 0,className:`h-10 w-full rounded-md border border-border bg-white px-3 text-sm focus:outline-2 focus:outline-offset-1 focus:outline-accent ${a?"border-red-500":""} ${c}`,...e,children:d})});a.s(["Select",0,c])},35984,a=>{"use strict";a.s(["ORDER_STATUS_FLOW",0,["PENDING_PAYMENT","PAID","PROCESSING","READY","SHIPPED","COMPLETED"],"ORDER_STATUS_LABELS",0,{PENDING_PAYMENT:"Pending payment",PAID:"Paid",PROCESSING:"Processing",READY:"Ready",SHIPPED:"Shipped",COMPLETED:"Completed",CANCELLED:"Cancelled",REFUNDED:"Refunded"}])}];

//# sourceMappingURL=_1y3kev8._.js.map