PageSourceSearch

https://roots-officiel.com/assets/Unsubscribe-CiVQjfbk.js

js roots-officiel.com collected 2026-10-09 05:06:38 UTC 4,729 bytes, 1 lines download raw bytes

1import{af as g,u as N,r as o,j as e,A as w,m as y,q as p,M as j,B as r,bv as k,ds as C,s as u,bB as x}from"./index-BTrKqWIn.js";const _=()=>{const[b]=g(),t=N(),[i,n]=o.useState("loading"),[s,v]=o.useState(""),[c,h]=o.useState(!1),d=b.get("email");o.useEffect(()=>{(async()=>{if(!d){n("confirm");return}const l=decodeURIComponent(d);v(l);const{data:a,error:E}=await u.from("newsletter_subscriptions").select("is_active").eq("email",l).maybeSingle();if(a&&!a.is_active){n("success");return}n("confirm")})()},[d]);const f=async()=>{if(!s){x({title:"Erreur",description:"Email non trouvé.",variant:"destructive"});return}h(!0);const{error:m}=await u.from("newsletter_subscriptions").update({is_active:!1}).eq("email",s),{error:l}=await u.rpc("opt_out_weekly_recap_by_email",{_email:s}),a=m&&l?m:null;a?(console.error("Unsubscribe error:",a),n("error"),x({title:"Erreur",description:"Une erreur est survenue lors de la désinscription.",variant:"destructive"})):(n("success"),x({title:"Désinscription réussie",description:"Vous ne recevrez plus notre newsletter."})),h(!1)};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"sticky top-0 z-40 bg-background/95 backdrop-blur-md border-b border-border",children:e.jsxs("div",{className:"flex items-center justify-between px-4 h-14",children:[e.jsx("button",{onClick:()=>t("/"),className:"p-2 -ml-2 hover:bg-muted rounded-lg transition-colors",children:e.jsx(w,{className:"w-5 h-5"})}),e.jsx("h1",{className:"font-semibold text-lg",children:"Désinscription"}),e.jsx("div",{className:"w-9"})]})}),e.jsx("main",{className:"container max-w-md mx-auto px-4 py-12",children:e.jsxs(y.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4},className:"text-center",children:[i==="loading"&&e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(p,{className:"w-12 h-12 text-primary animate-spin"}),e.jsx("p",{className:"text-muted-foreground",children:"Vérification..."})]}),i==="confirm"&&e.jsxs("div",{className:"flex flex-col items-center gap-6",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(j,{className:"w-10 h-10 text-primary"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Se désinscrire ?"}),s&&e.jsxs("p",{className:"text-muted-foreground mb-2",children:["Email : ",e.jsx("span",{className:"font-medium text-foreground",children:s})]}),e.jsx("p",{className:"text-muted-foreground",children:"Vous ne recevrez plus la newsletter ROOTS."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(r,{variant:"outline",onClick:()=>t("/"),children:"Annuler"}),e.jsx(r,{onClick:f,disabled:c||!s,className:"bg-destructive hover:bg-destructive/90",children:c?e.jsxs(e.Fragment,{children:[e.jsx(p,{className:"w-4 h-4 mr-2 animate-spin"}),"Traitement..."]}):"Confirmer la désinscription"})]})]}),i==="success"&&e.jsxs("div",{className:"flex flex-col items-center gap-6",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(k,{className:"w-10 h-10 text-green-500"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Désinscription confirmée"}),e.jsx("p",{className:"text-muted-foreground",children:"Vous ne recevrez plus notre newsletter. Vous pouvez vous réinscrire à tout moment."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(r,{variant:"outline",onClick:()=>t("/"),children:"Retour à l'accueil"}),e.jsx(r,{onClick:()=>t("/newsletter"),children:"Se réinscrire"})]})]}),i==="error"&&e.jsxs("div",{className:"flex flex-col items-center gap-6",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-destructive/10 flex items-center justify-center",children:e.jsx(C,{className:"w-10 h-10 text-destructive"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Une erreur est survenue"}),e.jsx("p",{className:"text-muted-foreground",children:"Impossible de traiter votre demande. Veuillez réessayer."})]}
1),e.jsx(r,{onClick:f,disabled:c,children:c?"Traitement...":"Réessayer"})]}),i==="not-found"&&e.jsxs("div",{className:"flex flex-col items-center gap-6",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-muted flex items-center justify-center",children:e.jsx(j,{className:"w-10 h-10 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold mb-2",children:"Email non trouvé"}),e.jsx("p",{className:"text-muted-foreground",children:"Cet email n'est pas inscrit à notre newsletter."})]}),e.jsx(r,{onClick:()=>t("/"),children:"Retour à l'accueil"})]})]})})]})};export{_ 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.