PageSourceSearch

https://www.straitstimes.com/assets/ManageNewsletterPage-wO1FKk8P.js

js straitstimes.com collected 2026-10-01 07:56:47 UTC 4,424 bytes, 1 lines download raw bytes

1import{A as e,I as t,O as n,j as r}from"./chunk-KS7C4IRE-DIkipulk.js";import{t as i}from"./jsx-runtime-CsaOnxTR.js";import{l as a}from"./components-JSzoenoU.js";import{$r as o,Aa as s,Ea as c,Fi as l,Ia as u,La as d,Li as f,Na as p,Ra as m,Vi as h,Xi as g,Xr as _,Yi as v,Yr as y,Zi as b,Zr as x,ca as S,f as C,jr as w,k as T,m as E,yn as D}from"./Elements-C-xYWSPQ.js";import{t as O}from"./PageLayout-CMR1o20j.js";var k=t(r(),1),A=i(),j=e(function(){let{userInfo:e,isAuthenticated:t}=c(e=>e),r=n(),[i,j]=(0,k.useState)(null),[M,N]=(0,k.useState)(0),[P,F]=(0,k.useState)([]),[I,L]=(0,k.useState)(!0),R=(0,k.useCallback)(async()=>{try{let t=await w(`consent/fetch`,`POST`,{email:e?.email_id??``},!1);if(t.success){let e=E(t.data.consents);F(e),N(e.length)}else N(0),j({type:_.ERROR,message:`Something went wrong.`,description:`An error was encountered while trying to load the page. Please refresh the page.`})}catch{N(0),j({type:_.ERROR,message:`Something went wrong.`,description:`An error was encountered while trying to load the page. Please refresh the page.`})}},[e?.email_id]),z=(0,k.useCallback)(async t=>{s({eventCategory:p.NEWSLETTER_SIGN_UP,eventAction:`click -`,eventLabel:t.name}),await w(`consent/sync`,`POST`,{email:e?.email_id??``,consents:[{name:t.consent_name,status:`withdrawn`}]},!1).then(e=>{e.success?(N(M-1),F(P.filter(e=>e.id!==t.id)),s({eventCategory:p.NEWSLETTER_SIGN_UP,eventAction:`visible`,eventLabel:`you're unsubscribed`}),j({type:_.SUCCESS,message:`You've unsubscribed`,description:`Explore more newsletters on our newsletter page.`})):j({type:_.ERROR,message:`Something went wrong.`,description:`An error was encountered while trying to unsubscribe you. Please try again later.`})})},[e?.email_id,M,P]);return(0,k.useEffect)(()=>{let e;return t?(L(!1),R()):(L(!0),e=setTimeout(()=>{console.info(`Session::No user session found. Redirecting...`),r(`/newsletter-signup`)},1e4)),()=>{e&&clearTimeout(e)}},[t,e?.email_id,r]),(0,A.jsxs)(O,{lb1Ad:void 0,gaData:{title:`Manage newsletters`},children:[(0,A.jsx)(`div`,{className:u(`container sticky top-72 mt-10 right-00 h-00 z-1000`,i===null?`hidden`:`block`),id:`newsletter-toast`,children:i!==null&&(0,A.jsx)(y,{type:i.type,message:i.message,descriptionMessage:i.description,duration:5e3,className:`absolute right-00 w-full tablet:w-fit tablet:mt-10`,handler:()=>{j(null)}})}),(0,A.jsx)(D,{title:`Newsletters`,url:`/newsletter-signup`,navigationItems:[{title:`Manage newsletters`,url:`/newsletter-manage`}]}),(0,A.jsx)(`div`,{className:`container`,children:I?(0,A.jsx)(`div`,{className:`flex justify-center items-center h-300 tablet:h-500`,children:(0,A.jsx)(o,{iconName:d.LOADER,className:`!icon-placeholder`,iconWidth:m.REGULAR,testId:`manage-newsletter-loader-test-id`})}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`dynamic-padding-y `,children:[(0,A.jsx)(h,{category:v.TITLE,size:g.SM,style:b.REGULAR,testId:`newsletter-manage-intro-text-test-id`,className:`text-secondary inline-block`,children:`You are logged in as`}),` `,(0,A.jsx)(h,{category:v.TITLE,size:g.SM,style:b.SEMIBOLD,testId:`newsletter-manage-intro-text-email-test-id`,className:`inline-block text-secondary break-all `,children:S(e?.email_id??``)})]}),M>0?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(h,{category:v.TITLE,size:g.SM,style:b.BOLD,className:`text-secondary py-08 tablet:py-12 desktop:py-16`,children:[`You are subscribed to `,M,` `,M>1?`newsletters`:`newsletter`]}),(0,A.jsx)(`div`,{className:u(`newsletter-manage-list-container`),children:(0,A.jsx)(`div`,{className:`newsletter-grid`,children:T().map(e=>P.map(t=>{if(t.id===e.id)return(0,A.jsx)(C,{newsletter:e,button:(0,A.jsx)(`button`,{"data-testid":`manage-newsletter-remove-consent-${e.consent_name}-test-id`,onClick:()=>{z(e)},children:(0,A.jsx)(o,{iconName:d.ACTION_REMOVE_OUTLINED,iconWidth:m.XL,className:`status-error-icon`})}),className:`newsletter-card`},e.id)}))})})]}):(0,A.jsxs)(`div`,{className:`h-300 tablet:h-500 w-full flex self-stretch flex-col gap-24 desktop:gap-32 items-center justify-center`,children:[(0,A.jsx)(h,{category:v.TITLE,size:g.SM,style:b.REGULAR,className:`text-secondary`,children:`You have no subscribed newsletters.`}),(0,A.jsx)(x,{fill:l.PRIMARY,type:f.TEXT_ONLY,handler:()=>{a&&r(`/newsletter-signup?ref=manage-newsletter`)},className:`w-fit`,text:`Explore newsletters`,textClassName:`font-secondary-label-lg-semibold`})]})]})})]})});export{j 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.