1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7867],{74964:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/auth/verify-email",function(){return n(27772)}])},27772:function(e,t,n){"use strict";n.r(t),n.d(t,{__N_SSG:function(){return P},default:function(){return VerifyEmailOtp}});var a=n(74817),o=n(71248),i=n(54389),l=n.n(i),r=n(23087),u=n(19598),d=n(56481),c=n(46670),s=n(55007),p=n(21110),h=n.n(p),v=n(76975),f=n(16628),g=n(70795),m=n(51711),y=n(66741),x=n(36497),b=n(67833),isStyleObject=function(e){return"object"==typeof e&&null!==e},OTPInput=function(e){var t=e.value,n=void 0===t?"":t,a=e.numInputs,i=void 0===a?4:a,l=e.onChange,r=e.onPaste,u=e.renderInput,d=e.shouldAutoFocus,c=void 0!==d&&d,s=e.inputType,p=void 0===s?"text":s,h=e.renderSeparator,v=e.placeholder,f=e.containerStyle,g=e.inputStyle,m=e.skipDefaultStyles,y=void 0!==m&&m,x=o.useState(0),b=x[0],w=x[1],j=o.useRef([]),getOTPValue=function(){return n?n.toString().split(""):[]},P="number"===p||"tel"===p;o.useEffect(function(){j.current=j.current.slice(0,i)},[i]),o.useEffect(function(){var e;c&&(null===(e=j.current[0])||void 0===e||e.focus())},[c]);var getPlaceholderValue=function(){if("string"==typeof v){if(v.length===i)return v;v.length>0&&console.error("Length of the placeholder should be equal to the number of inputs.")}},isInputValueValid=function(e){return(P?!isNaN(Number(e)):"string"==typeof e)&&1===e.trim().length},handleChange=function(e){var t=e.target.value;isInputValueValid(t)&&(changeCodeAtFocus(t),focusInput(b+1))},handleInputChange=function(e){var t=e.nativeEvent,n=e.target.value;isInputValueValid(n)||(n.length!==i||n.split("").some(function(e){return!isInputValueValid(e)})||(handleOTPChange(n.split("")),focusInput(i-1)),null===t.data&&"deleteContentBackward"===t.inputType&&(e.preventDefault(),changeCodeAtFocus(""),focusInput(b-1)),e.target.value="")},handleBlur=function(){w(b-1)},handleKeyDown=function(e){var t=getOTPValue();[e.code,e.key].includes("Backspace")?(e.preventDefault(),changeCodeAtFocus(""),focusInput(b-1)):"Delete"===e.code?(e.preventDefault(),changeCodeAtFocus("")):"ArrowLeft"===e.code?(e.preventDefault(),focusInput(b-1)):"ArrowRight"===e.code?(e.preventDefault(),focusInput(b+1)):e.key===t[b]?(e.preventDefault(),focusInput(b+1)):("Spacebar"===e.code||"Space"===e.code||"ArrowUp"===e.code||"ArrowDown"===e.code)&&e.preventDefault()},focusInput=function(e){var t,n,a=Math.max(Math.min(i-1,e),0);j.current[a]&&(null===(t=j.current[a])||void 0===t||t.focus(),null===(n=j.current[a])||void 0===n||n.select(),w(a))},changeCodeAtFocus=function(e){var t=getOTPValue();t[b]=e[0],handleOTPChange(t)},handleOTPChange=function(e){l(e.join(""))},handlePaste=function(e){e.preventDefault();var t,n=getOTPValue(),a=b,o=e.clipboardData.getData("text/plain").slice(0,i-b).split("");if(!(P&&o.some(function(e){return isNaN(Number(e))}))){for(var l=0;l<i;++l)l>=b&&o.length>0&&(n[l]=null!==(t=o.shift())&&void 0!==t?t:"",a++);focusInput(a),handleOTPChange(n)}};return o.createElement("div",{style:Object.assign({display:"flex",alignItems:"center"},isStyleObject(f)&&f),className:"string"==typeof f?f:void 0,onPaste:r},Array.from({length:i},function(e,t){return t}).map(function(e){var t,n,a;return o.createElement(o.Fragment,{key:e},u({value:null!==(t=getOTPValue()[e])&&void 0!==t?t:"",placeholder:null!==(a=null===(n=getPlaceholderValue())||void 0===n?void 0:n[e])&&void 0!==a?a:void 0,ref:function(t){return j.current[e]=t},onChange:handleChange,onFocus:function(t){w(e),t.target.select()},onBlur:handleBlur,onKeyDown:handleKeyDown,onPaste:handlePaste,autoComplete:"off","aria-label":"Please enter OTP character ".concat(e+1),style:Object.assign(y?{}:{width:"1em",textAlign:"center"},isStyleObject(g)?g:{}),className:"string"==typeof g?g:void 0,type:p,inputMode:P?"numeric":"text",onInput:handleInputChange},e),e<i-1&&("function"==typeof h?h(e):h))}))},w=n(909),j=n(556),P=!0;function VerifyEmailOtp(e){let{email:t,token:n,key:i}=e,p=(0,v.Z)({typography:{fontFamily:"Work Sans"}}),{t:P}=(0,b.Z)("verify-email"),S=(0,x.useRouter)(),{locale:O}=S,[C,I]=o.useState(!1),[k,T]=o.useState(""),[V,N]=o.useState("error"),[E,D]=o.use
1State(""),[_,A]=o.useState(n),[Z,F]=o.useState(i),[B,R]=o.useState(""),z=(0,j.E)();o.useEffect(()=>{try{var e;let t=new URLSearchParams(window.location.search),n=null!==(e=t.get("reset-password"))&&void 0!==e?e:z.isChangePassword;z.setIsChangePassword(n);let a=t.get("token"),o=t.get("code"),i=t.get("key"),l=t.get("redirectTo");"true"==n&&(n=!0),null!=a&&null!=i&&(A(a),D(null!=o?o:""),F(window.atob(i)),R(null!=l?l:""),null!=o&&proceedSubmitOtp(n))}catch(e){}},[]);let proceedSubmitOtp=async e=>{var t,n,a;if(E.length<6)return!1;I(!0);try{if(await (0,w.v7)(_,E,Z,e),e)S.push("/".concat(O,"/auth/change-password")),setTimeout(()=>{I(!1)},1e3);else{if(z.login(),B.length>=5)try{window.location.href=null!==(t=window.atob(B))&&void 0!==t?t:"/";return}catch(e){}S.push("/".concat(O)),setTimeout(()=>{I(!1)},1e3)}}catch(e){N("error"),T(null==e?void 0:null===(a=e.response)||void 0===a?void 0:null===(n=a.data)||void 0===n?void 0:n.message),I(!1)}};o.useEffect(()=>{E.length>=6&&proceedSubmitOtp(z.isChangePassword)},[E]);let proceedSubmitResendOtp=async()=>{var e,t,n,a,o,i,l,r,u,d,c,s,p,h,v,f,g;try{T(""),I(!0);let f=await (0,w.A$)(_,"");(null==f?void 0:f.status)==200&&(null==f?void 0:null===(n=f.data)||void 0===n?void 0:null===(t=n.data)||void 0===t?void 0:null===(e=t.data)||void 0===e?void 0:e.otpVerificationToken)&&(A(null==f?void 0:null===(i=f.data)||void 0===i?void 0:null===(o=i.data)||void 0===o?void 0:null===(a=o.data)||void 0===a?void 0:a.token),F(null==f?void 0:null===(u=f.data)||void 0===u?void 0:null===(r=u.data)||void 0===r?void 0:null===(l=r.data)||void 0===l?void 0:l.otpVerificationToken),S.push("/".concat(O,"/auth/verify-email?token=").concat(null==f?void 0:null===(s=f.data)||void 0===s?void 0:null===(c=s.data)||void 0===c?void 0:null===(d=c.data)||void 0===d?void 0:d.token,"&reset-password=true&key=").concat(window.btoa(null==f?void 0:null===(v=f.data)||void 0===v?void 0:null===(h=v.data)||void 0===h?void 0:null===(p=h.data)||void 0===p?void 0:p.otpVerificationToken))))}catch(e){T(null==e?void 0:null===(g=e.response)||void 0===g?void 0:null===(f=g.data)||void 0===f?void 0:f.message)}I(!1)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l(),{children:(0,a.jsx)("title",{children:"Verify Email OTP"})}),(0,a.jsx)(f.Z,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+5},open:C,children:(0,a.jsx)(g.Z,{color:"inherit"})}),(0,a.jsx)(m.Z,{theme:p,children:(0,a.jsxs)("main",{className:"".concat(h().main," ").concat(h().loginBG),children:[(0,a.jsx)(r.Z,{title:"Verify Email OTP"}),(0,a.jsx)("div",{className:h().loginBoxCenter,children:(0,a.jsx)(u.Z,{className:h().containerBox,children:(0,a.jsx)(d.ZP,{container:!0,justifyContent:"center",spacing:3,children:(0,a.jsx)(d.ZP,{item:!0,sm:9,md:6,xs:12,children:(0,a.jsxs)("div",{className:h().loginBox,children:[(0,a.jsx)(c.Z,{variant:"h2",children:P("header1")}),(0,a.jsx)(c.Z,{variant:"body1",children:P("subHeader1")}),(0,a.jsxs)("form",{method:"post",children:[(0,a.jsx)("div",{className:"mx-auto input-otp-code",style:{textAlign:"center"},children:(0,a.jsx)(OTPInput,{value:E,onChange:D,inputStyle:{gap:"1px",margin:"auto",padding:"10px",width:"37px",height:"40px",border:"0.3px solid lightgray",borderRadius:"10px",color:"black",fontSize:"1rem",background:"#eee"},numInputs:6,placeholder:"******",renderInput:e=>(0,a.jsx)("input",{...e,type:"text",pattern:"[0-9]*"})})}),(0,a.jsx)(s.Z,{onClick:e=>proceedSubmitOtp(z.isChangePassword),type:"button",variant:"contained",fullWidth:!0,className:"my-4 ".concat(h().btn," ").concat(h().btn_primary),children:P("Submit-btn")}),k&&""!=k&&(0,a.jsx)(y.Z,{severity:V,className:"mb-3",children:k})]}),(0,a.jsxs)(c.Z,{variant:"body1",children:[P("not-received-code")," ",(0,a.jsxs)("a",{onClick:e=>proceedSubmitResendOtp(),href:"#",children:[" ",P("resend-code-otp")," "]})]})]})})})})})]})})]})}}},function(e){e.O(0,[5445,1405,6741,3087,9774,2888,179],function(){return e(e.s=74964)}),_N_E=e.O()}]);
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.