1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3459],{83236:function(e,s,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/login",function(){return t(23520)}])},23520:function(e,s,t){"use strict";t.r(s),t.d(s,{default:function(){return y}});var n=t(85893),a=t(67294),i=t(87536),r=t(56312),l=t(88446),o=t(39332),d=t(94933),u=t(45977),c=t(11607),m=t(34464),x=t(36316),g=t(86501),p=t(92106),h=t(48583),v=t(94543);let f=p.Ry({login:p.Z_().min(1,"Username or email is required"),password:p.Z_().min(1,"Password is required"),otp:p.Z_().optional()});var y=function(){let e=(0,h.Dv)(v.ZP),s=(0,h.b9)(v.ZP),[t,p]=(0,a.useState)(!1),[y,w]=(0,a.useState)(!1),[b,j]=(0,a.useState)(!1),[N,_]=(0,a.useState)(null),[P,Z]=(0,a.useState)(["","","","","",""]),S=(0,o.useRouter)(),k=(0,a.useRef)([]),[E,O]=(0,a.useState)(0),{register:T,handleSubmit:C,setValue:I,watch:D,formState:{errors:L}}=(0,i.cI)({resolver:(0,r.F)(f)}),R=(e,s)=>{var t,n;if(!/^\d?$/.test(e))return;let a=[...P];a[s]=e,Z(a),I("otp",a.join("")),e&&s<5&&(null===(t=k.current[s+1])||void 0===t||t.focus()),!e&&s>0&&(null===(n=k.current[s-1])||void 0===n||n.focus())};(0,a.useEffect)(()=>{e.isLoggedIn&&S.push("/")},[e]);let F=()=>{O(30);let e=setInterval(()=>{O(s=>s<=1?(clearInterval(e),0):s-1)},1e3)},V=async e=>{var s,t,n,a;try{p(!0);let n=e.login.includes("@"),a={password:e.password};n?a.email=e.login:a.user_name=e.login;let i=await l.Z.post("/user/loginotp",a);(null===(s=i.data)||void 0===s?void 0:s.data)?(w(!0),_(i.data.data.verify_nologin_id),g.ZP.success("OTP sent successfully!"),F()):g.ZP.error((null===(t=i.data)||void 0===t?void 0:t.message)||"Failed to send OTP")}catch(e){g.ZP.error((null===(n=e.response)||void 0===n?void 0:null===(a=n.data)||void 0===a?void 0:a.error)||"Something went wrong. Please try again.")}finally{p(!1)}},q=async e=>{var t,n,a,i,r,o,d,u;try{if(p(!0),!N){g.ZP.error("Verification ID not found. Please try again.");return}let d=e.login.includes("@"),u={password:e.password,otp:parseInt(P.join("")),verify_nologin_id:N};d?u.email=e.login:u.user_name=e.login;let c=await l.Z.post("/user/login",u);if((null==c?void 0:null===(t=c.data)||void 0===t?void 0:t.message)==="Authentication Success"){let e={loading:!1,isLoggedIn:!0,userDetails:{user_id:null==c?void 0:null===(n=c.data)||void 0===n?void 0:n.user.id,name:null==c?void 0:null===(a=c.data)||void 0===a?void 0:a.user.user_name,current_limit:null==c?void 0:null===(i=c.data)||void 0===i?void 0:i.user.current_limit,limit:null==c?void 0:null===(r=c.data)||void 0===r?void 0:r.user.limit,status:null==c?void 0:null===(o=c.data)||void 0===o?void 0:o.user.status}};s(e)}200===c.status?(g.ZP.success("Login successful! \uD83C\uDF89"),S.push("/")):g.ZP.error(c.data.error||"Login failed!")}catch(e){g.ZP.error((null===(d=e.response)||void 0===d?void 0:null===(u=d.data)||void 0===u?void 0:u.error)||"Something went wrong. Please try again.")}finally{p(!1)}},U=async e=>{y?await q(e):await V(e)};return(0,n.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br px-4 py-8",children:(0,n.jsxs)("div",{className:"w-full max-w-md p-8 bg-white rounded-2xl shadow-xl",children:[(0,n.jsxs)("div",{className:"text-center mb-8",children:[(0,n.jsx)("h2",{className:"text-3xl font-bold text-gray-800",children:"Welcome Back"}),(0,n.jsx)("p",{className:"text-gray-600 mt-2",children:"Sign in to continue your journey"})]}),(0,n.jsxs)("form",{onSubmit:C(U),className:"space-y-5",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{className:"block text-sm font-medium mb-2 text-gray-700",children:"Username or Email"}),(0,n.jsxs)("div",{className:"flex items-center border border-gray-300 rounded-lg px-3 py-2 focus-within:ring-2 focus-within:ring-blue-500",children:[(0,n.jsx)(d.Z,{className:"w-5 h-5 text-gray-400 mr-2"}),(0,n.jsx)("input",{type:"text",...T("login"),className:"w-full outline-none",placeholder:"Enter your username or email",disabled:y})]}),L.login&&(0,n.jsx)("p",{className:"text-red-500 text-sm mt-1",children:L.login.message})]}),(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("label",{className:"block text-sm font-medium mb-2 text-gray-700",children:"Password"}),(0,n.jsxs)("div",{className:"flex items-center border border-gray-300 rounded-lg px-3 py-2 focus-within:ring-2 focus-within:ring-blue-500",children:[(0,n.jsx)(u.Z,{className:"w-5 h-5 text-gray-400 mr-2"}),(0,n.jsx)("input",{type:b?"text":"password",...T("password"),className:"w-full outline-none",placeholder:"Enter your password",disabled:y}),(0,n.jsx)("button",{type:"button",className:"text-gray-400 hover:text-gray-600",onClick:()=>j(!b),disabled:y,children:b?(0,n.jsx)(c.Z,{className:"w-5 h-5"}):(0,n.jsx)(m.Z,{className:"w-5 h-5"})})]}),L.password&&(0,n.jsx)("p",{className:"text-red-500 text-sm mt-1",children:L.password.message})]}),y&&(0,n.jsxs)("div",{className:"space-y-4",children:[(0,n.jsx)("label",{className:"block text-sm font-medium text-gray-700",children:"Enter OTP"}),(0,n.jsx)("div",{className:"flex gap-2 justify-center",children:P.map((e,s)=>(0,n.jsx)("input",{ref:e=>k.current[s]=e,type:"text",value:e,maxLength:1,onChange:e=>R(e.target.value,s),className:"w-12 h-12 text-center border border-gray-300 rounded-lg text-lg focus:ring-2 focus:ring-blue-500"},s))}),L.otp&&(0,n.jsx)("p",{className:"text-red-500 text-sm mt-1",children:L.otp.message}),(0,n.jsx)("p",{className:"text-sm text-gray-600 text-center",children:"We've sent a verification code to your registered email/mobile"})]}),y&&(0,n.jsx)("div",{className:"text-center mt-4",children:E>0?(0,n.jsxs)("p",{className:"text-sm text-gray-500",children:["Resend OTP in"," ",(0,n.jsxs)("span",{className:"font-medium",children:[E,"s"]})]}):(0,n.jsx)("button",{type:"button",onClick:()=>V({login:D("login"),password:D("password")}),className:"text-blue-600 hover:underline text-sm font-medium",children:"Resend OTP"})}),(0,n.jsx)("div",{className:"mt-6",children:(0,n.jsx)("button",{type:"submit",disabled:t,className:"w-full bg-blue-600 text-white py-3 rounded-lg hover:bg-blue-700 transition disabled:opacity-50 font-medium flex items-center justify-center",children:t?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(x.Z,{className:"w-5 h-5 animate-spin mr-2"}),y?"Verifying...":"Sending OTP..."]}):y?"Verify & Login":"Send OTP"})}),(0,n.jsxs)("p",{className:"text-center text-gray-600 text-sm mt-4",children:["Don't have an account?"," ",(0,n.jsx)("span",{className:"text-blue-600 cursor-pointer hover:underline font-medium",onClick:()=>S.push("/register"),children:"Sign up"})]})]})]})})}}},function(e){e.O(0,[8587,9774,2888,179],function(){return e(e.s=83236)}),_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.