PageSourceSearch

https://www.scientificamerican.com/static/entry/account-link.TBSkieLh.js

js scientificamerican.com collected 2026-09-24 07:34:55 UTC 4,870 bytes, 1 lines download raw bytes

1import{r as o,j as n}from"../chunks/vendor-react-DdEP1kCQ.js";import{D as F}from"../chunks/DefaultLayout-B4mESSua.js";import{k as S,e as w,g as T,x as E,f as A}from"../chunks/core-Bpuic6mr.js";import{F as M}from"../chunks/index-CsyIcmAv.js";import{B}from"../chunks/BlueNotice-c2R8x8S3.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 t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new t.Error().stack;a&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="ffb9e38b-4ebd-44ee-b37c-cfa0a70859d2",t._sentryDebugIdIdentifier="sentry-dbid-ffb9e38b-4ebd-44ee-b37c-cfa0a70859d2")}catch{}})();const U="/static/assets/mailingLabel-Cc965bw2.jpg",_="accountLinkContainer-8vtR2",D="accountLinkMainText-l17TA",O="accountLinkImageContainer--FlDa",P="accountLinkImageText-Afpjz",G="accountLinkBtn-MR6-i baseBtn-ZNLef largeBtn-jOmOm blue3Btn-bZbVn",H="accountLinkContactUs-Bbwa6",R="accountLinkErrorMessage-owJr3 accountLinkMessage-seJxJ",J="accountLinkFormContainer-sPHHj",W="accountLinkFormGroup-SRcBm",Y="accountLinkFormInput--VsEC",q="accountLinkNoForm-P9lHO",e={accountLinkContainer:_,accountLinkMainText:D,accountLinkImageContainer:O,accountLinkImageText:P,accountLinkBtn:G,accountLinkContactUs:H,accountLinkErrorMessage:R,accountLinkFormContainer:J,accountLinkFormGroup:W,accountLinkFormInput:Y,accountLinkNoForm:q},V=({responseStatus:t})=>t===409?n.jsxs("p",{className:e.accountLinkErrorMessage,children:["Looks like your account is already linked, please contact"," ",n.jsx("a",{className:e.accountLinkContactUs,href:"mailto:[email protected]",children:"[email protected]"}),"."]}):n.jsxs("p",{className:e.accountLinkErrorMessage,children:["We're having trouble linking your account, please contact"," ",n.jsx("a",{className:e.accountLinkContactUs,href:"mailto:[email protected]",children:"[email protected]"}),"."]}),Z=()=>n.jsx("div",{className:e.accountLinkContainer,children:n.jsxs("div",{className:e.accountLinkNoForm,children:[n.jsx("h2",{className:e.accountLinkMainText,children:"You already have an active subscription!"}),n.jsxs("p",{children:["Check out our latest stories on the"," ",n.jsx("a",{className:e.accountLinkContactUs,href:"/",children:"homepage"})," ","or view your"," ",n.jsx("a",{className:e.accountLinkContactUs,href:"/account/",children:"account"}),". Have questions? Contact"," ",n.jsx("a",{className:e.accountLinkContactUs,href:"mailto:[email protected]",children:"[email protected]"})]})]})});function z(){const{isLoading:t,isLoggedIn:a,login:l}=S(),{slug:L}=w(),{update:p,token:m}=T(),{activeSubscriptions:f}=E(),[g,b]=o.useState(""),[r,s]=o.useState(null),[x,u]=o.useState(null),[d,h]=o.useState(!1),[j,y]=o.useState(!1);if(o.useEffect(()=>{!t&&!a&&l(window.location.href)},[t]),o.useEffect(()=>{!t&&!a||y(!!f?.length)},[t,a]),j)return n.jsx(Z,{});function N(i){u(null),s(null),b(i)}async function C(i){const{accountNumber:k}=i;if(!k||!m)return;u(null),s(null),h(!0);const I=`/platform/api/v2/user/cds/link-entitlements/${k}/`,v=A(m,L,Object.create(globalThis.import_meta_env||null).PUBLIC_SA_API_HOST+I,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded"}}).then(c=>(p(),c),c=>(console.error(c),c));try{const c=await v;if(!c.ok){s("error"),u(c.status);return}s("success")}catch(c){console.error(c),s("error")}finally{h(!1)}}return n.jsxs("div",{className:e.accountLinkContainer,children:[n.jsxs(B,{showNotice:r==="success",children:["Your account has been successfully linked! Go to the ",n.jsx("a",{href:"/",children:"homepage"}),"."]}),n.jsx("h2",{className:e.accountLinkMainText,children:"Need to lookup your account number?"}),n.jsxs("figure",{className:e.accountLinkImageContainer,children:[n.jsx("p",{className:e.accountLinkImageText,children:"Your account number can be found on your mailing label in the highlighted area shown below."}),n.jsx("img",{src:U,alt:"Account number lookup"})]}),r!=="success"?n.jsxs(M,{onFormSubmit:C,className:e.accountLinkFormContainer,children:[n.jsxs("div",{className:e.accountLinkFormGroup,children:[n.jsx("label",{htmlFor:"accountNumber",children:"Enter your account number:"}),n.jsx("input",{className:e.accountLinkFormInput,id:"accountNumber",name:"accountNumber",onChange:i=>N(i.target.value),required:!0,type:"text",value:g})]}),n.jsxs("div",{children:[n.jsx("button",{className:e.accountLinkBtn,type:"submit",disabled:d,children:d?"Working on it...":"Submit"}),n.jsx("p",{className:e.accountLinkImageText,children:"Please note that it may take up to 24 hours from the time of purchase for you to be able to link your subscription."})]})]}):null,r==="error"&&n.jsx(V,{responseStatus:x})]})}function an(){return n.jsx(F,{children:n.jsx(z,{})})}
1export{an 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.