1import{r as u,j as e,I as N}from"./index-CyZ-pQAp.js";import{u as C,a as _,P as T}from"./useAdCampaigns-TT5nePDV.js";import{C as b}from"./card-DrHtq4Bk.js";import{S as v,a as S,b as y,c as w,d as F}from"./select-CN_M89Vx.js";import{T as M,a as A,b as l,c as n,d as L,e as a}from"./table-CMi6u7Ia.js";import{T as I,a as P,b as d}from"./tabs-CC1hS0xq.js";import"./index-CW3DgE6K.js";import"./chevron-up-DzuG9eeF.js";const o=s=>s==null||!isFinite(s)?"â":new Intl.NumberFormat("vi-VN").format(Math.round(s)),x=s=>s==null||!isFinite(s)?"â":s.toFixed(2),R=s=>s==null||!isFinite(s)?"â":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(s);function G(){const{data:s,isLoading:m}=C(),p=_(),[i,j]=u.useState("all"),[c,g]=u.useState(""),h=(s??[]).filter(t=>{var r;return!(i==="mapped"&&!t.product_type||i==="unmapped"&&t.product_type||c&&!((r=t.campaign_name)!=null&&r.toLowerCase().includes(c.toLowerCase())))});return e.jsxs("div",{className:"max-w-6xl mx-auto p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Map Campaign â Sản phẩm"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Gắn từng campaign quảng cáo và o loại sản phẩm tương ứng Äá» tÃnh lợi nhuáºn chÃnh xác."})]}),e.jsxs("div",{className:"flex gap-3 items-center",children:[e.jsx(I,{value:i,onValueChange:t=>j(t),children:e.jsxs(P,{children:[e.jsxs(d,{value:"all",children:["Tất cả (",(s==null?void 0:s.length)??0,")"]}),e.jsxs(d,{value:"unmapped",children:["Chưa map (",(s==null?void 0:s.filter(t=>!t.product_type).length)??0,")"]}),e.jsxs(d,{value:"mapped",children:["Äã map (",(s==null?void 0:s.filter(t=>t.product_type).length)??0,")"]})]})}),e.jsx(N,{placeholder:"Tìm campaign...",value:c,onChange:t=>g(t.target.value),className:"max-w-xs"})]}),e.jsx(b,{children:e.jsxs(M,{children:[e.jsx(A,{children:e.jsxs(l,{children:[e.jsx(n,{children:"Campaign"}),e.jsx(n,{children:"Account"}),e.jsx(n,{className:"text-right",children:"Chi phà 30 ngà y"}),e.jsx(n,{className:"text-right",children:"CPC"}),e.jsx(n,{className:"text-right",children:"CPM"}),e.jsx(n,{className:"text-right",children:"CTR %"}),e.jsx(n,{className:"text-right",children:"Tần suất"}),e.jsx(n,{className:"text-right",children:"Conversion"}),e.jsx(n,{className:"text-right",children:"ROAS"}),e.jsx(n,{children:"Sản phẩm"})]})}),e.jsxs(L,{children:[m&&e.jsx(l,{children:e.jsx(a,{colSpan:10,children:"Äang tải..."})}),!m&&h.length===0&&e.jsx(l,{children:e.jsx(a,{colSpan:10,className:"text-center text-muted-foreground py-8",children:'Chưa có campaign nà o. Bấm "Äá»ng bá» ngay" á» trang Meta Accounts Äá» pull data.'})}),h.map(t=>e.jsxs(l,{children:[e.jsx(a,{className:"font-medium",children:t.campaign_name}),e.jsx(a,{className:"text-xs text-muted-foreground",children:t.account_id}),e.jsxs(a,{className:"text-right font-mono",children:[o(t.spend_30d_vnd),"Ä"]}),e.jsxs(a,{className:"text-right font-mono text-xs",children:[o(Math.round(t.cpc_30d)),"Ä"]}),e.jsxs(a,{className:"text-right font-mono text-xs",children:[o(Math.round(t.cpm_30d)),"Ä"]}),e.jsxs(a,{className:"text-right font-mono text-xs",children:[x(t.ctr_30d),"%"]}),e.jsx(a,{className:"text-right font-mono text-xs",children:x(t.frequency_30d)}),e.jsx(a,{className:"text-right font-mono text-xs",children:R(t.conversion_value_usd_30d)}),e.jsx(a,{className:"text-right font-mono text-xs",children:x(t.roas_30d)}),e.jsx(a,{children:e.jsxs(v,{value:t.product_type??"",onValueChange:r=>p.mutate({id:t.id,product_type:r||null}),children:[e.jsx(S,{className:"w-48",children:e.jsx(y,{placeholder:"-- Chưa map --"})}),e.jsx(w,{children:Object.entries(T).map(([r,f])=>e.jsx(F,{value:r,children:f},r))})]})})]},t.id))]})]})})]})}export{G 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.