1import{c as X,r as n,j as e,P as ye,b as B,aj as be,ak as oe,al as le,am as ve,X as _e,an as ce,ao as de,ap as we,aq as Se,B as w,L as z,u as p,f as S,I as q,ar as ke,af as me,x as ue}from"./index-BR8-L3Ms.js";import{B as xe}from"./badge-btj7n9vB.js";import{T as Ce,a as Ee,b as Z,c as $,d as Le,e as k}from"./table-BwA0VZFQ.js";import{S as K,a as Y,b as ee,c as se,d as V}from"./select-DahO_Qc7.js";import{T as te}from"./textarea-D8qNcOfD.js";import{n as I,L as W,E as ae,s as A,S as Re}from"./leadWorkflow-BHuTp-ot.js";import{M as $e}from"./mail-B6zylq_j.js";import{S as Ae}from"./send-CU0Iq30X.js";import{H as Te}from"./history-CXk-dOsc.js";import{S as Me}from"./switch-CjmhcWcn.js";import{L as De}from"./label-BepDHRv8.js";import{A as Pe}from"./arrow-left-BI-IZyLM.js";import{R as qe}from"./refresh-cw-DT3oZIEA.js";import{D as Ie}from"./download-wclQp03T.js";import{S as Be}from"./search-DDi96SPZ.js";import{L as Oe}from"./lock-Pi9kg18e.js";import"./index-BdY2-Hnu.js";import"./chevron-down-CVfd9ot9.js";import"./chevron-up-BecW2VyZ.js";import"./check-DOu8STRj.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ze=X("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Fe=X("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const Ve=X("StickyNote",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]]);var Ue="Separator",re="horizontal",He=["horizontal","vertical"],he=n.forwardRef((s,o)=>{const{decorative:l,orientation:d=re,...c}=s,f=Ze(d)?d:re,i=l?{role:"none"}:{"aria-orientation":f==="vertical"?f:void 0,role:"separator"};return e.jsx(ye.div,{"data-orientation":f,...i,...c,ref:o})});he.displayName=Ue;function Ze(s){return He.includes(s)}var pe=he;const U=n.forwardRef(({className:s,orientation:o="horizontal",decorative:l=!0,...d},c)=>e.jsx(pe,{ref:c,decorative:l,orientation:o,className:B("shrink-0 bg-border",o==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",s),...d}));U.displayName=pe.displayName;const Qe=be,We=we,fe=n.forwardRef(({className:s,...o},l)=>e.jsx(oe,{className:B("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...o,ref:l}));fe.displayName=oe.displayName;const Xe=Se("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),ge=n.forwardRef(({side:s="right",className:o,children:l,...d},c)=>e.jsxs(We,{children:[e.jsx(fe,{}),e.jsxs(le,{ref:c,className:B(Xe({side:s}),o),...d,children:[l,e.jsxs(ve,{className:"absolute right-4 top-4 roun
16ded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[e.jsx(_e,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ge.displayName=le.displayName;const je=({className:s,...o})=>e.jsx("div",{className:B("flex flex-col space-y-2 text-center sm:text-left",s),...o});je.displayName="SheetHeader";const Ne=n.forwardRef(({className:s,...o},l)=>e.jsx(ce,{ref:l,className:B("text-lg font-semibold text-foreground",s),...o}));Ne.displayName=ce.displayName;const Ge=n.forwardRef(({className:s,...o},l)=>e.jsx(de,{ref:l,className:B("text-sm text-muted-foreground",s),...o}));Ge.displayName=de.displayName;const v=S,C=s=>s?new Date(s).toLocaleString("fr-FR",{dateStyle:"short",timeStyle:"short"}):"â";function Je({lead:s,open:o,onOpenChange:l,onUpdated:d}){const[c,f]=n.useState([]),[y,i]=n.useState([]),[j,E]=n.useState([]),[L,T]=n.useState(""),[M,R]=n.useState(""),[_,h]=n.useState(null),m=s==null?void 0:s.id,b=I(s==null?void 0:s.status),D=async()=>{if(!m)return;const[a,x,N]=await Promise.all([v.from("lead_status_history").select("*").eq("lead_id",m).order("created_at",{ascending:!1}),v.from("lead_notes").select("*").eq("lead_id",m).order("created_at",{ascending:!1}),v.from("lead_email_log").select("*").eq("lead_id",m).order("created_at",{ascending:!1})]);f(a.data||[]),i(x.data||[]),E(N.data||[])};n.useEffect(()=>{o&&D()},[o,m]);const P=async a=>{var G,J;if(!m||a===b)return;h("status-".concat(a));const x=new Date().toISOString(),N={status:a,last_status_change_at:x},t=Re[a];t&&(N[t]=x);const{error:r}=await v.from("leads").update(N).eq("id",m);if(r){p.error("Changement de statut impossible"),h(null);return}const{data:u}=await S.auth.getUser();await v.from("lead_status_history").insert({lead_id:m,from_status:b,to_status:a,note:M.trim()||null,changed_by:(J=(G=u==null?void 0:u.user)==null?void 0:G.id)!=null?J:null}),v.functions.invoke("crm-export",{body:{leadId:m,event:"status_change",previousStatus:b}}).catch(()=>{}),F({type:"status_change",title:"Statut mis à jour : ".concat(A(a).label),body:"".concat([s.first_name,s.last_name].filter(Boolean).join(" ")||"Demande"," (").concat(s.city||"â",") est passé de « ").concat(A(b).label," » à « ").concat(A(a).label," ».").concat(M.trim()?" Note : ".concat(M.trim()):""),leadId:m}),R(""),p.success("Statut : ".concat(A(a).label)),await D(),d(),h(null)},F=a=>v.functions.invoke("notify-admin",{body:a}).catch(()=>{}),O=async()=>{var N,t;if(!m||!L.trim())return;h("note");const{data:a}=await S.auth.getUser(),{error:x}=await v.from("lead_notes").insert({lead_id:m,content:L.trim(),author_id:(t=(N=a==null?void 0:a.user)==null?void 0:N.id)!=null?t:null});x?p.error("Note non enregistrée"):(T(""),p.success("Note interne ajoutée"),await D()),h(null)},g=async a=>{var t,r;if(!m)return;h("mail-".concat(a));const{data:x,error:N}=await v.functions.invoke("send-lead-email",{body:{leadId:m,template:a}});N||x!=null&&x.error?p.error((x==null?void 0:x.error)||"Envoi impossible"):(p.success("E-mail envoyé au client"),F({type:"email_sent",title:"E-mail client envoyé : ".concat((r=(t=ae.find(u=>u.key===a))==null?void 0:t.label)!=null?r:a),body:"Destinataire : ".concat(s.email," â ").concat([s.first_name,s.last_name].filter(Boolean).join(" ")," (").concat(s.city||"â",")."),leadId:m})),await D(),h(null)},H=async()=>{if(!m)return;h("crm");const{data:a,error:x}=await v.functions.invoke("crm-export",{body:{leadId:m,event:"manual"}});x||a!=null&&a.error?p.error((a==null?void 0:a.error)||"Export CRM impossible"):a!=null&&a.skipped?p.info("Export ignoré : ".concat(a.skipped)):p.success("Lead envoyé au CRM"),h(null)};return s?e.jsx(Qe,{open:o,onOpenChange:l,children:e.jsxs(ge,{side:"right",className:"w-full sm:max-w-xl overflow-y-auto",children:[e.jsx(je,{children:e.jsx(Ne,{className:"text-left",children:[s.first_name,s.last_name].filter(Boolean).join(" ")||"Demande"})}),e.jsxs("div",{className:"mt-4 space-y-6 text-sm",children:[e.jsxs("section",{className:"rounded-xl border p-3 space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Projet :"})," ",s.project_type||"â"," · ",s.surface?"".concat(s.surface," m²"):"â"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Ville :"})," ",s.city||"â"," · ",e.jsx("strong",{children:"Délai :"})," ",s.timing||"â"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Contact :"})," ",s.email||"â"," · ",s.phone||"â"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Reçu le :"})," ",C(s.created_at)]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Statut du dossier"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:W.map(a=>e.jsxs(w,{size:"sm",variant:a.key===b?"default":"outline",disabled:_==="status-".concat(a.key),onClick:()=>P(a.key),children:[_==="status-".concat(a.key)&&e.jsx(z,{className:"w-3 h-3 mr-1 animate-spin"}),a.label]},a.key))}),e.jsx(te,{className:"mt-2",rows:2,placeholder:"Commentaire joint au prochain changement de statut (optionnel)",value:M,onChange:a=>R(a.target.value)}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3 text-xs text-muted-foreground",children:[e.jsxs("p",{children:["Contacté : ",C(s.contacted_at)]}
16),e.jsxs("p",{children:["Qualifié : ",C(s.qualified_at)]}),e.jsxs("p",{children:["Devis envoyé : ",C(s.quote_sent_at)]}),e.jsxs("p",{children:["Clôturé : ",C(s.closed_at)]})]})]}),e.jsx(U,{}),e.jsxs("section",{children:[e.jsxs("h3",{className:"font-semibold mb-2 flex items-center gap-2",children:[e.jsx($e,{className:"w-4 h-4"})," E-mails & relances"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ae.map(a=>e.jsxs(w,{size:"sm",variant:"secondary",disabled:_==="mail-".concat(a.key)||!s.email,onClick:()=>g(a.key),children:[_==="mail-".concat(a.key)?e.jsx(z,{className:"w-3 h-3 mr-1 animate-spin"}):e.jsx(Ae,{className:"w-3 h-3 mr-1"}),a.label]},a.key))}),!s.email&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Aucune adresse e-mail sur ce lead."}),e.jsxs("ul",{className:"mt-3 space-y-1 text-xs",children:[j.map(a=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(xe,{variant:a.status==="sent"?"outline":"destructive",children:a.status}),e.jsx("span",{className:"flex-1",children:a.subject}),e.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:C(a.created_at)})]},a.id)),!j.length&&e.jsx("li",{className:"text-muted-foreground",children:"Aucun e-mail envoyé."})]})]}),e.jsx(U,{}),e.jsxs("section",{children:[e.jsxs("h3",{className:"font-semibold mb-2 flex items-center gap-2",children:[e.jsx(Ve,{className:"w-4 h-4"})," Notes internes"]}),e.jsx(te,{rows:3,placeholder:"Compte-rendu d'appel, contraintes chantier, négociationâ¦",value:L,onChange:a=>T(a.target.value)}),e.jsx(w,{size:"sm",className:"mt-2",onClick:O,disabled:_==="note"||!L.trim(),children:"Ajouter la note"}),e.jsxs("ul",{className:"mt-3 space-y-2 text-xs",children:[y.map(a=>e.jsxs("li",{className:"rounded-lg border p-2",children:[e.jsx("p",{className:"whitespace-pre-wrap",children:a.content}),e.jsx("p",{className:"text-muted-foreground mt-1",children:C(a.created_at)})]},a.id)),!y.length&&e.jsx("li",{className:"text-muted-foreground",children:"Aucune note."})]})]}),e.jsx(U,{}),e.jsxs("section",{children:[e.jsxs("h3",{className:"font-semibold mb-2 flex items-center gap-2",children:[e.jsx(Te,{className:"w-4 h-4"})," Historique des statuts"]}),e.jsxs("ul",{className:"space-y-1 text-xs",children:[c.map(a=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:C(a.created_at)}),e.jsxs("span",{children:[A(I(a.from_status)).label," â ",e.jsx("strong",{children:A(I(a.to_status)).label}),a.note?" · ".concat(a.note):""]})]},a.id)),!c.length&&e.jsx("li",{className:"text-muted-foreground",children:"Aucun changement enregistré."})]})]}),e.jsxs(w,{variant:"outline",className:"w-full",onClick:H,disabled:_==="crm",children:[_==="crm"?e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Fe,{className:"w-4 h-4 mr-2"}),"Envoyer vers le CRM (n8n)"]})]})]})}):null}const ne=S,Ke=["first_name","last_name","email","phone","city","pole","project_type","surface","estimation_low","estimation_high","status","score","timing","company","utm_source","utm_campaign"];function Ye(){const[s,o]=n.useState(null),[l,d]=n.useState({}),[c,f]=n.useState(!1);n.useEffect(()=>{ne.from("crm_export_settings").select("*").limit(1).maybeSingle().then(({data:i})=>{i&&(o(i),d(i.field_mapping||{}))})},[]);const y=async()=>{if(!s)return;f(!0);const{error:i}=await ne.from("crm_export_settings").update({enabled:s.enabled,trigger_on_new_lead:s.trigger_on_new_lead,trigger_on_status_change:s.trigger_on_status_change,field_mapping:l}).eq("id",s.id);f(!1),i?p.error("Enregistrement impossible"):p.success("Réglages CRM enregistrés")};return s?e.jsxs("section",{className:"rounded-xl border p-4 mb-6",children:[e.jsxs("h2",{className:"font-semibold flex items-center gap-2 mb-3",children:[e.jsx(ze,{className:"w-4 h-4"})," Export CRM (webhook n8n / Make)"]}),e.jsx("div",{className:"grid sm:grid-cols-3 gap-3 mb-4",children:[{k:"enabled",l:"Export activé"},{k:"trigger_on_new_lead",l:"à chaque nouveau lead"},{k:"trigger_on_status_change",l:"à chaque changement de statut"}].map(i=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Me,{id:i.k,checked:!!s[i.k],onCheckedChange:j=>
16o({...s,[i.k]:j})}),e.jsx(De,{htmlFor:i.k,className:"text-xs",children:i.l})]},i.k))}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Correspondance des champs : à gauche le champ du site, à droite le nom attendu par votre CRM (laisser vide pour ne pas envoyer)."}),e.jsx("div",{className:"grid sm:grid-cols-2 gap-2 max-h-64 overflow-y-auto pr-1",children:Ke.map(i=>{var j;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs w-32 shrink-0 text-muted-foreground",children:i}),e.jsx(q,{className:"h-8 text-xs","aria-label":"Champ CRM pour ".concat(i),value:(j=l[i])!=null?j:"",placeholder:"â",onChange:E=>d({...l,[i]:E.target.value})})]},i)})}),e.jsxs(w,{size:"sm",className:"mt-3",onClick:y,disabled:c,children:[c&&e.jsx(z,{className:"w-3 h-3 mr-1 animate-spin"})," Enregistrer le mapping"]})]}):null}const ie={btp:"Rénovation",adhesif:"Adhésif & Signalétique",assistance:"Assistance"},Q=s=>s==null?"â":new Intl.NumberFormat("fr-FR",{style:"currency",currency:"EUR",maximumFractionDigits:0}).format(s),es=s=>{const o=["created_at","pole","project_type","surface","city","timing","estimation_low","estimation_high","first_name","last_name","email","phone","company","status","score","contacted_at","qualified_at","quote_sent_at","closed_at","lead_source","utm_source","utm_medium","utm_campaign","description"],l=d=>{const c=d==null?"":String(d).replace(/\r?\n/g," ");return'"'.concat(c.replace(/"/g,'""'),'"')};return[o.join(";"),...s.map(d=>o.map(c=>l(d[c])).join(";"))].join("\r\n")};function ss(){const[s,o]=n.useState(""),[l,d]=n.useState(""),[c,f]=n.useState(!1),y=async i=>{i.preventDefault(),f(!0);const{error:j}=await S.auth.signInWithPassword({email:s,password:l});f(!1),j&&p.error("Identifiants incorrects")};return e.jsxs("div",{className:"min-h-screen flex items-center justify-center p-6",children:[e.jsxs(me,{children:[e.jsx("title",{children:"Accès administrateur â Spoof BTP"}),e.jsx("meta",{name:"robots",content:"noindex,nofollow"})]}),e.jsxs("form",{onSubmit:y,className:"w-full max-w-sm space-y-3 rounded-2xl border p-6",children:[e.jsx(Oe,{className:"w-8 h-8 mx-auto text-muted-foreground"}),e.jsx("h1",{className:"text-center font-display font-bold",children:"Espace administrateur"}),e.jsx(q,{type:"email",autoComplete:"username",placeholder:"E-mail","aria-label":"E-mail",value:s,onChange:i=>o(i.target.value),required:!0}),e.jsx(q,{type:"password",autoComplete:"current-password",placeholder:"Mot de passe","aria-label":"Mot de passe",value:l,onChange:i=>d(i.target.value),required:!0}),e.jsxs(w,{type:"submit",className:"w-full",disabled:c,children:[c&&e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"})," Se connecter"]}),e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:e.jsx(ue,{to:"/admin",className:"underline",children:"Retour au tableau de bord"})})]})]})}function vs(){var N;const[s,o]=n.useState(null),[l,d]=n.useState(null),[c,f]=n.useState([]),[y,i]=n.useState(!1),[j,E]=n.useState(null),[L]=ke(),[T,M]=n.useState(""),[R,_]=n.useState("all"),[h,m]=n.useState("all"),[b,D]=n.useState(""),[P,F]=n.useState("");n.useEffect(()=>{S.auth.getSession().then(({data:r})=>o(r.session));const{data:{subscription:t}}=S.auth.onAuthStateChange((r,u)=>o(u));return()=>t.unsubscribe()},[]),n.useEffect(()=>{var t;if(!((t=s==null?void 0:s.user)!=null&&t.id)){d(null);return}S.from("user_roles").select("role").eq("user_id",s.user.id).eq("role","admin").maybeSingle().then(({data:r})=>d(!!r))},[(N=s==null?void 0:s.user)==null?void 0:N.id]);const O=async()=>{i(!0);const{data:t,error:r}=await S.from("leads").select("*").order("created_at",{ascending:!1}).limit(1e3);r&&p.error("Impossible de charger les leads"),f(t||[]),i(!1)};n.useEffect(()=>{l&&O()},[l]),n.useEffect(()=>{const t=L.get("lead");if(!t||!c.length)return;const r=c.find(u=>u.id===t);r&&E(r)},[L,c]);const g=n.useMemo(()=>{const t=T.trim().toLowerCase();return c.filter(r=>R!=="all"&&r.pole!==R||h!=="all"&&I(r.status)!==h||b&&r.created_at&&r.created_at<b||P&&r.created_at&&r.created_at>"".concat(P,"T23:59:59")?!1:t?[r.first_name,r.last_name,r.email,r.phone,r.city,r.company,r.project_type].some(u=>(u||"").toString().toLowerCase().includes(t)):!0)},[c,T,R,h,b,P]),H=n.useMemo(()=>g.reduce((t,r)=>t+(Number(r.estimation_high)||0),0),[g]),a=n.useMemo(()=>{const t={};
16for(const r of c){const u=I(r.status);t[u]=(t[u]||0)+1}return t},[c]),x=()=>{if(!g.length){p.error("Aucun lead à exporter");return}const t=new Blob(["\uFEFF"+es(g)],{type:"text/csv;charset=utf-8;"}),r=URL.createObjectURL(t),u=document.createElement("a");u.href=r,u.download="leads-spoofbtp-".concat(new Date().toISOString().slice(0,10),".csv"),u.click(),URL.revokeObjectURL(r),p.success("".concat(g.length," leads exportés"))};return!s||l===!1?e.jsx(ss,{}):e.jsxs("div",{className:"min-h-screen p-4 md:p-8 max-w-6xl mx-auto",children:[e.jsxs(me,{children:[e.jsx("title",{children:"Leads â Espace administrateur Spoof BTP"}),e.jsx("meta",{name:"robots",content:"noindex,nofollow"})]}),e.jsxs("header",{className:"flex flex-wrap items-center gap-3 mb-6",children:[e.jsx(w,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs(ue,{to:"/admin",children:[e.jsx(Pe,{className:"w-4 h-4 mr-1"})," Admin"]})}),e.jsx("h1",{className:"text-xl md:text-2xl font-display font-bold",children:"Suivi des demandes"}),e.jsxs("div",{className:"ml-auto flex gap-2",children:[e.jsxs(w,{variant:"outline",size:"sm",onClick:O,disabled:y,children:[e.jsx(qe,{className:"w-4 h-4 mr-1 ".concat(y?"animate-spin":"")})," Actualiser"]}),e.jsxs(w,{size:"sm",onClick:x,children:[e.jsx(Ie,{className:"w-4 h-4 mr-1"})," Exporter CSV"]})]})]}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-5",children:W.map(t=>e.jsxs("button",{onClick:()=>m(h===t.key?"all":t.key),className:"rounded-xl border px-3 py-2 text-left transition ".concat(h===t.key?"ring-2 ring-primary":""),children:[e.jsx("span",{className:"block text-xs text-muted-foreground",children:t.label}),e.jsx("span",{className:"block text-lg font-bold",children:a[t.key]||0})]},t.key))}),e.jsx(Ye,{}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3 mb-5",children:[e.jsxs("div",{className:"rounded-xl border p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leads affichés"}),e.jsx("p",{className:"text-lg font-bold",children:g.length})]}),e.jsxs("div",{className:"rounded-xl border p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Potentiel (haut)"}),e.jsx("p",{className:"text-lg font-bold",children:Q(H)})]}),e.jsxs("div",{className:"rounded-xl border p-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Score moyen"}),e.jsx("p",{className:"text-lg font-bold",children:g.length?Math.round(g.reduce((t,r)=>t+(r.score||0),0)/g.length):0})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-3 mb-4",children:[e.jsxs("div",{className:"relative md:col-span-2",children:[e.jsx(Be,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),e.jsx(q,{className:"pl-9",placeholder:"Nom, email, téléphone, villeâ¦","aria-label":"Rechercher un lead",value:T,onChange:t=>M(t.target.value)})]}),e.jsxs(K,{value:R,onValueChange:_,children:[e.jsx(Y,{"aria-label":"Filtrer par pôle",children:e.jsx(ee,{placeholder:"Pôle"})}),e.jsxs(se,{children:[e.jsx(V,{value:"all",children:"Tous les pôles"}),Object.entries(ie).map(([t,r])=>e.jsx(V,{value:t,children:r},t))]})]}),e.jsxs(K,{value:h,onValueChange:m,children:[e.jsx(Y,{"aria-label":"Filtrer par statut",children:e.jsx(ee,{placeholder:"Statut"})}),e.jsxs(se,{children:[e.jsx(V,{value:"all",children:"Tous les statuts"}),W.map(t=>e.jsx(V,{value:t.key,children:t.label},t.key))]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(q,{type:"date","aria-label":"Date de début",value:b,onChange:t=>D(t.target.value)}),e.jsx(q,{type:"date","aria-label":"Date de fin",value:P,onChange:t=>F(t.target.value)})]})]}),e.jsx("div",{className:"rounded-xl border overflow-x-auto",children:e.jsxs(Ce,{children:[e.jsx(Ee,{children:e.jsxs(Z,{children:[e.jsx($,{children:"Date"}),e.jsx($,{children:"Client"}),e.jsx($,{children:"Contact"}),e.jsx($,{children:"Projet"}),e.jsx($,{children:"Ville"}),e.jsx($,{children:"Estimation"}),e.jsx($,{children:"Statut"})]})}),e.jsxs(Le,{children:[g.map(t=>{const r=A(I(t.status));return e.jsxs(Z,{className:"cursor-pointer",onClick:()=>E(t),children:[e.jsx(k,{className:"whitespace-nowrap text-xs",children:t.created_at?new Date(t.created_at).toLocaleDateString("fr-FR"):"â"}),e.jsx(k,{className:"font-medium",children:[t.first_name,t.last_name].filter(
16Boolean).join(" ")||"â"}),e.jsxs(k,{className:"text-xs",children:[e.jsx("div",{children:t.email||"â"}),e.jsx("div",{className:"text-muted-foreground",children:t.phone||""})]}),e.jsxs(k,{className:"text-xs",children:[e.jsx(xe,{variant:"outline",children:ie[t.pole||""]||t.pole||"â"}),e.jsxs("div",{className:"text-muted-foreground mt-1",children:[t.project_type||"",t.surface?" · ".concat(t.surface," m²"):""]})]}),e.jsx(k,{className:"text-xs",children:t.city||"â"}),e.jsxs(k,{className:"text-xs whitespace-nowrap",children:[Q(Number(t.estimation_low)||null)," â ",Q(Number(t.estimation_high)||null)]}),e.jsx(k,{className:"text-xs",children:e.jsx("span",{className:"rounded-full px-2 py-1 text-[11px] font-medium ".concat(r.className),children:r.label})})]},t.id)}),!g.length&&e.jsx(Z,{children:e.jsx(k,{colSpan:7,className:"text-center text-sm text-muted-foreground py-8",children:y?"Chargementâ¦":"Aucun lead ne correspond aux filtres."})})]})]})}),e.jsx(Je,{lead:j,open:!!j,onOpenChange:t=>!t&&E(null),onUpdated:O})]})}export{vs 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.