PageSourceSearch

https://agenceweb-proenvue.lovable.app/assets/DcTrackingAdminPage-TZUOUCP3.js

js agenceweb-proenvue.lovable.app collected 2026-10-03 03:20:11 UTC 11,832 bytes, 1 lines download raw bytes

1import{r as x,j as e,aO as C,aP as S,a9 as G,aQ as R,aR as q,i as O,a as b,S as M,B as v,Y as K,_ as U,$ as w,a0 as _,E as X,aU as D,O as Y,ab as I,G as L,am as z,b as i,e as m,f as h,c,aV as Q,aW as W,aX as Z,aY as H,aZ as J,a_ as ee,a$ as se,L as $,b0 as ae,C as F,a6 as re,a2 as te,aG as ne,s as T,u as g}from"./index-D3v-3Oo3.js";const ie={transfer_ownership:"Transfert de fiche",suspend_listing:"Suspendre fiche",reactivate_listing:"Réactiver fiche",refund_subscription:"Rembourser abonnement",change_tier:"Changer de palier",force_revoke:"Révoquer certif",delete_listing:"Supprimer fiche",grant_admin_access:"Accorder accès admin",revoke_admin_access:"Retirer accès admin",override_score:"Forcer score",other:"Autre"};function le(){const[t,y]=x.useState(null),[k,u]=x.useState(!0),[j,A]=x.useState(null),[p,P]=x.useState({}),[E,f]=x.useState(null),N=async()=>{u(!0),A(null);try{const{data:s,error:a}=await T.functions.invoke("dc-admin-tracking-overview");if(a)throw a;if(s!=null&&s.error)throw new Error(s.error);y(s)}catch(s){A(s.message??"Erreur de chargement")}finally{u(!1)}};x.useEffect(()=>{N()},[]);const V=async s=>{f(s);try{const{data:a,error:l}=await T.rpc("approve_dc_admin_action",{_action_id:s,_review_notes:p[s]||null});if(l)throw l;const r=a;if(!(r!=null&&r.success))throw new Error((r==null?void 0:r.detail)||(r==null?void 0:r.error)||"Erreur");g.success("Action approuvée — il faut maintenant l'exécuter dans le module concerné"),N()}catch(a){g.error(a.message)}finally{f(null)}},B=async s=>{if(!p[s]||p[s].trim().length<3){g.error("Motif de rejet requis (≥ 3 caractères)");return}f(s);try{const{data:a,error:l}=await T.rpc("reject_dc_admin_action",{_action_id:s,_review_notes:p[s]});if(l)throw l;const r=a;if(!(r!=null&&r.success))throw new Error((r==null?void 0:r.error)||"Erreur");g.success("Action rejetée"),N()}catch(a){g.error(a.message)}finally{f(null)}};if(k)return e.jsxs("div",{className:"container max-w-7xl py-8 space-y-4",children:[e.jsx(C,{className:"h-10 w-72"}),e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:Array.from({length:4}).map((s,a)=>e.jsx(C,{className:"h-28"},a))}),e.jsx(C,{className:"h-64"})]});if(j||!t)return e.jsx("div",{className:"container max-w-3xl py-8",children:e.jsxs(S,{variant:"destructive",children:[e.jsx(G,{className:"h-4 w-4"}),e.jsx(R,{children:"Erreur"}),e.jsx(q,{children:j??"Données indisponibles"})]})});const n=t.totals_30d,o=t.pending_admin_actions;return e.jsxs("div",{className:"container max-w-7xl py-8 space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl font-bold tracking-tight flex items-center gap-2",children:[e.jsx(O,{className:"h-8 w-8 text-primary"}),"Tracking Annuaire DC — Vue admin"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Stats globales du trafic monétisable + double commande pour les actions sensibles."})]}),e.jsx(b,{variant:"outline",onClick:N,children:"🔄 Rafraîchir"})]}),e.jsxs(S,{className:"border-amber-300 bg-amber-50/40 dark:bg-amber-950/20",children:[e.jsx(M,{className:"h-4 w-4 text-amber-700"}),e.jsxs(R,{className:"text-amber-900 dark:text-amber-100",children:["Mode double commande actif",o.length>0&&e.jsxs(v,{className:"ml-2 bg-amber-600",children:[o.length," en attente"]})]}),e.jsxs(q,{className:"text-amber-800 dark:text-amber-200",children:["Toute action sensible (suspendre une fiche, rembourser, transférer, révoquer…) doit être ",e.jsx("strong",{children:"proposée"})," par un admin, puis ",e.jsx("strong",{children:"approuvée par un autre admin"}),". Tant que tu es seul admin opérationnel, tes propositions resteront en attente jusqu'à ton approbation depuis un second compte. Pour déléguer, ajoute un second admin via /admin/employees."]})]}),e.jsxs(K,{defaultValue:"overview",className:"space-y-6",children:[e.jsxs(U,{children:[e.jsx(w,{value:"overview",children:"Vue d'ensemble"}),e.jsx(w,{value:"movers",children:"Top fiches"}),e.jsx(w,{value:"audience",children:"Audience"}),e.jsxs(w,{value:"approvals",children:["File d'approbation",o.length>0&&e.jsx(v,{className:"ml-2 bg-amber-600 h-5",children:o.length})]})]}),e.jsxs(_,{value:"overview",className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsx(d,{label:"Impressions 30j",value:n.impressions,icon:e.jsx(X,{className:"h-5 w-5"})}),e.jsx(d,{label:"Clics 30j",value:n.clicks,icon:e.jsx(D,{className:"h-5 w-5"}),accent:!0}),e.jsx(d,{label:"CTR moyen",value:n.ctr_pct!=null?`${n.ctr_pct}%`:"—",icon:e.jsx(Y,{className:"h-5 w-5"})}),e.jsx(d,{label:"Visiteurs uniques",value:n.unique_sessions,icon:e.jsx(I,{className:"h-5 w-5"})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(d,{label:"Sites web cliqués",value:n.website_clicks,icon:e.jsx(L,{className:"h-4 w-4"}),small:!0}),e.jsx(d,{label:"Avis Google cliqués",value:n.reviews_clicks,icon:e.jsx(z,{className:"h-4 w-4"}),small:!0}),e.jsx(d,{label:"Devis demandés",value:n.quote_clicks,icon:e.jsx(D,{className:"h-4 w-4"}),small:!0})]}),e.jsxs(i,{children:[e.jsx(m,{children:e.jsx(h,{className:"text-base",children:"Tendance des clics — 30 derniers jours"})}),e.jsx(c,{children:t.daily_trend.length>0?e.jsx(Q,{width:"100%",height:260,children:e.jsxs(W,{data:t.daily_trend,children:[e.jsx(Z,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(H,{dataKey:"date",tick:{fontSize:11}}),e.jsx(J,{tick:{fontSize:11}}),e.jsx(ee,{}),e.jsx(se,{type:"monotone",dataKey:"clicks",stroke:"hsl(var(--primary))",strokeWidth:2,dot:!1})]})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-12",children:"Pas encore de clic enregistré."})})]})]}),e.jsx(_,{value:"movers",className:"space-y-3",children:e.jsxs(i,{children:[e.jsx(m,{children:e.jsx(h,{className:"text-base",children:"Top 20 — fiches les plus cliquées (30j)"})}),e.jsx(c,{className:"p-0",children:t.top_movers.length===0?e.jsx("p",{className:"text-sm text-muted-foreground p-6 text-center",children:"Aucun trafic enregistré."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-xs uppercase",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-3",children:"Fiche"}),e.jsx("th",{className:"text-left p-3",children:"Zone"}),e.jsx("th",{className:"text-right p-3",children:"Vues"}),e.jsx("th",{className:"text-right p-3",children:"Clics"}),e.jsx("th",{className:"text-right p-3",children:"CTR"}),e.jsx("th",{className:"p-3"})]})}),e.jsx("tbody",{children:t.top_movers.map(s=>e.jsxs("tr",{className:"border-t",children:[e.jsxs("td",{className:"p-3",children:[e.jsx("div",{className:"font-medium",children:s.name}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[s.dc_grade&&e.jsxs(v,{variant:"outline",className:"h-4 text-[10px]",children:[s.dc_grade,"★"]}
1),s.vat_id&&e.jsx("code",{children:s.vat_id})]})]}),e.jsxs("td",{className:"p-3 text-muted-foreground",children:[s.country??"—"," · ",s.zone??"—"]}),e.jsx("td",{className:"p-3 text-right tabular-nums",children:s.impressions}),e.jsx("td",{className:"p-3 text-right tabular-nums font-semibold",children:s.clicks}),e.jsx("td",{className:"p-3 text-right tabular-nums",children:s.ctr!=null?`${s.ctr}%`:"—"}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(b,{size:"sm",variant:"ghost",asChild:!0,children:e.jsx($,{to:`/annuaire/detail/${s.directory_id}`,children:"Fiche"})}),s.vat_id&&e.jsx(b,{size:"sm",variant:"ghost",asChild:!0,children:e.jsx($,{to:`/dc/stats/${s.vat_id}`,children:"Stats DC"})})]})})]},s.directory_id))})]})})})]})}),e.jsxs(_,{value:"audience",className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(i,{children:[e.jsx(m,{children:e.jsxs(h,{className:"text-base flex items-center gap-2",children:[e.jsx(ae,{className:"h-4 w-4"})," Devices"]})}),e.jsx(c,{children:Object.entries(t.breakdown.by_device).length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"—"}):Object.entries(t.breakdown.by_device).sort((s,a)=>a[1]-s[1]).map(([s,a])=>e.jsxs("div",{className:"flex justify-between py-1 text-sm",children:[e.jsx("span",{className:"capitalize",children:s}),e.jsx("span",{className:"tabular-nums font-medium",children:a})]},s))})]}),e.jsxs(i,{children:[e.jsx(m,{children:e.jsxs(h,{className:"text-base flex items-center gap-2",children:[e.jsx(L,{className:"h-4 w-4"})," Top pays"]})}),e.jsx(c,{children:t.breakdown.top_countries.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"—"}):t.breakdown.top_countries.map(([s,a])=>e.jsxs("div",{className:"flex justify-between py-1 text-sm",children:[e.jsx("span",{children:s}),e.jsx("span",{className:"tabular-nums font-medium",children:a})]},s))})]}),e.jsxs(i,{children:[e.jsx(m,{children:e.jsxs(h,{className:"text-base flex items-center gap-2",children:[e.jsx(z,{className:"h-4 w-4"})," Top sources"]})}),e.jsx(c,{children:t.breakdown.top_referers.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"—"}):t.breakdown.top_referers.map(([s,a])=>e.jsxs("div",{className:"flex justify-between py-1 text-sm",children:[e.jsx("span",{className:"truncate",children:s}),e.jsx("span",{className:"tabular-nums font-medium ml-2",children:a})]},s))})]})]}),e.jsx(_,{value:"approvals",className:"space-y-3",children:o.length===0?e.jsx(i,{children:e.jsxs(c,{className:"py-12 text-center space-y-2",children:[e.jsx(F,{className:"h-12 w-12 mx-auto text-green-600"}),e.jsx("p",{className:"font-medium",children:"Aucune action en attente."}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Quand un admin propose une action sensible, elle apparaît ici pour approbation."})]})}):o.map(s=>e.jsxs(i,{className:"border-amber-300/50",children:[e.jsx(m,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs(h,{className:"text-base flex items-center gap-2",children:[e.jsx(re,{className:"h-4 w-4"}),ie[s.action_type]??s.action_type]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Proposée le ",new Date(s.proposed_at).toLocaleString("fr-FR"),s.vat_id&&e.jsxs(e.Fragment,{children:[" · Cible : ",e.jsx("code",{children:s.vat_id})]})]})]}),e.jsx(v,{variant:"outline",className:"border-amber-400 text-amber-700",children:"En attente"})]})}),e.jsxs(c,{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase text-muted-foreground mb-1",children:"Motif"}),e.jsx("p",{className:"text-sm bg-muted/40 rounded p-2",children:s.reason})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-semibold uppercase text-muted-foreground mb-1 block",children:"Note de revue (obligatoire pour rejet)"}),e.jsx(te,{placeholder:"Justifie ta décision...",value:p[s.id]??"",onChange:a=>P(l=>({...l,[s.id]:a.target.value})),rows:2})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>B(s.id),disabled:E===s.id,children:[e.jsx(ne,{className:"h-4 w-4 mr-1"})," Rejeter"]}),e.jsxs(b,{size:"sm",onClick:()=>V(s.id),disabled:E===s.id,children:[e.jsx(F,{className:"h-4 w-4 mr-1"})," Approuver"]})]})]})]},s.id))})]})]})}function d({label:t,value:y,icon:k,accent:u,small:j}){return e.jsx(i,{className:u?"border-primary/40":"",children:e.jsxs(c,{className:j?"p-4":"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1 text-muted-foreground",children:[e.jsx("span",{className:"text-xs uppercase font-semibold tracking-wide",children:t}),k]}),e.jsx("p",{className:`tabular-nums font-bold ${j?"text-xl":"text-3xl"} ${u?"text-primary":""}`,children:y})]})})}export{le 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.