1import{d as v,u as _,r as d,s as x,j as e,f as y,L as p,A as w}from"./index-CWZknsbG.js";import{A as k}from"./arrow-left-CQqVJmfJ.js";import{C as A}from"./clock-BlfZvjlm.js";import{C as L}from"./circle-check-B60dsO30.js";function z(){const{user:o,isAdmin:s,loading:n}=v(),a=_(),[c,t]=d.useState([]),[m,f]=d.useState(!0);if(d.useEffect(()=>{if(!n){if(!o){a({to:"/auth",search:{}});return}s||a({to:"/espace-client"})}},[o,s,n,a]),d.useEffect(()=>{s&&(async()=>{const{data:i}=await x.from("quotes").select("id, quote_number, title, status, total_ht, total_ttc, client_id, accepted_at, updated_at").in("status",["accepted","in_progress","completed"]).order("updated_at",{ascending:!1}),l=i??[];if(l.length){const j=[...new Set(l.map(r=>r.client_id))],{data:b}=await x.from("profiles").select("user_id, first_name, last_name, email, company").in("user_id",j),N=new Map((b??[]).map(r=>[r.user_id,r]));l.forEach(r=>{r.profile=N.get(r.client_id)??null})}t(l),f(!1)})()},[s]),n||m||!s)return e.jsx("div",{className:"min-h-[60vh] flex items-center justify-center",children:e.jsx(y,{className:"text-gold animate-pulse"})});const g=c.filter(i=>i.status==="accepted"||i.status==="in_progress"),h=c.filter(i=>i.status==="completed");return e.jsxs("section",{className:"bg-background min-h-screen pb-24",children:[e.jsx("div",{className:"border-b border-border bg-card",children:e.jsxs("div",{className:"container-x max-w-6xl mx-auto py-12",children:[e.jsxs(p,{to:"/admin",className:"inline-flex items-center gap-2 text-xs uppercase tracking-[0.2em] text-muted-foreground hover:text-gold transition-colors mb-6",children:[e.jsx(k,{size:14})," L'atelier"]}),e.jsx("p",{className:"eyebrow mb-3",children:"Parcours clients"}),e.jsxs("h1",{className:"font-display text-4xl md:text-5xl",children:["Les ",e.jsx("span",{className:"italic text-gold",children:"chantiers"})," de la maison"]}),e.jsx("p",{className:"mt-4 text-foreground/70 max-w-2xl",children:"Le suivi des projets validés : ceux qui avancent et ceux qui sont livrés."})]})}),e.jsxs("div",{className:"container-x max-w-6xl mx-auto pt-12 space-y-12",children:[e.jsx(u,{title:"En cours",subtitle:"Projets validés et en production",icon:e.jsx(A,{size:16}),rows:g,emptyText:"Aucun projet en cours."}),e.jsx(u,{title:"Terminés",subtitle:"Parcours livrés et clos",icon:e.jsx(L,{size:16}),rows:h,emptyText:"Aucun projet terminé pour le moment."})]})]})}function u({title:o,subtitle:s,icon:n,rows:a,emptyText:c}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-end justify-between mb-6",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"eyebrow mb-2 inline-flex items-center gap-2",children:[n," ",o]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s})]}),e.jsx("span",{className:"text-xs uppercase tracking-[0.2em] text-muted-foreground",children:a.length})]}),a.length===0?e.jsx("div",{className:"border border-border bg-card p-10 text-center text-muted-foreground text-sm",children:c}):e.jsx("div",{className:"space-y-3",children:a.map(t=>{const m=t.profile?`${t.profile.first_name??""} ${t.profile.last_name??""}`.trim()||t.profile.email:"â";return e.jsx(p,{to:"/devis/$quoteId",params:{quoteId:t.id},className:"block border border-border bg-card hover:border-gold/60 transition-colors group",children:e.jsxs("div",{className:"grid grid-cols-12 gap-4 p-6 items-center",children:[e.jsx("div",{className:"col-span-12 md:col-span-2",children:e.jsx("p",{className:"font-mono text-[0.7rem] uppercase tracking-[0.18em] text-gold",children:t.quote_number})}),e.jsxs("div",{className:"col-span-12 md:col-span-5",children:[e.jsx("p",{className:"font-display text-lg group-hover:text-gold transition-colors",children:t.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[m,t.profile?.company?` â ${t.profile.company}`:""]})]}),e.jsx("div",{className:"col-span-6 md:col-span-3 text-xs text-muted-foreground",children:t.accepted_at&&e.jsxs("span",{children:["Acceptée le ",new Date(t.accepted_at).toLocaleDateString("fr-FR")]})}),e.jsxs("div",{className:"col-span-6 md:col-span-2 text-right",children:[e.jsxs("p",{className:"font-mono text-sm text-gold",children:[Number(t.total_ttc??t.total_ht).toLocaleStr
1ing("fr-FR",{minimumFractionDigits:0})," â¬"]}),e.jsx(w,{size:14,className:"inline-block text-muted-foreground group-hover:text-gold group-hover:translate-x-1 transition-all mt-1"})]})]})},t.id)})})]})}export{z 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.