import{j as e}from"./jsx-runtime.D_zvdyIk.js";import{r as o}from"./index.DIfZGIpv.js";import{A as g,a as v,u as y}from"./AdminAuth.CbzFS552.js";import{A as c}from"./AdminLayout.CKC2eNsX.js";import{C as N,l as S,R as x,X as m,Y as h,T as u}from"./CartesianChart.zfG3JjV4.js";import{B as k,a as A}from"./BarChart.Dgp66h7A.js";import{L as C}from"./Line.zFZ1Y-pA.js";import"./index.cthNB-FE.js";import"./index.XeJbqeyU.js";import"./getRadiusAndStrokeWidthFromDot.D5m1f1P6.js";var T=["axis"],L=o.forwardRef((i,t)=>o.createElement(N,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:T,tooltipPayloadSearcher:S,categoricalChartProps:i,ref:t}));function n({label:i,value:t,icon:d,sub:l}){return e.jsxs("div",{className:"bg-[#141414] border border-[#333] rounded-xl p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-[#999] text-sm",children:i}),e.jsx("span",{className:"text-lg",children:d})]}),e.jsx("div",{className:"text-2xl font-bold text-[#F5F5F5]",children:t}),l&&e.jsx("div",{className:"text-xs text-[#666] mt-1",children:l})]})}function F(){const{token:i}=y(),[t,d]=o.useState(null),[l,f]=o.useState([]),[j,b]=o.useState(!0);if(o.useEffect(()=>{const s={Authorization:`Bearer ${i}`};Promise.all([fetch("/api/admin/stats",{headers:s}).then(r=>r.json()),fetch("/api/admin/analytics?type=timeseries&days=30",{headers:s}).then(r=>r.json())]).then(([r,a])=>{d(r),f(a.data||[])}).catch(()=>{}).finally(()=>b(!1))},[i]),j)return e.jsx(c,{title:"Dashboard",children:e.jsx("div",{className:"flex items-center justify-center h-64 text-[#666]",children:"Laden..."})});const p=s=>{if(!s)return"Nooit";const r=new Date(s),a=Math.floor((Date.now()-r.getTime())/6e4);return a<1?"Zojuist":a<60?`${a} min geleden`:a<1440?`${Math.floor(a/60)} uur geleden`:`${Math.floor(a/1440)} dagen geleden`};return e.jsxs(c,{title:"Dashboard",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-4 mb-8",children:[e.jsx(n,{label:"Sneakers",value:Number(t?.total_sneakers||0).toLocaleString(),icon:"👟"}),e.jsx(n,{label:"Totaal producten",value:Number(t?.total_products||0).toLocaleString(),icon:"📦"}),e.jsx(n,{label:"Actieve feeds",value:Number(t?.active_feeds||0),icon:"📡"}),e.jsx(n,{label:"Clicks vandaag",value:Number(t?.clicks_today||0).toLocaleString(),icon:"🖱️"}),e.jsx(n,{label:"Revenue (maand)",value:`€${Number(t?.revenue_month||0).toFixed(2)}`,icon:"💰"}),e.jsx(n,{label:"Laatste sync",value:p(t?.last_sync_at||null),icon:"🔄"})]}),l.length===0?e.jsxs("div",{className:"bg-[#141414] border border-[#333] rounded-xl p-8 text-center",children:[e.jsx("div",{className:"text-[#666] text-lg mb-2",children:"📊"}),e.jsx("div",{className:"text-[#999] text-sm",children:"Nog geen analytics data"}),e.jsx("div",{className:"text-[#666] text-xs mt-1",children:"Data verschijnt hier zodra er clicks en conversies binnenkomen"})]}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"bg-[#141414] border border-[#333] rounded-xl p-5",children:[e.jsx("h3",{className:"text-sm font-medium text-[#999] mb-4",children:"Clicks (30 dagen)"}),e.jsx(x,{width:"100%",height:200,children:e.jsxs(k,{data:l,children:[e.jsx(m,{dataKey:"date",tick:{fill:"#666",fontSize:10},tickFormatter:s=>s.slice(5)}),e.jsx(h,{tick:{fill:"#666",fontSize:10}}),e.jsx(u,{contentStyle:{background:"#1A1A1A",border:"1px solid #333",borderRadius:8},labelStyle:{color:"#999"}}),e.jsx(A,{dataKey:"clicks",fill:"#00FF6A",radius:[2,2,0,0]})]})})]}),e.jsxs("div",{className:"bg-[#141414] border border-[#333] rounded-xl p-5",children:[e.jsx("h3",{className:"text-sm font-medium text-[#999] mb-4",children:"Revenue (30 dagen)"}),e.jsx(x,{width:"100%",height:200,children:e.jsxs(L,{data:l,children:[e.jsx(m,{dataKey:"date",tick:{fill:"#666",fontSize:10},tickFormatter:s=>s.slice(5)}),e.jsx(h,{tick:{fill:"#666",fontSize:10}}),e.jsx(u,{contentStyle:{background:"#1A1A1A",border:"1px solid #333",borderRadius:8},labelStyle:{color:"#999"}}),e.jsx(C,{type:"monotone",dataKey:"revenue",stroke:"#00FF6A",strokeWidth:2,dot:!1})]})})]})]})]})}function M(){return e.jsx(g,{children:e.jsx(v,{children:e.jsx(F,{})})})}export{M as default};
