PageSourceSearch

https://lesmaisonsvertesprovencales.com/app/assets/CallCompletePage-_qy44d9C.js

js lesmaisonsvertesprovencales.com collected 2026-10-03 01:39:03 UTC 10,678 bytes, 1 lines download raw bytes

1import{r as n,j as e,aa as O,ah as H,b3 as q,cL as I,cF as V,a9 as D,bH as X,bx as K}from"./vendor-DH3sIdl2.js";import{s as w,b6 as W,t as b,S as Y,B as f}from"./index-BwHllA22.js";import{m as S}from"./motion-CAIqhnBW.js";import"./utils-CDPbcFE-.js";async function G(l){const{data:i,error:o}=await w.rpc("get_lead_by_call_token",{p_token:l});if(o)return console.warn("[appel] résolution du token échouée :",o.message),null;const r=Array.isArray(i)?i[0]:i;return r?{nom:r.nom??"",telephone:r.telephone??"",typeTravaux:r.type_travaux??"",commune:r.commune??"",codePostal:r.code_postal??"",delai:r.delai??"",description:r.description??""}:null}const N=8;async function J(l,i,o){const r=[],u=i.slice(0,N);for(let c=0;c<u.length;c++){const j=u[c];try{const d=await W(j),h=`${l}/${crypto.randomUUID()}.jpg`,{error:x}=await w.storage.from("demandes-photos").upload(h,d,{contentType:d.type||"image/jpeg",upsert:!1});x?console.warn("[appel] envoi photo échoué :",x.message):r.push(h)}catch(d){console.warn("[appel] photo illisible, ignorée :",d)}o==null||o(c+1,u.length)}return r}async function Q(l,i,o,r){const{data:u,error:c}=await w.rpc("complete_lead_by_call_token",{p_token:l,p_email:i.trim(),p_precisions:o.trim()||null,p_photos:r});return c?(console.warn("[appel] complétion échouée :",c.message),!1):u===!0}const y="04 12 13 62 41",$="tel:+33412136241",Z=/^[^\s@]+@[^\s@]+\.[a-z]{2,}$/i,ae=({token:l,onGoHome:i,onStartEstimate:o})=>{const[r,u]=n.useState(null),[c,j]=n.useState(!0),[d,h]=n.useState(""),[x,A]=n.useState(""),[s,k]=n.useState([]),[C,z]=n.useState(!1),[P,g]=n.useState(""),[U,M]=n.useState(!1),E=n.useRef(null);n.useEffect(()=>{let t=!0;return G(l).then(a=>{t&&(u(a),j(!1))}),()=>{t=!1}},[l]),n.useEffect(()=>()=>{s.forEach(t=>URL.revokeObjectURL(t.url))},[s]);const T=n.useCallback(t=>{if(!(t!=null&&t.length))return;const a=N-s.length;if(a<=0){b({title:"Maximum atteint",description:`${N} photos suffisent largement pour chiffrer.`});return}const p=Array.from(t).filter(m=>m.type.startsWith("image/")).slice(0,a);k(m=>[...m,...p.map(R=>({file:R,url:URL.createObjectURL(R)}))])},[s.length]),B=t=>{k(a=>(URL.revokeObjectURL(a[t].url),a.filter((p,m)=>m!==t)))},F=async()=>{if(!Z.test(d.trim())){b({title:"Email à vérifier",description:"Saisissez une adresse valide — c’est là que le devis sera envoyé.",variant:"destructive"});return}z(!0);try{let t=[];if(s.length>0&&(g(`Envoi des photos… 0/${s.length}`),t=await J(l,s.map(p=>p.file),(p,m)=>g(`Envoi des photos… ${p}/${m}`))),g("Enregistrement…"),!await Q(l,d,x,t)){b({title:"Lien expiré",description:`Appelez directement Monsieur Ben bouazza au ${y}.`,variant:"destructive"});return}M(!0)}catch(t){console.error("[appel] complétion KO",t),b({title:"Envoi impossible",description:"Réessayez dans un instant, ou appelez-nous directement.",variant:"destructive"})}finally{z(!1),g("")}};if(c)return e.jsxs("div",{className:"min-h-screen bg-background flex flex-col items-center justify-center gap-4",children:[e.jsx(Y,{size:"lg",className:"text-foreground/40"}),e.jsx("p",{className:"text-sm text-foreground/50",children:"Chargement de votre demande…"})]});if(!r)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md bg-card border border-border rounded-2xl p-8 text-center space-y-4",children:[e.jsx("div",{className:"mx-auto w-14 h-14 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(O,{className:"w-7 h-7 text-amber-500"})}),e.jsx("h1",{className:"text-xl font-serif font-bold text-foreground",children:"Ce lien n’est plus valide"}),e.jsxs("p",{className:"text-sm text-foreground/60",children:["Il a peut-être expiré. Appelez Monsieur Ben bouazza au ",y,", ou faites votre demande directement en ligne."]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 justify-center pt-2",children:[e.jsx("a",{href:$,children:e.jsxs(f,{variant:"outline",className:"w-full",children:[e.jsx(H,{size:15,className:"mr-1.5"}),"Appeler"]})}),e.jsx(f,{onClick:o,className:"w-full sm:w-auto",children:"Demander un devis"})]})]})});if(U)return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs(S.div,{initial:{opacity:0,y:20}
1,animate:{opacity:1,y:0},transition:{duration:.4},className:"w-full max-w-md bg-card border border-border rounded-2xl p-8 text-center space-y-4 shadow-2xl",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(q,{className:"w-8 h-8 text-primary"})}),e.jsx("h1",{className:"text-2xl font-serif font-bold text-foreground",children:"C’est envoyé, merci !"}),e.jsxs("p",{className:"text-sm text-foreground/60",children:["Votre demande est complète",s.length>0?` avec ${s.length} photo${s.length>1?"s":""}`:"",". Monsieur Ben bouazza vous répond sous 24 heures à ",e.jsx("strong",{className:"text-foreground",children:d.trim()}),"."]}),e.jsxs("div",{className:"bg-foreground/5 border border-border rounded-xl p-4 text-left",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider text-foreground/40 mb-1",children:"En attendant"}),e.jsx("p",{className:"text-sm text-foreground/70",children:"Vous pouvez obtenir un ordre de prix immédiat avec notre estimateur en ligne — c’est gratuit et sans engagement."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 pt-1",children:[e.jsx(f,{onClick:o,className:"w-full",children:"Estimer mon projet"}),e.jsx(f,{variant:"outline",onClick:i,className:"w-full",children:"Retour à l’accueil"})]})]})});const _=r.nom.trim().split(" ")[0]||"",v=(t,a)=>a?e.jsxs("div",{className:"flex items-baseline justify-between gap-3 py-2 border-b border-border/60 last:border-0",children:[e.jsx("span",{className:"text-[11px] uppercase tracking-wider text-foreground/40 shrink-0",children:t}),e.jsx("span",{className:"text-sm text-foreground font-semibold text-right",children:a})]}):null,L=[r.commune,r.codePostal].filter(Boolean).join(" · ");return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4 py-10",children:e.jsx(S.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4},className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card border border-border rounded-2xl overflow-hidden shadow-2xl",children:[e.jsxs("div",{className:"bg-black dark:bg-[#050505] p-6 text-center",children:[e.jsx("div",{className:"mx-auto w-12 h-12 rounded-2xl bg-primary/15 flex items-center justify-center mb-3",children:e.jsx(I,{className:"w-6 h-6 text-primary"})}),e.jsx("p",{className:"text-primary font-bold tracking-widest text-[11px] uppercase mb-1",children:"Les Maisons Vertes Provençales"}),e.jsx("h1",{className:"text-xl font-serif font-bold text-white",children:_?`Merci pour votre appel, ${_}`:"Merci pour votre appel"}),e.jsx("p",{className:"text-white/50 text-sm mt-1",children:"Plus qu’une minute pour recevoir votre devis"})]}),e.jsxs("div",{className:"p-6 space-y-5",children:[(r.typeTravaux||L||r.delai)&&e.jsxs("div",{className:"bg-foreground
1/5 border border-border rounded-xl px-4 py-2",children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider text-foreground/40 pt-1.5 pb-0.5",children:"Votre demande"}),v("Travaux",r.typeTravaux),v("Lieu",L),v("Délai",r.delai)]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"appel-email",className:"block text-sm font-semibold text-foreground mb-1.5",children:["Votre email ",e.jsx("span",{className:"text-primary",children:"*"})]}),e.jsx("input",{id:"appel-email",type:"email",inputMode:"email",autoComplete:"email",autoFocus:!0,value:d,onChange:t=>h(t.target.value),placeholder:"[email protected]",className:"w-full px-4 py-3 rounded-xl bg-background border border-border text-foreground text-base placeholder:text-foreground/30 focus:outline-none focus:ring-2 focus:ring-primary/40"}),e.jsx("p",{className:"text-[11px] text-foreground/40 mt-1.5",children:"C’est à cette adresse que votre devis détaillé sera envoyé."})]}),e.jsxs("div",{children:[e.jsxs("span",{className:"block text-sm font-semibold text-foreground mb-1.5",children:["Photos du chantier ",e.jsx("span",{className:"text-foreground/40 font-normal",children:"(recommandé)"})]}),e.jsx("input",{ref:E,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:t=>{T(t.target.files),t.target.value=""}}),e.jsxs("button",{type:"button",onClick:()=>{var t;return(t=E.current)==null?void 0:t.click()},className:"w-full flex items-center justify-center gap-2 px-4 py-3 rounded-xl border border-dashed border-border bg-background hover:bg-foreground
1/5 text-foreground/70 text-sm font-medium transition",children:[e.jsx(V,{size:17}),s.length===0?"Ajouter des photos":`${s.length} photo${s.length>1?"s":""} · en ajouter`]}),e.jsx("p",{className:"text-[11px] text-foreground/40 mt-1.5",children:"Une photo évite souvent une visite : chiffrage plus rapide et plus juste."}),s.length>0&&e.jsx("div",{className:"grid grid-cols-4 gap-2 mt-3",children:s.map((t,a)=>e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden border border-border",children:[e.jsx("img",{src:t.url,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:()=>B(a),"aria-label":"Retirer cette photo",className:"absolute top-1 right-1 w-5 h-5 rounded-full bg-black/70 text-white flex items-center justify-center hover:bg-black",children:e.jsx(D,{size:11})})]},t.url))})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"appel-precisions",className:"block text-sm font-semibold text-foreground mb-1.5",children:["Un détail à ajouter ? ",e.jsx("span",{className:"text-foreground/40 font-normal",children:"(facultatif)"})]}),e.jsx("textarea",{id:"appel-precisions",rows:3,value:x,onChange:t=>A(t.target.value),placeholder:"Ex : accès difficile, maison ancienne, surface approximative…",className:"w-full px-4 py-3 rounded-xl bg-background border border-border text-foreground text-sm placeholder:text-foreground/30 focus:outline-none focus:ring-2 focus:ring-primary/40 resize-none"})]}),e.jsx(f,{onClick:F,disabled:C,className:"w-full h-12 text-base",children:C?e.jsxs(e.Fragment,{children:[e.jsx(X,{size:17,className:"mr-2 animate-spin"}),P||"Envoi…"]}):e.jsxs(e.Fragment,{children:[e.jsx(K,{size:16,className:"mr-2"}),"Envoyer ma demande"]})}),e.jsxs("p",{className:"text-[11px] text-foreground/40 text-center",children:["Vos informations servent uniquement à établir votre devis. Une question ?"," ",e.jsx("a",{href:$,className:"text-primary font-semibold hover:underline",children:y})]})]})]})})})};export{ae 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.