PageSourceSearch

https://sharethemeal.org/assets/marketingConsent-CcHcZ7Xn.js

js sharethemeal.org collected 2026-09-24 08:45:03 UTC 3,793 bytes, 1 lines download raw bytes

1import{t as s}from"./chunk-4N6VE7H7-Exqj4PTM.js";import{u as O}from"./useGenerateErrorModalContent-HjzkqIQ8.js";import{u as F}from"./useNewsletterSubscribe-_hpLDGCj.js";import{u as G}from"./useRootData-fFXhC2hW.js";import{u as L}from"./errorHandling-CJ53Cpo-.js";import{E as q,Q as e,q as B,k as z}from"./constants-CmaRX5ba.js";import{i as I}from"./amplitudeContext-Cg1Mbi4A.js";import{k as T,w as Q}from"./index-Cp7v22Jw.js";import{R as H,C as y}from"./Col-CPLGU30n.js";import{B as J}from"./Button-Dw9IA_-S.js";import{F as K}from"./FormGroup-BrC4eXxe.js";import{L as P}from"./Label-CKt1RJ7o.js";import{D as U}from"./downloadApp-D2C4yyAh.js";import{S as R}from"./stmInput-B6qy2IGd.js";import{g as V}from"./emails-BcsGL0LJ.js";import{u as W}from"./useTranslation-AnhJcB0n.js";const de=()=>{const{openDialog:i}=L(),{newsletterSubscribe:p}=F(),{user:l}=G(),C=O(),[x,n]=s.useState(!1),[u,t]=s.useState(""),[b,d]=s.useState(!1),[h,f]=s.useState(""),[r,g]=s.useState(!I(l)),m=s.useCallback(a=>{g(a),a||(t(""),f(""))},[]),E=async(a,S,_=!1)=>(d(!0),!r||h?!1:new Promise(c=>{p({email:u,provider:a,transactionId:S,callbacks:{onSuccess:()=>c(!0),onError:()=>{if(_){const k=C(q.PAGE_LOAD);i(k)}c(!1)}}})}));return s.useEffect(()=>{I(l)&&m(!1)},[m,l]),{consentEmail:u,consentEmailError:h,handleSubmit:E,isConsentChecked:r,isConsentConfirmed:x,isSubmitted:b,setConsentEmail:t,setConsentEmailError:f,setIsConsentChecked:m,setIsConsentConfirmed:n,setIsSubmitted:d}},he=({analyticsLocation:i,donationType:p=B.SINGLE,isChallenge:l,marketingConsentState:C,provider:x,thankYouPage:n=!1,transactionId:u})=>{const{t}=W(),b=s.useId(),{consentEmail:d,consentEmailError:h,handleSubmit:f,isConsentChecked:r,isSubmitted:g,setConsentEmail:m,setConsentEmailError:E,setIsConsentChecked:a}=C,[S,_]=s.useState(!1),[c,j]=s.useState(!1),[k,N]=s.useState(!1);s.useEffect(()=>{const o=window.setTimeout(()=>j(!0),0);return()=>window.clearTimeout(o)},[]);const v=o=>t(V(o)),A=async()=>{N(!0);const o=await f(x,u,!0);_(o),N(!1),Q("consent_submitted",{screen_name:i})},D=o=>{const w=o.target;m(w.value),E(v(w.value))},M=o=>{a(o.currentTarget.checked)};return e.jsx("div",{className:"consent",children:S?e.jsx("span",{children:e.jsxs(e.Fragment,{children:[e.jsx("img",{src:"/images/thank-you.svg",alt:"Thank you",className:"consent__thank-you-image",width:146,height:84}),e.jsx("h3",{className:"heading--4 consent__heading",children:t("newsletter.successTitle")}),e.jsx("p",{className:"dimmed-text text-center consent__thank-you-text",children:t("newsletter.successText")}),e.jsx("div",{className:"text-center",children:i&&e.jsx(U,{analyticsLocation:i,isChallenge:l,donationType:p,isConsentConfirmed:!0})})]})}):e.jsxs("span",{children:[n&&e.jsx("h3",{className:"heading--4 consent__heading",children:t("newsletter.consentTitle")}),e.jsx("div",{className:T({"order-1":n}),children:e.jsx(H,{className:"g-0",children:e.jsx(y,{xs:"auto",className:"checkbox-col",children:e.jsxs(P,{className:"checkbox",children:[e.jsx(R,{type:"checkbox",checked:r,className:"checkbox__input consent__checkbox-input","data-testid":"marketing-consent-checkbox",disabled:!c,id:b,onChange:M}),e.jsx(y,{className:"consent__checkbox-label",children:t("newsletter.consentText")})]})})})}),(r||n)&&e.jsx(K,{style:{order:n?0:1},className:T("consent__input-group",{"consent__input-group--thank-you":n}),children:e.jsx(R,{label:n?void 0:t("profile.form.email.label"),type:"email",name:"email",className:"consent__input","data-testid":"marketing-consent-email",placeholder:t("newsletter.emailAddress.enter"),value:d,errorMessage:h,forceShowError:g,onChange:D,disabled:!c,required:!0})}),n&&e.jsx(J,{type:"button",block:!0,color:z,size:"lg",className:"consent__cta",disabled:!c||!r||k,onClick:A,children:t("newsletter.action.agree")})]})})};export{he as M,de as u};

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.