OwlCyberSecurity - MANAGER
Edit File: 2429-dce83281d9dba3e1.js
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2429],{85271:function(e,t,a){a.d(t,{$:function(){return s}});function s(e){return e.replace(/[\u06F0-\u06F9]/g,function(e){switch(e){case"۰":e="0";break;case"۱":e="1";break;case"۲":e="2";break;case"۳":e="3";break;case"۴":e="4";break;case"۵":e="5";break;case"۶":e="6";break;case"۷":e="7";break;case"۸":e="8";break;case"۹":e="9"}return e})}},12429:function(e,t,a){a.r(t),a.d(t,{default:function(){return x}});var s=a(57437),n=a(2265),r=a(36596);let o=e=>{let t=Math.floor(e/60),a=Math.floor(e-60*t);return t<=10&&(t="0"+t),a<=10&&(a="0"+a),t+":"+a};var l=function(e){let{loginStepOne:t,registerStepOne:a,userRegister:l,mobileNumberInput:c,setOtpInput:i,otpInput:d,error:p,setErrorMessage:u,industrialOrCarPath:h}=e,[m,x]=(0,n.useState)(120),[g,f]=(0,n.useState)(!1),b=(0,n.useRef)(),[v,j]=(0,n.useState)(0),[w,N]=(0,n.useState)(!1),k=(0,n.useRef)(null);async function S(){if("OTPCredential"in window)try{let e=new AbortController,t=await navigator.credentials.get({otp:{transport:["sms"]},signal:e.signal});t&&t.code&&(N(!0),t.code,i(t.code)),setTimeout(()=>{console.log(d)},2e3)}catch(e){console.log(e)}else console.warn("OTPCredential API is not supported in this browser.")}return(0,n.useEffect)(()=>{S()},[]),(0,n.useEffect)(()=>{var e;null===(e=k.current)||void 0===e||e.focus()},[v]),(0,n.useEffect)(()=>(b.current=setInterval(()=>{x(e=>e-1)},1e3),()=>clearInterval(b.current)),[]),(0,n.useEffect)(()=>{m<=0&&f(!0)},[m]),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{htmlFor:"otp-number1",className:" ".concat(w?"text-gray-600":""),children:"کد ارسال شده"}),(0,s.jsx)("div",{className:"login-form-for-hidden-input ltr",children:(0,s.jsx)(r.Z,{inputType:"tel",value:d,onChange:i,numInputs:4,renderSeparator:(0,s.jsx)("span",{}),renderInput:e=>(0,s.jsx)("input",{...e}),shouldAutoFocus:!0,inputStyle:{width:"3.0em",height:"3.0em",fontSize:"24px",border:"".concat(p?"1px solid var(--base-red)":"1px solid #D7DBEC"),outline:"none",color:"black",borderRadius:"6px",fontFamily:"IRANSansNormal",margin:"0px 5px",background:"transparent"},containerStyle:"flex items-center justify-between w-full"})})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between text-[13px] text-[var(--text-gray)] mt-2",children:[(0,s.jsx)("div",{className:" ".concat(h?"text-white":""),children:g?"":(0,s.jsxs)("div",{children:[o(m)," تا ارسال مجدد "]})}),(0,s.jsx)("div",{children:g?(0,s.jsx)("button",{className:"login-form-for-hidden-button",type:"button",disabled:!g,onClick:function(){l&&(t(),x(120),f(!1),i(""),u("")),l||(a(),x(120),f(!1),i(""),u(""))},children:"ارسال مجدد"}):(0,s.jsx)("span",{className:" ".concat(h?"text-white":""),children:c})})]})]})},c=a(32603),i=a(14438),d=a(50400),p=a(99376),u=a(85271),h=a(27648);let m=e=>RegExp("^(\\+98|09)\\d{9}$").test(e);var x=function(e){let{setShowPopup:t}=e,a=(0,c.I0)(),r=(0,p.usePathname)(),o=(0,p.useRouter)(),[x,g]=(0,n.useState)(""),[f,b]=(0,n.useState)(!1),[v,j]=(0,n.useState)(""),[w,N]=(0,n.useState)(""),[k,S]=(0,n.useState)(!1),[y,A]=(0,n.useState)(!1),[I,C]=(0,n.useState)(!0),[_,E]=(0,n.useState)(!1),[R,O]=(0,n.useState)(""),T=(0,n.useRef)(),B=r.startsWith("/industrial-parts")||r.startsWith("/car-parts");function F(){E(!0);var e=new Headers;e.append("Accept","application/json");var t=new FormData;t.append("cell_number",x),fetch("".concat("https://app.charsooq.com/api/v1/","register-set-number"),{method:"POST",headers:e,body:t}).then(e=>e.json()).then(e=>{if(422===e.status){T.current.style.border="02px solid var(--base-blue)",E(!1),P();return}200===e.status&&(b(!0),N(e.data.user_id),C(!1),A(!0),j("")),429===e.status&&(j(e.message),i.Am.error(e.message))}).catch(e=>console.log("error",e)).finally(()=>E(!1))}function M(){E(!0);var e=new Headers;e.append("Accept","application/json");var t=new FormData;t.append("user_id",w),t.append("otp",R),fetch("".concat("https://app.charsooq.com/api/v1/","register-validate-otp"),{method:"POST",headers:e,body:t}).then(e=>e.json()).then(e=>{console.log(e),422===e.status&&j(e.message),429===e.status&&(j(e.message),i.Am.error(e.message)),200===e.status&&(j(""),localStorage.setItem("token",e.data.token),D(!1))}).catch(e=>console.log("error",e)).finally(()=>E(!1))}function P(){E(!0);var e=new Headers;e.append("Accept","application/json");var t=new FormData;t.append("cell_number",x),fetch("".concat("https://app.charsooq.com/api/v1/","send-otp"),{method:"POST",headers:e,body:t}).then(e=>e.json()).then(e=>{200===e.status&&(b(!0),S(!0),N(e.data.user_id),C(!1),A(!0),j("")),429===e.status&&(j(e.message),i.Am.error(e.message))}).catch(e=>console.log("error",e)).finally(()=>E(!1))}function q(){E(!0);var e=new Headers;e.append("Accept","application/json");var t=new FormData;t.append("user_id",w),t.append("otp",R),fetch("".concat("https://app.charsooq.com/api/v1/","validate-otp"),{method:"POST",headers:e,body:t}).then(e=>e.json()).then(e=>{422===e.status&&(j(e.message),i.Am.error(e.message)),200===e.status&&(j(""),localStorage.setItem("token",e.data.token),D(!0),i.Am.success(e.message)),403===e.status&&(j(e.message),i.Am.error(e.message)),429===e.status&&(j(e.message),i.Am.error(e.message))}).catch(e=>console.log("error",e)).finally(()=>E(!1))}(0,n.useEffect)(()=>{4!==R.length||(k&&(I?P():q()),k||(I?F():M()))},[R]);let D=e=>{let s=localStorage.getItem("token");if(localStorage.getItem("token")){var n=new Headers;n.append("Accept","application/json"),n.append("Authorization","Bearer ".concat(s)),fetch("".concat("https://app.charsooq.com/api/v1/","profile"),{method:"GET",headers:n}).then(e=>e.json()).then(e=>{200===e.status?(localStorage.setItem("user_info",JSON.stringify(e.data)),a((0,d.Ib)(e.data)),a((0,d.sc)(e.data.wallet_balance)),a((0,d.sI)(!0)),function(){let e=localStorage.getItem("token");var t=new Headers;t.append("Accept","application/json"),t.append("Authorization","Bearer ".concat(e)),fetch("".concat("https://app.charsooq.com/api/v1/","address-index"),{method:"GET",headers:t}).then(e=>e.json()).then(e=>{200===e.status&&a((0,d.Kn)(e.data.address))}).catch(e=>console.log("error",e))}(),t(!1),e.data.national_code||setTimeout(()=>{o.push("/dashboard/profile")},500)):i.Am.error("خطا در ثبت اطلاعات.")}).catch(e=>console.log("error",e))}else i.Am.error("خطای سرور")};return(0,s.jsxs)("div",{className:"login-page-content-title",children:[f?(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"flex gap-2 items-center",children:[(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",className:"w-7 h-7 text-[var(--text-gray)] cursor-pointer",onClick:function(){b(!1),j(""),N(""),S(!1),A(!1),C(!0),O("")},children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.25 8.25L21 12m0 0l-3.75 3.75M21 12H3"})}),(0,s.jsx)("h4",{children:"تایید شماره موبایل "})]}),(0,s.jsx)("p",{className:"mb-3 lg:mb-7 ".concat(B?"!text-white":""),children:"برا ی تایید شماره موبایل، لطفا کد ارسالی را وارد نمایید."})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-4 ".concat("/login"===r?"pt-[15px]":""),children:[(0,s.jsx)("h4",{className:"",children:"به چارسوق خوش آمدید"}),(0,s.jsx)("p",{className:"mb-3 lg:mb-7 ".concat(B?"!text-white":""),children:"لطفا شماره موبایل خود را وارد نمایید."})]}),(0,s.jsxs)("form",{onSubmit:e=>{e.preventDefault(),m(x)?(T.current.style="2px solid var(--base-blue)",j(""),k&&(I?P():q()),k||(I?F():M())):(j("شماره موبایل وارد شده نامعتبر است."),T.current.focus(),T.current.style.border="2px solid var(--base-red)")},children:[(0,s.jsxs)("div",{className:"flex flex-col gap-[5px]",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 ".concat(f?"hidden":""),children:[(0,s.jsx)("label",{htmlFor:"phone-number",children:"شماره موبایل"}),(0,s.jsx)("input",{ref:T,type:"text",name:"phone-number",id:"phone-number",placeholder:"شماره موبایل خود را وارد کنید. مثال: 09121111111",value:x,onChange:function(e){(""===e.target.value||/^[0-9\b+۰+۱+۲+۳+۴+۵+۶+۷+۸+۹]+$/.test(e.target.value))&&g((0,u.$)(e.target.value))},dir:x?"ltr":"rtl",className:" ".concat(B?"bg-transparent bg-gradient-to-r from-white/60 to-white/20 !border-none placeholder:text-black":"")})]}),f?(0,s.jsx)(l,{loginStepOne:P,registerStepOne:F,userRegister:k,mobileNumberInput:x,setOtpInput:O,otpInput:R,error:v,setErrorMessage:j,industrialOrCarPath:B}):null,(0,s.jsx)("div",{className:"login-form-error-message",children:(0,s.jsx)("span",{children:v})})]}),y?(0,s.jsxs)("button",{type:"submit",disabled:!1,className:"login-page-button tab2",children:[(0,s.jsx)("span",{className:_?"button-loader active":"button-loader"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-IRANSansBold",children:"ورود"}),(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",className:"w-5 h-5",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 12h-15m0 0l6.75 6.75M4.5 12l6.75-6.75"})})]})]}):(0,s.jsxs)("button",{type:"submit",disabled:!x,className:"login-page-button",children:[(0,s.jsx)("span",{className:_?"button-loader active":"button-loader"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-IRANSansBold",children:"تایید | ارسال کد"}),(0,s.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor",className:"w-5 h-5",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 12h-15m0 0l6.75 6.75M4.5 12l6.75-6.75"})})]})]}),(0,s.jsxs)("p",{className:"text-[12px] text-center font-IRANSansBold ".concat(B?"!text-black":"text-[var(--text-gray)]"),children:["با ایجاد حساب کاربری جدید در چارسوق ، تأیید می کنم که"," ",(0,s.jsx)(h.default,{className:"text-[var(--base-blue)] font-IRANSansBold",href:"/ghavanincharsooq",onClick:()=>{"/login"!==r&&t(!1)},children:"شرایط استفاده و اظهارنامه حریم خصوصی چارسوق"})," ","را خوانده ام و موافقم."]})]})]})}}}]);