import{r as e,t}from"./jsx-runtime-DGeXAQPT.js";import{H as n,t as r}from"./link-BEigRx5R.js";import{F as i,N as a,d as o,n as s,r as c,t as l,z as u}from"./Modals-BkPPnKoF.js";import{t as d}from"./map-pin-z_SXwEyN.js";import{t as f}from"./package-DzDt_BEJ.js";import{C as p,S as m,l as h,u as g,x as _,y as v}from"./index-BFZg1haX.js";var y=e(n()),b=t();function x(){let[e,t]=(0,y.useState)(!1),[n,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),{user:w,addresses:T,orders:E,addAddress:D,removeAddress:O}=m(),[k,A]=(0,y.useState)({name:``,phone:``,street:``,city:``,state:``});return(0,b.jsxs)(`div`,{className:`min-h-screen bg-neutral-50`,children:[(0,b.jsx)(c,{open:e,onOpenChange:t}),(0,b.jsx)(l,{open:n,onOpenChange:x,onCheckout:()=>{x(!1),C(!0)}}),(0,b.jsx)(s,{open:S,onOpenChange:C}),(0,b.jsx)(o,{onOpenCart:()=>x(!0),onOpenSignIn:()=>t(!0)}),(0,b.jsx)(`main`,{className:`max-w-[1100px] mx-auto px-4 py-8`,children:w?(0,b.jsxs)(`div`,{className:`grid grid-cols-3 gap-6`,children:[(0,b.jsxs)(`aside`,{className:`bg-white rounded-lg border p-5 h-fit`,children:[(0,b.jsx)(`div`,{className:`w-12 h-12 rounded-full bg-orange-100 text-orange-600 flex items-center justify-center font-bold text-lg mb-2`,children:w.name.charAt(0).toUpperCase()}),(0,b.jsx)(`div`,{className:`font-bold`,children:w.name}),(0,b.jsx)(`div`,{className:`text-xs text-neutral-500`,children:w.email}),(0,b.jsx)(`div`,{className:`text-xs mt-3 px-2 py-1 rounded bg-neutral-100 inline-block`,children:w.role})]}),(0,b.jsxs)(`div`,{className:`col-span-2 space-y-6`,children:[(0,b.jsxs)(`section`,{className:`bg-white rounded-lg border`,children:[(0,b.jsxs)(`div`,{className:`px-5 py-3 border-b font-bold flex items-center gap-2`,children:[(0,b.jsx)(d,{className:`w-4 h-4 text-orange-500`}),` Saved addresses`]}),(0,b.jsxs)(`div`,{className:`p-5 space-y-3`,children:[T.length===0&&(0,b.jsx)(`p`,{className:`text-sm text-neutral-500`,children:`No addresses yet.`}),T.map(e=>(0,b.jsxs)(`div`,{className:`border rounded-md p-3 flex items-start gap-3`,children:[(0,b.jsxs)(`div`,{className:`flex-1 text-sm`,children:[(0,b.jsxs)(`div`,{className:`font-medium`,children:[e.name,` · `,e.phone]}),(0,b.jsxs)(`div`,{className:`text-neutral-500 text-xs`,children:[e.street,`, `,e.city,`, `,e.state]})]}),(0,b.jsx)(`button`,{onClick:()=>O(e.id),className:`text-neutral-400 hover:text-red-500`,children:(0,b.jsx)(i,{className:`w-4 h-4`})})]},e.id)),(0,b.jsxs)(`form`,{className:`border-t pt-3 space-y-2`,onSubmit:e=>{e.preventDefault(),!(!k.name||!k.phone||!k.street)&&(D(k),A({name:``,phone:``,street:``,city:``,state:``}),p.success(`Address added`))},children:[(0,b.jsx)(`div`,{className:`text-xs font-semibold text-neutral-600`,children:`Add new address`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,b.jsx)(h,{placeholder:`Full name`,value:k.name,onChange:e=>A({...k,name:e.target.value})}),(0,b.jsx)(h,{placeholder:`Phone`,value:k.phone,onChange:e=>A({...k,phone:e.target.value})})]}),(0,b.jsx)(h,{placeholder:`Street address`,value:k.street,onChange:e=>A({...k,street:e.target.value})}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,b.jsx)(h,{placeholder:`City`,value:k.city,onChange:e=>A({...k,city:e.target.value})}),(0,b.jsx)(h,{placeholder:`State`,value:k.state,onChange:e=>A({...k,state:e.target.value})})]}),(0,b.jsxs)(g,{type:`submit`,size:`sm`,className:`bg-orange-500 hover:bg-orange-600`,children:[(0,b.jsx)(u,{className:`w-4 h-4 mr-1`}),` Add address`]})]})]})]}),(0,b.jsxs)(`section`,{className:`bg-white rounded-lg border`,children:[(0,b.jsxs)(`div`,{className:`px-5 py-3 border-b font-bold flex items-center gap-2`,children:[(0,b.jsx)(f,{className:`w-4 h-4 text-orange-500`}),` Purchase history`]}),E.length===0?(0,b.jsx)(`div`,{className:`p-10 text-center text-sm text-neutral-500`,children:`You haven't placed any orders yet.`}):(0,b.jsx)(`div`,{className:`divide-y`,children:E.map(e=>(0,b.jsxs)(r,{to:`/orders/$id`,params:{id:e.id},className:`flex items-center gap-4 p-4 hover:bg-neutral-50`,children:[(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-sm font-medium`,children:e.id}),(0,b.jsxs)(`div`,{className:`text-xs text-neutral-500`,children:[new Date(e.createdAt).toLocaleDateString(),` · `,e.items.length,` item`,e.items.length===1?``:`s`,` · `,_[e.status]]})]}),(0,b.jsxs)(`div`,{className:`text-sm font-bold`,children:[`₦ `,v(e.total)]}),(0,b.jsx)(`span`,{className:`text-orange-500 text-sm`,children:`Track →`})]},e.id))})]})]})]}):(0,b.jsxs)(`div`,{className:`bg-white rounded-lg border p-10 text-center`,children:[(0,b.jsx)(a,{className:`w-12 h-12 text-orange-500 mx-auto mb-3`}),(0,b.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Sign in to view your account`}),(0,b.jsx)(g,{onClick:()=>t(!0),className:`mt-5 bg-orange-500 hover:bg-orange-600`,children:`Sign in`})]})})]})}export{x as component};