PageSourceSearch

https://twinforgefit.ai/assets/AdminFeedback-D3NVCwph.js

js twinforgefit.ai collected 2026-10-05 14:31:53 UTC 13,720 bytes, 1 lines download raw bytes

1import{j as e}from"./motion-CghpQXKE.js";import{r,L as z}from"./router-epi9CWfp.js";import{A as J}from"./AdminTabs-CCJH3r_r.js";import{A as G}from"./AdminPageHeader-B8DHzsUR.js";import{C as f}from"./Chip-CIa43c9D.js";import{E as U,f as W,I as Z}from"./components-Cgk8aYfE.js";import{s as X,aJ as ee,ad as V,z as te,a5 as se}from"./index-_-9kgWZ5.js";import{S as ae}from"./search-BLNachTO.js";import{M as re}from"./message-square-Pi7e8k7F.js";import{A as ne}from"./AdminPanel-bKqOIV2b.js";import{K as N}from"./KpiCard-DstGqr2F.js";import{M as O}from"./message-square-quote-O_oYtgMg.js";import"./supabase-CTBn71hm.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"19ca80bcc68db376b793c8a886be03b6d5ea8a5c"};var a=new s.Error().stack;a&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[a]="bddfcb4c-1c1b-44d7-a4a1-2d48d2c6a447",s._sentryDebugIdIdentifier="sentry-dbid-bddfcb4c-1c1b-44d7-a4a1-2d48d2c6a447")}catch{}})();async function k(s){const{data:a,error:n}=await X.functions.invoke("admin-feedback",{body:s});if(n)throw n;if(a?.error)throw new Error(String(a.error));return a}const ie={whatsapp:"WhatsApp",web:"Web",unknown:"Inconnue"};function le({source:s}){return e.jsx("span",{className:"inline-flex items-center whitespace-nowrap rounded border border-white/10 bg-white/5 px-1.5 py-0.5 text-[10px] font-medium text-text-secondary",children:ie[s]??s})}const ce={idea:"Idée",problem:"Problème",praise:"Compliment",technical:"Souci technique",open:"Question ouverte"},q={idea:"bg-accent/10 text-accent border-accent/20",problem:"bg-warning/15 text-warning border-warning/30",praise:"bg-success/15 text-success border-success/30",technical:"bg-error/15 text-error border-error/30",open:"bg-white/5 text-text-tertiary border-white/10"};function oe({kind:s}){return e.jsx("span",{className:`inline-flex items-center whitespace-nowrap rounded border px-1.5 py-0.5 text-[10px] font-semibold ${q[s]??q.open}`,children:ce[s]??s})}const de={new:"Nouveau",read:"Lu",done:"Traité"},ue={new:"bg-accent/15 text-accent border-accent/30",read:"bg-white/5 text-text-secondary border-white/10",done:"bg-success/15 text-success border-success/30"};function xe({status:s}){return e.jsx("span",{className:`inline-flex items-center whitespace-nowrap rounded border px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wider ${ue[s]}`,children:de[s]})}function H({truncated:s}){return s?e.jsx("p",{role:"status",className:"mb-4 rounded-lg border border-warning/30 bg-warning/10 p-3 text-xs text-warning",children:"La fenêtre a atteint le plafond de lecture du serveur : cette liste n’est pas exhaustive. Resserre la période pour tout voir."}):null}const F=50,me=[{label:"Tous",value:""},{label:"Nouveaux",value:"new"},{label:"Lus",value:"read"},{label:"Traités",value:"done"}],pe=[{label:"Toutes",value:""},{label:"Web",value:"web"},{label:"WhatsApp",value:"whatsapp"}],be=[{label:"Toutes",value:""},{label:"Idée",value:"idea"},{label:"Problème",value:"problem"},{label:"Compliment",value:"praise"},{label:"Souci technique",value:"technical"}],he=[{label:"7j",hours:168},{label:"30j",hours:720},{label:"90j",hours:2160},{label:"Tout",hours:365*24}];function fe({text:s}){const[a,n]=r.useState(!1);return s.trim()?e.jsxs("div",{children:[e.jsx("p",{className:`whitespace-pre-wrap break-words text-sm leading-relaxed text-text-primary ${a?"":"line-clamp-6"}`,children:s}),s.length>400&&e.jsx("button",{type:"button",onClick:()=>n(c=>!c),className:"mt-1 text-xs font-medium text-accent hover:underline",children:a?"Replier":"Lire la suite"})]}):e.jsx("p",{className:"text-sm italic text-text-tertiary",children:"Verbatim vide."})}function ge({item:s}){const a=s.user;if(!a)return e.jsx("span",{className:"text-xs text-text-tertiary",children:"Auteur introuvable"});const n=[a.first_name,a.email,a.whatsapp_number].filter(Boolean);return e.jsx("span",{className:"text-xs text-text-tertiary",children:n.join(" · ")||a.id})}function je({refreshTick:s}){const[a,n]=r.useState(""),[c,o]=r.useState(""),[i,u]=r.useState(""),[l,x]=r.useState(2160),[p,m]=r.useState(!1),[E,Q]=r.useState(""),[T,Y]=r.useState(""),[b,g]=r.useState(1),[S,C]=r.useState(null),[A,I]=r.useState(!1),[L,j]=r.useState(null),[R,P]=r.useState(null);r.useEffect(()=>{let t=!1;async function _(){I(!0),j(null);try{const d=await k({action:"list",status:a||void 0,source:c||void 0,kind:i||void 0,wants_reply:p||void 0,search:T.trim()||void 0,since_hours:l,page:b,page_size:F});t||C(d)}catch(d){t||j(d instanceof Error?d.message:"Erreur inconnue")}finally{t||I(!1)}}return _(),()=>{t=!0}},[a,c,i,l,p,T,b,s]);const h=r.useCallback(t=>{g(1),t()},[]),D=r.useCallback(async(t,_)=>{P(t.id),j(null);
1try{const d=await k({action:"set_status",feedback_id:t.id,new_status:_});if(d.item){const B=d.item;C(v=>v&&{...v,items:v.items.map(w=>w.id===B.id?{...w,...B,user:w.user}:w)})}}catch(d){j(d instanceof Error?d.message:"Changement de statut impossible")}finally{P(null)}},[]),M=S?.total??0,y=Math.max(1,Math.ceil(M/F)),$=S?.items??[];return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-5 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider text-text-tertiary",children:"Statut"}),me.map(t=>e.jsx(f,{label:t.label,selected:a===t.value,onClick:()=>h(()=>n(t.value))},t.label))]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider text-text-tertiary",children:"Provenance"}),pe.map(t=>e.jsx(f,{label:t.label,selected:c===t.value,onClick:()=>h(()=>o(t.value))},t.label))]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider text-text-tertiary",children:"Nature"}),be.map(t=>e.jsx(f,{label:t.label,selected:i===t.value,onClick:()=>h(()=>u(t.value))},t.label))]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider text-text-tertiary",children:"Période"}),he.map(t=>e.jsx(f,{label:t.label,selected:l===t.hours,onClick:()=>h(()=>x(t.hours))},t.label)),e.jsx(f,{label:"Réponse demandée",selected:p,onClick:()=>h(()=>m(t=>!t))})]}),e.jsxs("form",{onSubmit:t=>{t.preventDefault(),g(1),Y(E)},className:"flex items-center gap-2",children:[e.jsx("label",{htmlFor:"feedback-search",className:"sr-only",children:"Rechercher dans les verbatims"}),e.jsx("input",{id:"feedback-search",value:E,onChange:t=>Q(t.target.value),placeholder:"Rechercher dans les verbatims…",className:"min-h-11 flex-1 rounded-xl border border-white/10 bg-surface px-3 py-2 text-sm text-text-primary placeholder-text-tertiary focus-visible:border-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"}),e.jsxs("button",{type:"submit",className:"inline-flex min-h-11 items-center gap-2 rounded-xl border border-white/10 px-3 text-sm text-text-secondary transition-colors hover:bg-white/5",children:[e.jsx(ae,{className:"h-4 w-4","aria-hidden":"true"}),"Chercher"]})]})]}),L&&e.jsx(U,{error:L}),e.jsx(H,{truncated:S?.truncated??!1}),e.jsx("p",{className:"mb-3 text-xs text-text-tertiary",children:A?"Chargement…":`${M} avis`}),!A&&$.length===0&&e.jsxs("div",{className:"rounded-xl border border-white/10 bg-surface p-8 text-center",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:"Aucun avis sur cette période."}),e.jsx("p",{className:"mt-1 text-xs text-text-tertiary",children:"Élargis la fenêtre ou retire un filtre — les verbatims WhatsApp du J+14 remontent ici dès qu’ils existent."})]}),e.jsx("ul",{className:"space-y-3",children:$.map(t=>e.jsxs("li",{className:"rounded-xl border border-white/10 bg-surface p-4",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[e.jsx(xe,{status:t.admin_status}),e.jsx(le,{source:t.source}),e.jsx(oe,{kind:t.kind}),t.medium==="audio"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-text-tertiary",title:"Réponse envoyée en vocal, puis transcrite",children:[e.jsx(ee,{className:"h-3 w-3","aria-hidden":"true"}),"Vocal"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-text-tertiary",children:[e.jsx(re,{className:"h-3 w-3","aria-hidden":"true"}),"Texte"]}),t.wants_reply&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-accent/30 bg-accent/10 px-1.5 py-0.5 text-[10px] font-semibold text-accent",children:[e.jsx(V,{className:"h-3 w-3","aria-hidden":"true"}),"Réponse demandée"]}),e.jsx("span",{className:"ml-auto font-mono-numbers text-[11px] text-text-tertiary",children:W(t.created_at)})]}),e.jsx(fe,{text:t.text}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-3 border-t border-white/5 pt-3",children:[e.jsx(ge,{item:t}),e.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[e.jsx(z,{to:`/admin/users/${t.user_id}/communications`,className:"min-h-11 rounded-lg px-2 py-1 text-xs font-medium text-accent transition-colors hover:bg-white/5",children:"Voir la conversation"}),t.wants_reply&&t.user?.email&&e.jsx("a",{href:`mailto:${t.user.email}?subject=${encodeURIComponent("Ton retour sur TwinForge")}`,className:"min-h-11 rounded-lg px-2 py-1 text-xs font-medium text-accent transition-colors hover:bg-white/5",children:"Répondre par e-mail"}),t.admin_status!=="read"&&e.jsx("button",{type:"button",disabled:R===t.id,onClick:()=>D(t,"read"),className:"min-h-11 rounded-lg border border-white/10 px-2 py-1 text-xs text-text-secondary transition-colors hover:bg-white/5 disabled:opacity-40",children:"Marquer lu"}),t.admin_status!=="done"&&e.jsx("button",{type:"button",disabled:R===t.id,onClick:()=>D(t,"done"),className:"min-h-11 rounded-lg border border-white/10 px-2 py-1 text-xs text-text-secondary transition-colors hover:bg-white/5 disabled:opacity-40",children:"Marquer traité"})]})]}),t.reviewed_by&&e.jsxs("p",{className:"mt-2 text-[11px] text-text-tertiary",children:[t.admin_note?`« ${t.admin_note} » — `:"",t.reviewed_by,t.reviewed_at?` · ${W(t.reviewed_at)}`:""]})]},t.id))}),y>1&&e.jsxs("div",{className:"mt-5 flex items-center justify-center gap-3",children:[e.jsx("button",{type:"button",disabled:b<=1,onClick:()=>g(t=>Math.max(1,t-1)),className:"min-h-11 rounded-lg border border-white/10 px-3 text-sm text-text-secondary transition-colors hover:bg-white/5 disabled:opacity-40",children:"Précédent"}),e.jsxs("span",{className:"font-mono-numbers text-xs text-text-tertiary",children:[b," / ",y]}),e.jsx("button",{type:"button",disabled:b>=y,onClick:()=>g(t=>Math.min(y,t+1)),className:"min-h-11 rounded-lg border border-white/10 px-3 text-sm text-text-secondary transition-colors hover:bg-white/5 disabled:opacity-40",children:"Suivant"})]})]})}const ye={whatsapp:"WhatsApp",web:"Web",unknown:"Provenance inconnue"},ve={idea:"Idée",problem:"Problème",praise:"Compliment",technical:"Souci technique",open:"Question ouverte"};function K({title:s,data:a,labels:n}){const c=Object.entries(a).sort((o,i)=>i[1]-o[1]);return e.jsxs(ne,{children:[e.jsx("h3",{className:"mb-3 text-sm font-semibold text-text-primary",children:s}),c.length===0?e.jsx("p",{className:"text-xs text-text-tertiary",children:"Aucune donnée sur cette période."}):e.jsx("ul",{className:"space-y-1.5",children:c.map(([o,i])=>e.jsxs("li",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-text-secondary",children:n[o]??o}),e.jsx("span",{className:"font-mono-numbers text-text-primary",children:i})]},o))})]})}function we({refreshTick:s}){const[a,n]=r.useState(null),[c,o]=r.useState(!1),[i,u]=r.useState(null);if(r.useEffect(()=>{let x=!1;async function p(){o(!0),u(null);try{const m=await k({action:"stats",since_hours:8760});x||n(m)}catch(m){x||u(m instanceof Error?m.message:"Erreur inconnue")}finally{x||o(!1)}}return p(),()=>{x=!0}},[s]),i)return e.jsx(U,{error:i});if(c&&!a)return e.jsx("p",{className:"text-sm text-text-tertiary",children:"Chargement…"});if(!a)return null;const{stats:l}=a;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(H,{truncated:a.truncated}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[e.jsx(N,{icon:Z,label:"Non lus",value:String(l.unread_count),sublabel:"à lire",alert:l.unread_count>0}),e.jsx(N,{icon:O,label:"Total",value:String(l.total),sublabel:"sur 12 mois"}),e.jsx(N,{icon:te,label:"30 derniers jours",value:String(l.last_30d)}),e.jsx(N,{icon:V,label:"Réponse demandée",value:String(l.wants_reply_count),sublabel:"attendent un mot"})]}),e.jsxs("div",{className:"grid gap-3 lg:grid-cols-2",children:[e.jsx(K,{title:"Par provenance",data:l.by_source,labels:ye}),e.jsx(K,{title:"Par nature",data:l.by_kind,labels:ve})]})]})}const Ne=[{key:"verbatims",label:"Avis"},{key:"summary",label:"Synthèse"}];function $e(){const[s,a]=r.useState("verbatims"),[n,c]=r.useState(0),[o,i]=r.useState(!1),u=()=>{i(!0),c(l=>l+1),setTimeout(()=>i(!1),600)};return e.jsxs("div",{className:"mx-auto max-w-7xl p-6",children:[e.jsx(G,{icon:O,t
1itle:"Avis",subtitle:"Verbatims utilisateurs — web et WhatsApp, dans une seule liste.",actions:e.jsx("button",{onClick:u,className:"rounded-lg p-1.5 text-text-tertiary transition-colors hover:bg-white/5 hover:text-text-primary","aria-label":"Rafraîchir",children:e.jsx(se,{className:`h-4 w-4 ${o?"animate-spin":""}`})})}),e.jsx("div",{className:"mb-5",children:e.jsx(J,{tabs:Ne,active:s,onChange:a,layoutIdPrefix:"admin-feedback"})}),s==="verbatims"&&e.jsx(je,{refreshTick:n}),s==="summary"&&e.jsx(we,{refreshTick:n})]})}export{$e as AdminFeedback};

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.