1import{a as P,a1 as D,r as p,s as m,j as s,B as h,L as l,C as i,e as N,f as v,g as _,d,aX as M,bJ as S}from"./index-C-GMF1w8.js";import{u as $}from"./usePro-BuuQN__I.js";import{P as F}from"./ProBadge-C9iufluc.js";import{M as T}from"./mouse-pointer-click-CTpu46ks.js";import{E as z}from"./euro-BkdJzRnr.js";import"./badge-check-DYCNfIID.js";function X(){var g,f;const{user:n}=P(),{status:u,subscription:c}=$(),{t:e,currentLanguage:b}=D(),y={nl:"nl-BE",fr:"fr-BE",de:"de-DE",en:"en-GB"}[b.code]??"nl-BE",[j,C]=p.useState([]),[a,k]=p.useState({clicks:0,impressions:0,spent:0});p.useEffect(()=>{n&&(async()=>{const{data:t}=await m.from("admarkt_campaigns").select("*, products(title)").eq("user_id",n.id).order("created_at",{ascending:!1});C(t??[]);const r=(t??[]).map(x=>x.id);if(r.length){const[{count:x},{count:w}]=await Promise.all([m.from("admarkt_clicks").select("*",{count:"exact",head:!0}).in("campaign_id",r),m.from("admarkt_impressions").select("*",{count:"exact",head:!0}).in("campaign_id",r)]),E=(t??[]).reduce((L,B)=>L+(B.spent_total_cents??0),0);k({clicks:x??0,impressions:w??0,spent:E})}})()},[n==null?void 0:n.id]);const o=t=>`â¬${(t/100).toFixed(2)}`;return s.jsxs("div",{className:"container max-w-6xl mx-auto py-8 px-4 space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h1",{className:"text-3xl font-bold",children:e("pro.dash.title")}),u.isPro&&s.jsx(F,{verified:u.verified,size:"md"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(h,{asChild:!0,variant:"outline",children:s.jsx(l,{to:"/pro/subscription",children:e("pro.dash.subscription")})}),s.jsx(h,{asChild:!0,children:s.jsx(l,{to:"/seller/dashboard",children:e("pro.dash.myListings")})})]})]}),c&&s.jsx(i,{children:s.jsxs(N,{children:[s.jsxs(v,{children:[e("pro.dash.activeSub"),": ",(g=c.pro_subscription_tiers)==null?void 0:g.name]}),s.jsxs(_,{children:[e("pro.dash.expires")," ",new Date(c.current_period_end).toLocaleDateString(y)," â â¬",Number(((f=c.pro_subscription_tiers)==null?void 0:f.price_monthly)??0).toFixed(2),e("pro.common.perMonth")]})]})}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(i,{children:s.jsxs(d,{className:"pt-6",children:[s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[s.jsx(M,{className:"h-4 w-4"})," ",e("pro.dash.impressions")]}),s.jsx("div",{className:"text-2xl font-bold",children:a.impressions.toLocaleString()})]})}),s.jsx(i,{children:s.jsxs(d,{className:"pt-6",children:[s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[s.jsx(T,{className:"h-4 w-4"})," ",e("pro.dash.clicks")]}),s.jsx("div",{className:"text-2xl font-bold",children:a.clicks.toLocaleString()})]})}),s.jsx(i,{children:s.jsxs(d,{className:"pt-6",children:[s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[s.jsx(S,{className:"h-4 w-4"})," ",e("pro.dash.ctr")]}),s.jsxs("div",{className:"text-2xl font-bold",children:[a.impressions?(a.clicks/a.impressions*100).toFixed(2):"0.00","%"]})]})}),s.jsx(i,{children:s.jsxs(d,{className:"pt-6",children:[s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground text-sm",children:[s.jsx(z,{className:"h-4 w-4"})," ",e("pro.dash.spent")]}),s.jsx("div",{className:"text-2xl font-bold",children:o(a.spent)})]})})]}),s.jsxs(i,{children:[s.jsxs(N,{children:[s.jsx(v,{children:e("pro.dash.campaigns")}),s.jsx(_,{children:e("pro.dash.campaignsDesc")})]}),s.jsxs(d,{children:[j.length===0&&s.jsx("p",{className:"text-sm text-muted-foreground",children:e("pro.dash.noCampaigns")}),s.jsx("div",{className:"space-y-2",children:j.map(t=>{var r;return s.jsxs("div",{className:"flex items-center justify-between border rounded-lg p-3 text-sm",children:[s.jsxs("div",{children:[s.jsx(l,{to:`/product/${t.product_id}`,className:"font-medium hover:underline",children:((r=t.products)==null?void 0:r.title)??t.product_id.slice(0,8)}),s.jsxs("div",{className:"text-muted-foreground text-xs",children:[e("pro.dash.bid"),": ",o(t.cpc_bid_cents),e("pro.dash.perClick")," · ",e("pro.dash.today"),": ",o(t.spent_today_cents)," · ",e("pro.dash.thisMonth"),": ",o(t.spent_month_cents)]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-xs px-2 py-1 rounded ${t.status==="active"?"bg-green-100 text-green-800":t.status==="depleted"?"bg-orange-100 text-orange-800":"bg-gray-100 text-gray-800"}`,children:t.status}),s.jsx(h,{asChild:!0,size:"sm",variant:"outline",children:s.jsx(l,{to:`/pro/campaigns/${t.product_id}`,children:e("pro.dash.manage")})})]})]},t.id)})})]})]})]})}export{X 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.