PageSourceSearch

https://wirelesschoices.com.au/assets/js/EmailVerification-ggA8nn_p.js

js wirelesschoices.com.au collected 2026-09-25 11:55:01 UTC 11,826 bytes, 1 lines download raw bytes

1import{r as t,j as e}from"./vendor-react-DxD_Nlv7.js";import{H as pe}from"./seo-Zk1C8x9s.js";import{T as he}from"./TurnstileWidget-cDtsCHC9.js";import{w as ne,k as X,j as Z,N as Q,F as ee,B as G}from"./index-Gxvt7SP4.js";import{u as re}from"./useAuthActions-5nPWSPiL.js";import{u as ie,a as xe}from"./vendor-router-R-QXiuK1zB.js";import{A as be,a as ve,H as ye,c as we}from"./cfImage-dalXCgK7.js";import{z as je,bg as Se,a4 as Ne}from"./icons-Q1ONMAdp.js";import"./query-29Ahx5Et.js";import"./notifications-pVj4y6sZ.js";import"./aws-GfI9qLg0.js";import"./utils-validation-BzChuuMT.js";import"./forms-MQMTrd0y.js";import"./utils-core-WYLBMHLG.js";import"./ui-radix-3gUgqgSR.js";import"./ui-motion-nIby3EjP.js";const te=900*1e3,$=60*1e3,J=3,B="pendingVerification";function Ee(){const{user:D}=ne(),{resendVerificationEmail:h}=re(),N=ie(),[E,p]=t.useState(!0),[T,u]=t.useState(null),[P,A]=t.useState(null),[l,j]=t.useState(null),[n,C]=t.useState(null),[U,H]=t.useState(null),m=t.useRef(null),z=t.useMemo(()=>N.state?.email??null,[N.state]),V=t.useCallback((i,a)=>
1{if(!i||typeof i!="object")return null;const s=i,d=s.ts||s.timestamp;if(typeof d!="number"||d<=0||Date.now()-d>te)return null;const g=s.sid||s.sessionId;if(typeof g!="string"||!g)return null;let w="signup";s.action&&["signup","login","protected-route"].includes(s.action)?w=s.action:s.from&&["signup","login","fallback"].includes(s.from)&&(w=s.from==="fallback"?"signup":s.from);let c=null;return a&&typeof a=="string"&&a.includes("@")&&(c=a),!c&&s.email&&typeof s.email=="string"&&(c=s.email),!c||!c.includes("@")||!X(c).isValid?null:{email:c,timestamp:d,sessionId:g,action:w,...typeof s.returnUrl=="string"?{returnUrl:s.returnUrl}:{},resendCount:typeof s.resendCount=="number"?s.resendCount:0}},[]),S=t.useCallback(()=>{try{const i=sessionStorage.getItem(B);if(!i){j(null),C(null),p(!1);return}let a;try{a=JSON.parse(i)}catch{sessionStorage.removeItem(B),j(null),C(null),p(!1);return}j(a);const s=V(a,z);if(!s){sessionStorage.removeItem(B),j(null),C(null),p(!1);return}C(s),H(s.email),p(!1)}catch{sessionStorage.removeItem(B),j(null),C(null),p(!1)}},[V,z]);t.useEffect(()=>{S()},[S]);const f=t.useMemo(()=>U||(n?.email?n.email:l?.email&&typeof l.email=="string"&&l.email.includes("@")?l.email:D?.email?D.email:""),[U,n?.email,l?.email,D?.email]),O=t.useMemo(()=>{const i=f;if(!i)return"";const a=Z(i);if(!a)return"";const[s,d]=a.split("@");return!s||!d?"":s.length<=3?`${s[0]}***@${d}`:`${s.substring(0,2)}****@${d}`},[f]),v=t.useMemo(()=>n?Date.now()-n.timestamp>te:!1,[n?.timestamp]),F=t.useMemo(()=>{if(!n||v||(n.resendCount||0)>=J)return!1;const i=Date.now();return!(m.current&&i-m.current<$)},[n,v]),b=t.useMemo(()=>Math.max(0,J-(n?.resendCount||0)),[n?.resendCount]),L=t.useMemo(()=>{if(!m.current)return null;const i=m.current+$,a=Date.now();return i>a?i:null},[]),R=t.useCallback(()=>{if(!l)return;const i="ts"in l?{ts:Date.now()}:{timestamp:Date.now()},a={...l,...i,resendCount:(n?.resendCount||0)+1};try{sessionStorage.setItem(B,JSON.stringify(a)),j(a),n&&C({...n,timestamp:Date.now(),resendCount:(n.resendCount||0)+1})}catch{u("Failed to update session data")}},[l,n]),y=t.useCallback(()=>{u(null),A(null)},[]),M=t.useCallback(async(i,a)=>{y();const s=i||f;if(!s){u("No email address available");return}const d=Z(s);if(!d){u("Invalid email address");return}if(!X(d).isValid){u("Please provide a valid email address");return}const w=Date.now();if(m.current&&w-m.current<$){const c=Math.ceil(($-(w-m.current))/1e3);u(`Please wait ${c} seconds before trying again.`);return}if((n?.resendCount||0)>=J){u("Maximum resend attempts reached. Please try again later.");return}try{const c=await h(d,a);if(!c.ok){const I=c.message||"Unable to resend verification email";u(I);return}m.current=w,R(),A("Verification email sent! Please check your inbox and spam folder.")}catch{u("An unexpected error occurred. Please try again.")}},[n?.resendCount,R,h,y,f]);return t.useMemo(()=>({loading:E,error:T,success:P,data:n,rawData:l,resolvedEmail:f,obscuredEmail:O,isExpired:v,canResend:F,remainingResends:b,nextResendTime:L,extendSession:R,resend:M,clearMessages:y}),[E,T,P,n,l,f,O,v,F,b,L,R,M,y])}const se="https://wirelesschoices.com.au/images/b578ceb1-ceec-41f8-e604-67961bf45000/public",k=6,Ce=["otp-1","otp-2","otp-3","otp-4","otp-5","otp-6"],Fe=()=>{const D=ie(),h=xe(),{isAuthenticated:N,isEmailVerified:E,isLoading:p}=ne(),{verifyOtp:T}=re(),{loading:u,error:P,success:A,data:l,rawData:j,resolvedEmail:n,obscuredEmail:C,isExpired:U,resend:H}=Ee(),[m,z]=t.useState(Array(k).fill("")),[V,S]=t.useState(null),[f,O]=t.useState(!1),[v,F]=t.useState(!1),b=t.useRef([]),L=t.useRef(!1),R=t.useRef(null),[y,M]=t.useState(null),[i,a]=t.useState(0),[s,d]=t.useState(!1),g=D.state,w=t.useMemo(()=>new URLSearchParams(D.search),[D.search]),c=t.useMemo(()=>{try{return!!sessionStorage.getItem("pendingVerification")}catch{return!1}},[]),I=t.useMemo(()=>N&&E?!1:p||u?c||g?.from==="signup"||g?.from==="login":g?.from==="signup"||g?.from==="login"||!!((j??l)&&!U)||N&&!E||c,[p,u,N,E,g,j,l,U,c]);I&&(L.current=!0),t.useEffect(()=>()=>{v||sessionStorage.removeItem("pendingVerification")},[v]),t.useEffect(()=>{if(!p&&N&&E){const o=w.get("returnUrl")??"/profile";sessionStorage.removeItem("pendingVerification"),h(o,{replace:!0})}},[p,N,E,h,w]),t.useEffect(()=>{L.current||p||u||f||I||h("/",{replace:!0})},[p,u,I,f,h]);const _=t.useMemo(()=>m.join(""),[m]),K=t.useMemo(()=>_.length===k&&/^\d{6}$/.test(_),[_]),ae=t.useCallback((r,o)=>{V&&S(null);const x=o.replace(/\D/g,"").slice(-1);z(q=>{const W=[...q];return W[r]=x,W}),x&&r<k-1&&b.current[r+1]?.focus()},[V]),oe=t.useCallback((r,o)=>{o.key==="Backspace"&&!m[r]&&r>0&&b.current[r-1]?.focus(),o.key==="ArrowLeft"&&r>0&&b.current[r-1]?.focus(),o.key==="ArrowRight"&&r<k-1&&b.current[r+1]?.focus()},[m]),le=t.useCallback(r=>{r.preventDefault();const o=r.clipboardData.getData("text").replace(/\D/g,"").slice(0,k);if(!o)return;const x=o.split("");z(W=>{const Y=[...W];return x.forEach((fe,ge)=>{Y[ge]=fe}),Y});const q=Math.min(x.length,k-1);b.current[q]?.focus()},[]),ce=t.useCallback(async()=>
1{if(!K||f)return;let r=n;if(!r&&g?.email&&typeof g.email=="string"&&g.email.includes("@")&&(r=g.email),!r){S("No email address found. Please sign up again.");return}O(!0),S(null);const o=await T(r,_);o.ok?(F(!0),sessionStorage.removeItem("pendingVerification"),window.history.replaceState(null,"","/email-verification"),setTimeout(()=>{h("/profile",{replace:!0})},1200)):(S(o.error??"Verification failed. Please try again."),z(Array(k).fill("")),b.current[0]?.focus(),a(Date.now()+3e3),setTimeout(()=>a(0),3e3)),O(!1)},[K,n,f,_,T,h]),ue=t.useCallback(async()=>{if(!y){S("Please complete the security check before requesting a new code.");return}S(null),z(Array(k).fill("")),await H(void 0,y),M(null),d(!1),R.current?.reset(),b.current[0]?.focus()},[H,y]),de=t.useCallback(()=>{h(-1)},[h]),me=t.useMemo(()=>!n||(l?.resendCount??0)>=3||!y,[n,l?.resendCount,y]);return p||u?e.jsxs(Q,{children:[e.jsx("div",{className:"flex min-h-[calc(100vh-4rem)] items-center justify-center bg-white pt-16",children:e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-zinc-200 border-t-zinc-700"}),e.jsx("p",{className:"text-sm text-zinc-500",children:"Loading verification..."})]})}),e.jsx(ee,{})]}):I?e.jsxs(Q,{children:[e.jsxs(pe,{children:[e.jsx("title",{children:"Verify Email - Wireless Choices"}),e.jsx("meta",{name:"description",content:"Enter your verification code to activate your Wireless Choices account."})]}),e.jsx("section",{className:"bg-white pt-16",children:e.jsxs("div",{className:"flex w-full items-stretch lg:min-h-[calc(100vh-4rem)]",children:[e.jsxs("section",{className:"relative flex w-full basis-1/2 items-center justify-center p-12 lg:order-1",children:[e.jsxs("button",{type:"button",onClick:de,className:"absolute left-8 top-8 inline-flex items-center gap-2 rounded-full border border-zinc-200 bg-white px-3 py-1.5 text-xs font-medium text-zinc-700 shadow-sm transition hover:bg-zinc-50",children:[e.jsx(je,{className:"h-3.5 w-3.5"}),"Back"]}),e.jsxs("div",{className:"w-full max-w-sm",children:[e.jsx("div",{className:"mx-auto mb-8 flex w-fit items-center justify-center",children:e.jsx("img",{src:"/logo.webp",alt:"Wireless Choices",className:"h-10 w-auto object-contain"})}),e.jsx("h1",{className:"text-center text-3xl font-bold tracking-tight text-zinc-900",children:"Verify your email"}),e.jsx("p",{className:"mt-3 text-center text-sm text-zinc-500",children:"Enter the 6-digit code sent to your email address."}),e.jsxs("div",{className:"mt-6 rounded-lg border border-zinc-200 bg-zinc-50 p-3 text-center text-sm text-zinc-600",children:[e.jsx("p",{children:"Code sent to"}),e.jsx("p",{className:"font-semibold text-zinc-900",children:C||"your email address"})]}),e.jsxs("div",{className:"mt-6 space-y-4",children:[v?e.jsxs("div",{className:"rounded-lg border border-green-200 bg-green-50 p-4 text-sm text-green-800",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-center gap-2 font-medium",children:[e.jsx(Se,{className:"h-4 w-4"}),"Email verified"]}),e.jsx("p",{className:"text-center",children:"Redirecting..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex justify-center gap-2",onPaste:le,children:Ce.map((r,o)=>e.jsx("input",{ref:x=>{b.current[o]=x},type:"text",inputMode:"numeric",autoComplete:o===0?"one-time-code":"off",maxLength:1,value:m[o],onChange:x=>ae(o,x.target.value),onKeyDown:x=>oe(o,x),disabled:f,className:"h-14 w-12 rounded-lg border border-zinc-300 text-center text-xl font-semibold text-zinc-900 transition-colors focus:border-zinc-500 focus:outline-none focus:ring-2 focus:ring-zinc-300/70 disabled:opacity-50","aria-label":`Digit ${o+1}`},r))}),s?e.jsxs("div",{className:"flex flex-col items-center gap-3 rounded-lg border border-zinc-200 bg-zinc-50 p-3",children:[e.jsx(he,{ref:R,onVerify:r=>M(r),onError:()=>M(null),onExpire:()=>M(null)}),e.jsx(G,{variant:"outline",className:"h-10 w-full rounded-lg border-zinc-300",onClick:()=>{ue()},disabled:me,children:"Send new code"})]}):e.jsxs("div",{className:"text-center text-sm text-zinc-600",children:["Didn't receive the code? Check your spam folder or"," ",e.jsx(G,{variant:"link",className:"h-auto p-0 text-sm font-semibold text-zinc-800",onClick:()=>d(!0),children:"request a new code"}),"."]})]}),A&&!v&&e.jsx("div",{className:"rounded-lg border border-green-200 bg-green-50 p-3 text-center text-sm text-green-800",children:A}),(V??P)&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-3 text-center text-sm text-red-800",children:V??P}),!n&&e.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3 text-sm text-amber-800",children:e.jsx("p",{children:"No email address available. Please sign up or log in again."})}),!v&&e.jsx(G,{onClick:()=>{ce()},disabled:!K||f||i>Date.now(),className:"h-11 w-full rounded-lg bg-black text-sm font-semibold text-white hover:opacity-90",children:f?e.jsxs(e.Fragment,{children:[e.jsx(Ne,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Email"}),e.jsx("button",{type:"button",onClick:()=>{h("/signup?tab=login")},className:"inline-flex w-full items-center justify-center text-xs font-medium text-zinc-600 underline underline-offset-2 hover:text-zinc-900",children:"Back to sign in"})]})]})]}),e.jsx("section",{className:"relative hidden basis-1/2 p-3 sm:p-4 lg:order-2 lg:block",children:e.jsx("div",{className:"relative h-full min-h-[650px] overflow-hidden rounded-3xl",children:e.jsx("img",{src:we(se,{w:1280}),srcSet:ve(se,ye),sizes:be,alt:"Wireless Choices visual",className:"h-full w-full object-cover animate-wc-image-float",loading:"eager",decoding:"async"})})})]})}),e.jsx(ee,{})]}):null};export{Fe as EmailVerification};

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.