1import{al as N,aD as f,r as p,j as e,as as b,B as l,ap as v,av as h,M as y,V as w}from"./index-DVnvwKss.js";import{A as n}from"./AdminLayout-C50e_CCB.js";import{b as S,c as _}from"./useOrders-4HXJOkhs.js";import{S as P,a as C,b as O,c as A,d as k}from"./select-gdjYPLd5.js";import{T as D}from"./textarea-C2P6Vfod.js";import{L}from"./label-Bnts9xf-.js";import{P as M}from"./package-CWCtnPMe.js";import{P as B}from"./phone-_C-6FI2j.js";import{M as I}from"./map-pin-Bn7e5Vt0.js";import"./lock-D_WmPVvn.js";import"./chart-column-4glrh6i_.js";import"./graduation-cap-B6HRXtd7.js";import"./star-DgJGUcrD.js";import"./tag-BsS18FKR.js";import"./users-Slprv71S.js";import"./send-DbAweDjN.js";import"./code-DeKqVZ0y.js";import"./link-2-FU3pAgyk.js";import"./index-BdQq_4o_.js";import"./chevron-up-CYCEPE0m.js";const T=[{value:"pending",label:"Pending"},{value:"paid",label:"Paid"},{value:"processing",label:"Processing"},{value:"shipped",label:"Shipped"},{value:"delivered",label:"Delivered"},{value:"cancelled",label:"Cancelled"}],U={pending:"bg-yellow-100 text-yellow-800",paid:"bg-blue-100 text-blue-800",processing:"bg-purple-100 text-purple-800",shipped:"bg-orange-100 text-orange-800",delivered:"bg-green-100 text-green-800",cancelled:"bg-red-100 text-red-800"},re=()=>{var x;const{id:r}=N(),c=f(),{data:s,isLoading:u}=S(r||""),i=_(),[o,m]=p.useState("");p.useEffect(()=>{s!=null&&s.notes&&m(s.notes)},[s==null?void 0:s.notes]);const d=t=>new Intl.NumberFormat("en-NG",{style:"currency",currency:"NGN",minimumFractionDigits:0}).format(t/100),j=t=>{r&&i.mutate({id:r,status:t})},g=()=>{r&&i.mutate({id:r,status:s.status,notes:o})};if(u)return e.jsx(n,{title:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(b,{})})});if(!s)return e.jsx(n,{title:"Order Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Order not found"}),e.jsx(l,{variant:"outline",onClick:()=>c("/admin/orders"),className:"mt-4",children:"Back to Orders"})]})});const a=s.shipping_address;return e.jsx(n,{title:`Order ${s.order_number}`,action:e.jsxs(l,{variant:"outline",onClick:()=>c("/admin/orders"),children:[e.jsx(v,{className:"h-4 w-4 mr-2"}),"Back to Orders"]}),children:e.jsxs("div",{className:"grid lg:grid-cols-3 gap-4 lg:gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4 lg:space-y-6",children:[e.jsxs("div",{className:"bg-card border-2 border-border p-4 md:p-6",children:[e.jsx("h3",{className:"font-heading text-lg mb-4",children:"Order Items"}),e.jsx("div",{className:"divide-y divide-border",children:(x=s.order_items)==null?void 0:x.map(t=>e.jsxs("div",{className:"py-3 sm:py-4 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 sm:gap-4 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 sm:w-12 sm:h-12 bg-secondary flex items-center justify-center rounded shrink-0",children:e.jsx(M,{className:"h-5 w-5 sm:h-6 sm:w-6 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base truncate",children:t.product_title}),e.jsxs("p",{className:"text-xs sm:text-sm text-muted-foreground",children:[t.product_type," · Qty: ",t.quantity]}),t.digital_access_granted&&e.jsx(h,{variant:"outline",className:"mt-1 text-xs",children:"Digital Access Granted"})]})]}),e.jsx("p",{className:"font-medium text-sm sm:text-base shrink-0",children:d(t.total)})]},t.id))}),e.jsxs("div",{className:"border-t border-border pt-4 mt-4 space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subtotal"}),e.jsx("span",{children:d(s.subtotal)})]}),s.shipping_cost>0&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Shipping"}),e.jsx("span",{children:d(s.shipping_cost)})]}),e.jsxs("div",{className:"flex justify-between font-medium text-lg",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{children:d(s.total)})]})]})]}),e.jsxs("div",{className:"bg-card border-2 border-border p-6",children:[e.jsx("h3",{className:"font-heading text-lg mb-4",children:"Admin Notes"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(D,{value:o,onChange:t=>m(t.target.value),placeholder:"Add notes about this order...",rows:4}),e.jsx(l,{onClick:g,disabled:i.isPending,children:"Save Notes"})]})]})]}),e.jsxs("div",{className:"space-y-4 lg:space-y-6",children:[e.jsxs("div",{className:"bg-card border-2 border-border p-4 md:p-6 space-y-4",children:[e.jsx("h3",{className:"font-heading text-lg",children:"Order Status"}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(h,{className:U[s.status],children:s.status.charAt(0).toUpperCase()+s.status.slice(1)})}),e.jsxs("div",{children:[e.jsx(L,{children:"Update Status"}),e.jsxs(P,{value:s.status,onValueChange:j,children:[e.jsx(C,{className:"mt-1",children:e.jsx(O,{})}),e.jsx(A,{children:T.map(t=>e.jsx(k,{value:t.value,children:t.label},t.value))})]})]})]}),e.jsxs("div",{className:"bg-card border-2 border-border p-6 space-y-4",children:[e.jsx("h3",{className:"font-heading text-lg",children:"Customer"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(y,{className:"h-4 w-4 text-muted-foreground mt-1"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.customer_name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.customer_email})]})]}),s.customer_phone&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(B,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("p",{className:"text-sm",children:s.customer_phone})]})]})]}),a&&e.jsxs("div",{className:"bg-card border-2 border-border p-6 space-y-4",children:[e.jsx("h3",{className:"font-heading text-lg",children:"Shipping Address"}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(I,{className:"h-4 w-4 text-muted-foreground mt-1"}),e.jsxs("div",{className:"text-sm",children:[a.street&&e.jsx("p",{children:a.street}),(a.city||a.state)&&e.jsxs("p",{children:[a.city,a.city&&a.state&&", ",a.state]}),a.postal_code&&e.jsx("p",{children:a.postal_code}),a.country&&e.jsx("p",{children:a.country})]})]})]}),e.jsxs("div",{className:"bg-card border-2 border-border p-6 space-y-4",children:[e.jsx("h3",{className:"font-heading text-lg",children:"Payment"}),e.jsxs("div",{className:"space-y-2 text-sm",children:[s.payment_reference&&e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground",children:"Reference"}),e.jsx("p",{className:"font-mono",children:s.payment_reference})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground",children:"Date"}),e.jsx("p",{children:w(new Date(s.created_at),"MMM d, yyyy 'at' h:mm a")})]})]})]})]})]})})};export{re 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.