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,I as a,d as o,n as s,r as c,t as l}from"./Modals-BkPPnKoF.js";import{t as u}from"./package-DzDt_BEJ.js";import{S as d,t as f,y as p}from"./index-BFZg1haX.js";var m=e(n()),h=t();function g(){let{id:e}=f.useParams(),[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(!1),[a,u]=(0,m.useState)(!1),{vendors:p}=d(),g=p.find(t=>t.id===e);return(0,h.jsxs)(`div`,{className:`min-h-screen bg-neutral-50`,children:[(0,h.jsx)(c,{open:t,onOpenChange:n}),(0,h.jsx)(l,{open:r,onOpenChange:i,onCheckout:()=>{i(!1),u(!0)}}),(0,h.jsx)(s,{open:a,onOpenChange:u}),(0,h.jsx)(o,{onOpenCart:()=>i(!0),onOpenSignIn:()=>n(!0)}),(0,h.jsx)(`main`,{className:`max-w-[1100px] mx-auto px-4 py-8`,children:g?(0,h.jsx)(_,{vendorEmail:g.contactEmail,vendorName:g.contactName,businessName:g.businessName}):(0,h.jsx)(`div`,{className:`text-center py-20 text-neutral-500`,children:`Vendor not found`})})]})}function _({vendorEmail:e,vendorName:t,businessName:n}){let{vendorProducts:o,removeProduct:s}=d(),c=o.filter(t=>t.vendorEmail===e);return(0,h.jsxs)(`div`,{className:`space-y-6`,children:[(0,h.jsxs)(`div`,{className:`flex items-end justify-between`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`text-xs text-neutral-500 mb-1 flex items-center gap-1`,children:[(0,h.jsx)(r,{to:`/admin`,className:`hover:underline`,children:`Admin`}),(0,h.jsx)(`span`,{children:`/`}),(0,h.jsx)(`span`,{children:`Vendors`})]}),(0,h.jsxs)(`h1`,{className:`text-2xl font-bold flex items-center gap-2`,children:[(0,h.jsx)(a,{className:`w-6 h-6 text-orange-500`}),` `,n,` (Admin View)`]}),(0,h.jsxs)(`p`,{className:`text-sm text-neutral-500`,children:[`Managing products for `,t,`. Active listings: `,c.length,`.`]})]}),(0,h.jsxs)(`div`,{className:`flex gap-3`,children:[(0,h.jsx)(v,{label:`Listings`,value:String(c.length)}),(0,h.jsx)(v,{label:`Status`,value:`Active`,tone:`emerald`})]})]}),(0,h.jsx)(`div`,{className:`grid grid-cols-3 gap-6`,children:(0,h.jsxs)(`div`,{className:`col-span-3 bg-white rounded-lg border`,children:[(0,h.jsx)(`div`,{className:`px-5 py-3 border-b font-bold flex items-center justify-between`,children:(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(u,{className:`w-4 h-4`}),` Listings`]})}),c.length===0?(0,h.jsx)(`div`,{className:`p-10 text-center text-sm text-neutral-500`,children:`No products yet.`}):(0,h.jsx)(`div`,{className:`divide-y`,children:c.map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-4 p-4`,children:[(0,h.jsx)(`img`,{src:e.images?.[0]||`https://picsum.photos/seed/${e.seed}/80/80`,alt:e.name,className:`w-14 h-14 rounded object-cover`}),(0,h.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,h.jsx)(`div`,{className:`text-sm font-medium line-clamp-1`,children:e.name}),(0,h.jsx)(`div`,{className:`text-xs text-neutral-500`,children:e.category})]}),(0,h.jsxs)(`div`,{className:`text-sm font-bold`,children:[`₦ `,p(e.price)]}),(0,h.jsx)(`button`,{onClick:()=>{confirm(`Delete this product?`)&&s(e.id)},className:`text-neutral-400 hover:text-red-500`,children:(0,h.jsx)(i,{className:`w-4 h-4`})})]},e.id))})]})})]})}function v({label:e,value:t,tone:n}){return(0,h.jsxs)(`div`,{className:`px-4 py-2 rounded-md border ${n===`emerald`?`bg-emerald-50 border-emerald-200 text-emerald-700`:`bg-white`}`,children:[(0,h.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-neutral-500`,children:e}),(0,h.jsx)(`div`,{className:`font-bold text-sm`,children:t})]})}export{g as component};