PageSourceSearch

https://lelabodeclairie.com/assets/admin.avatars-BPDd227a.js

js lelabodeclairie.com collected 2026-10-09 22:04:10 UTC 15,136 bytes, 1 lines download raw bytes

1import{$ as F,u as p,aa as D,r as x,a as h,j as e,U as q,S as w,L as U,aG as j,aH as f,a2 as S,V as g,aB as R}from"./index-CCfEC8G7.js";import{a as T,b as P,c as Q,d as E,e as K,f as G}from"./avatar.functions-DnFJDNAn.js";import{I as z}from"./image-Cf_qZIiI.js";import{E as I}from"./external-link-ByoNMKmj.js";import{S as $}from"./search-eMefx4TB.js";import{R as H}from"./rotate-ccw-D4UADRwa.js";import{T as V}from"./trash-2-CHsEDVeo.js";const B=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],C=F("gauge",B);function te(){const s=p(T),o=p(P),n=p(Q),i=D(),[v,N]=x.useState(""),[t,_]=x.useState("all"),[u,b]=x.useState(null),{data:l,isLoading:m}=h({queryKey:["admin-avatars"],queryFn:()=>s()}),{data:a}=h({queryKey:["admin-avatars-members"],queryFn:()=>o()}),{data:k}=h({queryKey:["admin-avatars-stats"],queryFn:()=>n()}),L=x.useMemo(()=>{const r=new Map;return(l?.overrides??[]).forEach(c=>r.set(c.user_id,{daily_limit:c.daily_limit,expires_at:c.expires_at})),r},[l]),A=x.useMemo(()=>{const r=a?.members??[],c=v.trim().toLowerCase();return r.filter(y=>!(t==="with"&&!y.avatar_url||t==="without"&&y.avatar_url||c&&!(y.display_name??"").toLowerCase().includes(c)))},[a,v,t]),M=()=>b(null);return e.jsxs("div",{className:"mx-auto max-w-6xl px-4 py-6 md:px-6 md:py-8",children:[e.jsxs("header",{className:"mb-6",children:[e.jsx("p",{className:"mono-label text-[color:var(--mute)]",children:"Supervision"}),e.jsx("h1",{className:"mt-1 text-2xl font-extrabold tracking-tight md:text-3xl",children:"Avatars IA"}),e.jsx("p",{className:"mt-1 text-sm text-[color:var(--mute)]",children:"Visualise les avatars Pixar générés, surveille l'usage du quota et accompagne les membres."})]}),m||!l?e.jsx(O,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-4",children:[e.jsx(d,{icon:e.jsx(q,{size:16}),label:"Membres",value:l.stats.total_users}),e.jsx(d,{icon:e.jsx(z,{size:16}),label:"Avatars générés",value:l.stats.users_with_avatar}),e.jsx(d,{icon:e.jsx(w,{size:16}),label:"Générations aujourd'hui",value:l.stats.generated_today}),e.jsx(d,{icon:e.jsx(C,{size:16}),label:"Quota / jour",value:l.stats.daily_limit})]}),k&&e.jsx(X,{stats:k}),l.stats.users_with_avatar===0&&e.jsxs("div",{className:"mt-6 rounded-2xl border border-dashed p-5 text-sm",style:{borderColor:"color-mix(in srgb, var(--brand-orange-brule) 35%, transparent)",background:"color-mix(in srgb, var(--brand-orange-brule) 6%, white)"},children:[e.jsx("p",{className:"font-extrabold text-[color:var(--ink)]",children:"Aucun avatar IA n'a encore été généré ✨"}),e.jsx("p",{className:"mt-1 text-[color:var(--ink-soft)]",children:"Le parcours est prêt — il manque juste une première génération pour amorcer la galerie. Lance la tienne depuis ton profil."}),e.jsxs(U,{to:"/profil/edit",className:"mt-3 inline-flex items-center gap-1.5 rounded-full bg-[color:var(--brand-orange-brule)] px-4 py-2 text-xs font-bold text-white shadow",children:[e.jsx(w,{size:14})," Générer mon avatar",e.jsx(I,{size:12})]})]}),e.jsxs("section",{className:"mt-8",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("h2",{className:"text-lg font-extrabold",children:"Top générateurs"}),e.jsxs("p",{className:"text-[10px] uppercase tracking-wider text-[color:var(--mute)]",children:[l.top_generators.length," membre(s)"]})]}),l.top_generators.length===0?e.jsx("p",{className:"mt-3 text-sm text-[color:var(--mute)]",children:"Aucun générateur encore."}):e.jsx("ul",{className:"mt-3 grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-5",children:l.top_generators.map(r=>e.jsx("li",{children:e.jsxs("button",{onClick:()=>b(r.user_id),className:"w-full rounded-2xl border border-[color:var(--line)] bg-white p-3 text-center transition hover:border-[color:var(--ink)] hover:shadow-sm",children:[e.jsx("div",{className:"mx-auto h-16 w-16 overflow-hidden rounded-full",children:e.jsx(j,{avatarUrl:r.avatar_url,fallbackConfig:f,size:64,alt:r.display_name??""})}),e.jsx("p",{className:"mt-2 truncate text-xs font-bold",children:r.display_name??"—"}),e.jsxs("p",{className:"text-[10px] text-[color:var(--mute)]",children:[r.avatar_generation_count," générations"]})]})},r.user_id))})]}),e.jsxs("section",{className:"mt-8",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("h2",{className:"text-lg font-extrabold",children:"Membres"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 sm:flex-none",children:[e.jsx($,{size:14,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-[color:var(--mute)]"}
1),e.jsx("input",{type:"text",value:v,onChange:r=>N(r.target.value),placeholder:"Rechercher…",className:"w-full rounded-full border border-[color:var(--line)] bg-white py-2 pl-9 pr-3 text-sm outline-none focus:border-[color:var(--ink)] sm:w-56"})]}),e.jsx("div",{className:"flex rounded-full border border-[color:var(--line)] bg-white p-1",children:["all","with","without"].map(r=>e.jsx("button",{onClick:()=>_(r),className:`rounded-full px-3 py-1 text-[11px] font-bold uppercase tracking-wider transition ${t===r?"bg-[color:var(--ink)] text-white":"text-[color:var(--mute)]"}`,children:r==="all"?"Tous":r==="with"?"Avec avatar":"Sans avatar"},r))})]})]}),A.length===0?e.jsx("p",{className:"mt-4 text-sm text-[color:var(--mute)]",children:"Aucun membre ne correspond."}):e.jsx("ul",{className:"mt-4 grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6",children:A.map(r=>{const c=L.get(r.user_id);return e.jsx("li",{children:e.jsxs("button",{onClick:()=>b(r.user_id),className:"group relative w-full rounded-2xl border border-[color:var(--line)] bg-white p-3 text-center transition hover:border-[color:var(--ink)] hover:shadow-sm",children:[c&&e.jsxs("span",{className:"absolute right-2 top-2 rounded-full px-1.5 py-0.5 text-[9px] font-bold text-white",style:{background:"var(--brand-violet)"},children:[c.daily_limit,"/j"]}),e.jsx("div",{className:"mx-auto h-20 w-20 overflow-hidden rounded-full",children:e.jsx(j,{avatarUrl:r.avatar_url,fallbackConfig:f,size:80,alt:r.display_name??""})}),e.jsx("p",{className:"mt-2 truncate text-xs font-bold",children:r.display_name??"—"}),e.jsx("p",{className:"text-[10px] text-[color:var(--mute)]",children:r.avatar_generated_at?new Date(r.avatar_generated_at).toLocaleDateString():"Jamais"})]})},r.user_id)})})]})]}),u&&e.jsx(J,{userId:u,onClose:M,onChanged:()=>{i.invalidateQueries({queryKey:["admin-avatars"]}),i.invalidateQueries({queryKey:["admin-avatars-members"]}),i.invalidateQueries({queryKey:["admin-avatars-member",u]})}})]})}function J({userId:s,onClose:o,onChanged:n}){const i=p(E),v=p(K),N=p(G),{data:t,isLoading:_}=h({queryKey:["admin-avatars-member",s],queryFn:()=>i({data:{user_id:s}})}),[u,b]=x.useState(""),l=S({mutationFn:()=>v({data:{user_id:s,purge_files:!0}}),onSuccess:()=>{g.success("Avatar et fichiers supprimés"),n()},onError:a=>g.error(a.message)}),m=S({mutationFn:a=>N({data:{user_id:s,daily_limit:a}}),onSuccess:()=>{g.success("Quota mis à jour"),n()},onError:a=>g.error(a.message)});return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-end justify-center sm:items-center",role:"dialog",children:[e.jsx("div",{className:"absolute inset-0 bg-black/40",onClick:o,"aria-hidden":!0}),e.jsxs("div",{className:"relative max-h-[92vh] w-full max-w-2xl overflow-y-auto rounded-t-3xl bg-white p-5 sm:rounded-3xl",style:{paddingBottom:"calc(1.25rem + env(safe-area-inset-bottom))"},children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"mono-label text-[color:var(--mute)]",children:"Membre"}),e.jsx("h2",{className:"text-xl font-extrabold",children:t?.profile?.display_name??"Membre"}),t?.profile?.avatar_generated_at&&e.jsxs("p",{className:"text-xs text-[color:var(--mute)]",children:["Dernier avatar le ",new Date(t.profile.avatar_generated_at).toLocaleString()]})]}),e.jsx("button",{onClick:o,"aria-label":"Fermer",className:"inline-flex h-9 w-9 items-center justify-center rounded-full text-[color:var(--mute)] hover:bg-[color:var(--bg)]",children:e.jsx(R,{size:18})})]}),_?e.jsx("p",{className:"mt-6 text-sm text-[color:var(--mute)]",children:"Chargement…"}):e.jsxs(e.Fragment,{children:[t?.profile?.avatar_url&&e.jsxs("div",{className:"mt-4 flex items-center gap-4 roun
1ded-2xl border border-[color:var(--line)] p-3",children:[e.jsx("div",{className:"h-20 w-20 overflow-hidden rounded-full",children:e.jsx(j,{avatarUrl:t.profile.avatar_url,fallbackConfig:t.profile.avatar_config??f,size:80,alt:t.profile.display_name??""})}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-bold",children:"Avatar actif"}),e.jsxs("p",{className:"text-[color:var(--mute)]",children:[t.profile.avatar_generation_count??0," générations cumulées"]})]})]}),e.jsxs("section",{className:"mt-5 rounded-2xl border border-[color:var(--line)] p-4",children:[e.jsx("p",{className:"text-sm font-bold",children:"Quota personnalisé"}),e.jsx("p",{className:"mt-1 text-xs text-[color:var(--mute)]",children:'Par défaut 10/jour. Indique un nombre pour le relever, puis valide. Laisse vide et clique "Retirer" pour revenir au défaut.'}),t?.override&&e.jsxs("p",{className:"mt-2 inline-block rounded-full bg-[color:var(--brand-violet)]/10 px-3 py-1 text-xs font-bold text-[color:var(--brand-violet)]",children:["Actuel : ",t.override.daily_limit,"/jour",t.override.expires_at&&` (jusqu'au ${new Date(t.override.expires_at).toLocaleDateString()})`]}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsx("input",{type:"number",min:0,max:200,value:u,onChange:a=>b(a.target.value),placeholder:`${t?.override?.daily_limit??10}`,className:"w-28 rounded-full border border-[color:var(--line)] bg-white px-3 py-2 text-sm outline-none focus:border-[color:var(--ink)]"}),e.jsx("button",{onClick:()=>{const a=Number(u);if(!Number.isFinite(a)||a<0||a>200){g.error("Valeur entre 0 et 200");return}m.mutate(a)},disabled:m.isPending||!u,className:"rounded-full bg-[color:var(--ink)] px-4 py-2 text-xs font-bold text-white disabled:opacity-50",children:"Appliquer"}),t?.override&&e.jsx("button",{onClick:()=>m.mutate(null),disabled:m.isPending,className:"rounded-full border border-[color:var(--line)] px-4 py-2 text-xs font-bold text-[color:var(--ink-soft)] hover:bg-[color:var(--bg)]",children:"Retirer"})]})]}),e.jsxs("section",{className:"mt-5",children:[e.jsxs("p",{className:"text-sm font-bold",children:["Historique (",t?.history.length??0,")"]}),(t?.history.length??0)===0?e.jsx("p",{className:"mt-2 text-xs text-[color:var(--mute)]",children:"Aucune génération enregistrée."}):e.jsx("ul",{className:"mt-3 grid grid-cols-3 gap-2 sm:grid-cols-4",children:t.history.map(a=>e.jsxs("li",{className:"rounded-xl border border-[color:var(--line)] bg-white p-2 text-center",title:a.error_message??a.status,children:[e.jsx("div",{className:"aspect-square overflow-hidden rounded-lg bg-[color:var(--bg)]",children:a.avatar_url?e.jsx("img",{src:a.avatar_url,alt:"",className:"h-full w-full object-cover",loading:"lazy"}):e.jsx("div",{className:"flex h-full items-center justify-center text-[10px] text-[color:var(--mute)]",children:a.status})}),e.jsx("p",{className:"mt-1 truncate text-[10px] text-[color:var(--mute)]",children:new Date(a.created_at).toLocaleDateString()}),e.jsx("p",{className:`text-[9px] font-bold uppercase ${a.status==="success"?"text-[color:var(--brand-vert)]":a.status==="quota_blocked"?"text-[color:var(--brand-orange-brule)]":"text-[color:var(--brand-rouge)]"}`,children:a.status})]},a.id))})]}),e.jsxs("section",{className:"mt-5 rounded-2xl border border-[color:var(--brand-rouge)]/30 bg-[color:var(--brand-rouge)]/5 p-4",children:[e.jsx("p",{className:"text-sm font-bold text-[color:var(--brand-rouge)]",children:"Réinitialiser"}),e.jsx("p",{className:"mt-1 text-xs text-[color:var(--ink-soft)]",children:"Supprime l'avatar actif, remet le compteur quotidien à zéro et purge les fichiers stockés."}),e.jsxs("button",{onClick:()=>{confirm("Confirmer la réinitialisation complète ?")&&l.mutate()},disabled:l.isPending,className:"mt-3 inline-flex items-center gap-1.5 rounded-full bg-[color:var(--brand-rouge)] px-4 py-2 text-xs font-bold text-white disabled:opacity-50",children:[l.isPending?e.jsx(H,{size:12,className:"animate-spin"}):e.jsx(V,{size:12}),"Réinitialiser"]})]})]})]})]})}function d({icon:s,label:o,value:n}){return e.jsxs("div",{className:"rounded-2xl border border-[color:var(--line)] bg-white p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[color:var(--mute)]",children:[s,e.jsx("span",{className:"mono-label text-[10px]",children:o})]}),e.jsx("p",{className:"mt-2 text-2xl font-extrabold tracking-tight",children:n})]})}function O(){return e.jsx("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-4",children:Array.from({length:4}).map((s,o)=>e.jsx("div",{className:"h-24 animate-pulse rounded-2xl border border-[color:var(--line)] bg-white"},o))})}function X({stats:s}){const o=s.success_rate_7d<80&&s.generations_7d>5,n=!s.last_purge||Date.now()-new Date(s.last_purge.started_at).getTime()>36*36e5;return e.jsxs("section",{className:"mt-6",children:[(o||n)&&e.jsxs("div",{className:"mb-4 rounded-2xl border p-3 text-sm",style:{borderColor:"color-mix(in srgb, var(--brand-orange-brule) 35%, transparent)",background:"color-mix(in srgb, var(--brand-orange-brule) 8%, white)"},children:[o&&e.jsxs("p",{children:["⚠️ Taux de succès 7j : ",s.success_rate_7d,"% (sous 80%)."]}),n&&e.jsxs("p",{children:["🕒 Aucune purge depuis >36h — vérifie le cron ",e.jsx("code",{children:"purge-avatars"}),"."]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 md:grid-cols-4",children:[e.jsx(d,{icon:e.jsx(w,{size:16}),label:"Succès 7j",value:s.success_7d}),e.jsx(d,{icon:e.jsx(C,{size:16}),label:"Taux succès 7j",value:s.success_rate_7d}),e.jsx(d,{icon:e.jsx(q,{size:16}),label:"Bloqués quota 7j",value:s.blocked_7d}),e.jsx(d,{icon:e.jsx(z,{size:16}),label:"Stockage (Mo)",value:s.storage_size_mb})]}),s.top_users_7d.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"mono-label text-[10px] text-[color:var(--mute)]",children:"Top 5 (7j)"}),e.jsx("ul",{className:"mt-2 flex flex-wrap gap-2",children:s.top_users_7d.map(i=>e.jsxs("li",{className:"inline-flex items-center gap-2 rounded-full border border-[color:var(--line)] bg-white py-1 pl-1 pr-3 text-xs",children:[e.jsx("div",{className:"h-6 w-6 overflow-hidden rounded-full",children:e.jsx(j,{avatarUrl:i.avatar_url,fallbackConfig:f,size:24,alt:""})}),e.jsx("span",{className:"font-bold",children:i.display_name??"—"}),e.jsxs("span",{className:"text-[color:var(--mute)]",children:["×",i.count]})]}
1,i.user_id))})]}),s.last_purge&&e.jsxs("p",{className:"mt-3 text-[11px] text-[color:var(--mute)]",children:["Dernière purge : ",new Date(s.last_purge.started_at).toLocaleString()," —"," ",e.jsx("span",{className:"font-bold",children:s.last_purge.status})]})]})}export{te as component};

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.