PageSourceSearch

https://www.scientificamerican.com/static/entry/gift-sub-email-form.CVn7Wo6V.js

js scientificamerican.com collected 2026-09-24 07:36:46 UTC 4,620 bytes, 1 lines download raw bytes

1import{r as l,j as e}from"../chunks/vendor-react-DdEP1kCQ.js";import{D as y}from"../chunks/DefaultLayout-B4mESSua.js";import{k as v,g as _,e as I,w}from"../chunks/core-Bpuic6mr.js";import{F as L}from"../chunks/Faq-CD5jDRNx.js";import{s,l as D}from"../chunks/redeem-gift.module-kNqlX0DI.js";import"../chunks/Header-DuP3RNUx.js";import"../chunks/sciam-B_IQ-Vo8.js";import"../chunks/sciam-CvuG93yt.js";import"../chunks/vendor-shared-ShLQKC4n.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new a.Error().stack;t&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[t]="7cb8ad86-4aac-4423-a8c0-d8961c4ede2d",a._sentryDebugIdIdentifier="sentry-dbid-7cb8ad86-4aac-4423-a8c0-d8961c4ede2d")}catch{}})();const T="/static/assets/sharedGiftIcon-DMKV-NTT.png",A=()=>e.jsxs("p",{className:s.giftSubEmailFormError,children:["Something went wrong, please contact"," ",e.jsx("a",{className:s.errorHelpLink,href:"mailto:[email protected]",children:"[email protected]"}),"."]}),G=()=>e.jsx("p",{className:s.giftSubEmailFormSuccess,children:"Your gift has been successfully sent!"}),k=()=>e.jsxs("p",{className:s.giftSubEmailFormNoGiftSub,children:["Looks like you don't have a gift subscription to give, but you can"," ",e.jsx("a",{href:"/getsciam/gift/",children:"purchase one here"}),". Need help? Email"," ",e.jsx("a",{href:"mailto:[email protected]",children:"[email protected]"}),"."]}),f=({children:a})=>e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:s.giftSubEmailFormContainer,children:[e.jsx("img",{src:D,alt:"Laptop and Phone",className:s.laptopAndPhoneImg}),e.jsx("h2",{className:s.giftSubEmailFormHeader,children:"Enter your gift recipient's email"}),e.jsxs("div",{className:s.giftSubEmailFormCard,children:[e.jsx("img",{src:T,alt:"Unlimited Icons",className:s.sharedGiftIcon}),a]})]}),e.jsx("div",{className:s.redeemGiftFaqContainer,children:e.jsx(L,{})})]}),C=({handleFormSubmit:a,loading:t})=>e.jsxs("form",{onSubmit:a,className:s.giftSubEmailForm,children:[e.jsxs("div",{className:s.giftSubEmailFormField,children:[e.jsx("label",{className:s.giftSubEmailFormLabel,htmlFor:"first_name",children:"Recipient's first name:"}),e.jsx("input",{className:s.giftSubEmailFormInput,type:"text",id:"first_name",name:"first_name",placeholder:"First Name",required:!0})]}),e.jsxs("div",{className:s.giftSubEmailFormField,children:[e.jsx("label",{className:s.giftSubEmailFormLabel,htmlFor:"last_name",children:"Recipient's last name:"}),e.jsx("input",{className:s.giftSubEmailFormInput,type:"text",id:"last_name",name:"last_name",placeholder:"Last Name",required:!0})]}),e.jsxs("div",{className:s.giftSubEmailFormField,children:[e.jsx("label",{className:s.giftSubEmailFormLabel,htmlFor:"email",children:"Recipient's email:"}),e.jsx("input",{className:s.giftSubEmailFormInput,type:"email",id:"email",name:"email",placeholder:"[email protected]",required:!0})]}),e.jsxs("div",{className:s.giftSubEmailFormField,children:[e.jsx("label",{className:s.giftSubEmailFormLabel,htmlFor:"signature",children:"Sender:"}),e.jsx("input",{className:s.giftSubEmailFormInput,type:"text",id:"signature",name:"signature",placeholder:"Enter your name",required:!0})]}),e.jsx("button",{className:s.giftSubEmailFormBtn,type:"submit",disabled:t,children:t?"Working on it...":"Send gift!"})]});function q(){const{isLoading:a,isLoggedIn:t,login:m}=v(),{payload:p,token:h,update:u}=_(),{slug:g}=I();l.useEffect(()=>{u()},[]);const[o,c]=l.useState(null),[b,d]=l.useState(!1),x=p?.subscriptions,S=["active","non_renewing","in_trial"],j=x?.some(r=>S.includes(r.status.toLowerCase())&&r.shared_access_remaining),F=async r=>{r.preventDefault();let n=new FormData(r.target);n=Object.fromEntries(n),n=JSON.stringify(n);const E="/platform/api/v2/cb/gifts/shared-sub/create/";d(!0);const N=w(Object.create(globalThis.import_meta_env||null).PUBLIC_SA_API_HOST+E,{body:n,method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","User-Authorization":`Bearer ${h}`,"x-auth-env":g}}).then(i=>(u(),i),i=>(console.error(i),i));try{if(!(await N).ok){c("error");return}c("success")}catch(i){console.error(i),c("error")}finally{d(!1)}};return l.useEffect(()=>{!a&&!t&&m(window.location.href)},[a]),j?e.jsxs(f,{children:[e.jsx("p",{className:s.giftSubEmailFormText,children:"Your gift recipient will receive an email to claim their subscription!"}),o!=="success"?e.jsx(C,{handleFormSubmit:F,loading:b}):null,o==="success"&&e.jsx(G,{}),o==="error"&&e.jsx(A,{})]}):e.jsx(f,{children:e.jsx(k,{})})}function Y(){return e.jsx(y,{children:e.jsx(q,{})})}
1export{Y 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.