import{j as e}from"./ui-vendor-DUfjpZ4p.js";import{r as a,L as i}from"./react-vendor-DlVMRrtE.js";import{u as x,s as u,am as h,B as n,S as f,C as d,d as l,F as j,H as y,e as g,E as w}from"./index-BKwmLAPt.js";import"./charts-vendor-wgDUSDZK.js";import"./supabase-vendor-Bd7R0Yn5.js";const B=()=>{const{user:t}=x(),[p,o]=a.useState(!0),[c,m]=a.useState([]);return a.useEffect(()=>{t&&(async()=>{o(!0);const{data:s}=await u.from("importer_report_requests").select("id,importer_profile_id,report_type,payment_status,amount_usd,created_at,paystack_reference,importer_profiles(company_name,country,industry,trust_score)").eq("supplier_user_id",t.id).eq("payment_status","paid").order("created_at",{ascending:!1});m(s||[]),o(!1)})()},[t]),p?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(h,{className:"h-4 w-4 animate-spin"})," Loading…"]}):e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-heading text-3xl font-bold",children:"My Reports"}),e.jsx("p",{className:"text-muted-foreground font-body",children:"Verified importer reports you have purchased."})]}),e.jsx(n,{asChild:!0,children:e.jsxs(i,{to:"/portal/importer-network/directory",children:[e.jsx(f,{className:"h-4 w-4 mr-2"})," Browse Directory"]})})]}),c.length===0?e.jsx(d,{children:e.jsxs(l,{className:"p-10 text-center space-y-3",children:[e.jsx(j,{className:"h-12 w-12 mx-auto text-muted-foreground opacity-30"}),e.jsx("h3",{className:"font-heading text-lg font-semibold",children:"You haven't purchased any reports yet"}),e.jsx("p",{className:"font-body text-muted-foreground",children:"Browse the verified importer directory and purchase a Basic or Full Due Diligence report."}),e.jsx(n,{asChild:!0,children:e.jsx(i,{to:"/portal/importer-network/directory",children:"Browse Importers"})})]})}):e.jsx("div",{className:"space-y-3",children:c.map(s=>{const r=s.importer_profiles||{};return e.jsx(d,{className:"hover:shadow-md transition-shadow",children:e.jsxs(l,{className:"p-4 flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[e.jsx("div",{className:"p-2 rounded-lg bg-accent/10 flex-shrink-0",children:e.jsx(y,{className:"h-5 w-5 text-accent"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-heading font-semibold text-foreground truncate",children:r.company_name||"Importer"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground font-body mt-0.5",children:[r.country&&e.jsx("span",{children:r.country}),r.industry&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:r.industry})]}),e.jsx("span",{children:"·"}),e.jsxs(g,{variant:"outline",className:"capitalize text-xs",children:[s.report_type==="full"?"Full Due Diligence":"Basic"," Report"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:new Date(s.created_at).toLocaleDateString()})]})]})]}),e.jsx(n,{asChild:!0,size:"sm",className:"gap-1",children:e.jsxs(i,{to:`/portal/importer-network/report/${s.importer_profile_id}/${s.report_type}`,children:[e.jsx(w,{className:"h-3.5 w-3.5"})," View & Download"]})})]})},s.id)})})]})};export{B as default};
