PageSourceSearch

https://brcohn.com/assets/unsubscribe-CPdTo8-i.js

js brcohn.com collected 2026-09-25 19:03:38 UTC 2,779 bytes, 1 lines download raw bytes

1import{r as i,j as e}from"./index-ZYPqz8AT.js";import{N as m,F as u}from"./Footer-D8rPV0ol.js";function b(){const[s,n]=i.useState({kind:"loading"}),[a,l]=i.useState(null);i.useEffect(()=>{const t=new URLSearchParams(window.location.search).get("token");if(l(t),!t){n({kind:"invalid"});return}fetch(`/email/unsubscribe?token=${encodeURIComponent(t)}`).then(async o=>{const c=await o.json().catch(()=>({}));if(!o.ok){n({kind:"invalid"});return}c.valid===!0?n({kind:"valid"}):c.reason==="already_unsubscribed"?n({kind:"already"}):n({kind:"invalid"})}).catch(()=>n({kind:"invalid"}))},[]);async function d(){if(a){n({kind:"submitting"});try{const r=await fetch("/email/unsubscribe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({token:a})}),t=await r.json().catch(()=>({}));r.ok&&t.success?n({kind:"done"}):t.reason==="already_unsubscribed"?n({kind:"already"}):n({kind:"error",message:t.error??"Something went wrong."})}catch{n({kind:"error",message:"Network error. Please try again."})}}}return e.jsxs(e.Fragment,{children:[e.jsx(m,{}),e.jsx("main",{className:"bg-cream text-foreground min-h-[70vh] py-24 lg:py-32",children:e.jsxs("div",{className:"mx-auto max-w-xl px-6 lg:px-10 text-center",children:[e.jsx("p",{className:"eyebrow text-bronze mb-3",children:"Email Preferences"}),e.jsx("h1",{className:"font-serif text-4xl md:text-5xl font-light text-walnut mb-6",children:"Unsubscribe"}),s.kind==="loading"&&e.jsx("p",{className:"font-sans text-sm text-foreground/70",children:"Checking your link…"}),s.kind==="invalid"&&e.jsx("p",{className:"font-sans text-sm text-foreground/80",children:"This unsubscribe link is invalid or has expired. If you'd like to stop receiving emails, please reply to any recent message from us and we'll take care of it."}),s.kind==="already"&&e.jsx("p",{className:"font-sans text-sm text-foreground/80",children:"You're already unsubscribed. You won't receive further email from B.R. Cohn Winery."}),s.kind==="valid"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-sans text-base text-foreground/80 mb-8",children:"Click the button below to stop receiving email from B.R. Cohn Winery."}),e.jsx("button",{onClick:d,className:"btn-fill relative inline-flex items-center justify-center px-8 py-3.5 bg-walnut text-walnut-foreground font-sans text-sm font-medium tracking-wider uppercase before:bg-bronze",children:"Confirm Unsubscribe"})]}),s.kind==="submitting"&&e.jsx("p",{className:"font-sans text-sm text-foreground/70",children:"Unsubscribing…"}),s.kind==="done"&&e.jsx("p",{className:"font-sans text-base text-foreground/80",children:"You've been unsubscribed."}),s.kind==="error"&&e.jsx("p",{className:"font-sans text-sm text-red-800",children:s.message})]})}),e.jsx(u,{})]})}export{b 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.