(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[327],{20508:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(71847).A)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]])},42284:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>A});var r=s(95155),a=s(12115),l=s(20063),i=s(52619),n=s.n(i),d=s(3998),o=s(65142),c=s(55010),h=s(76444),m=s(18332),x=s(99550),u=s(20508),p=s(23664),w=s(99708),y=s(70532),j=s(57828),g=s(36489),f=s(58261),N=s(76343),b=s(37861),v=s(66091),k=s(67734);function A(){let e=(0,l.useRouter)(),t=(0,k.Ps)(),s=(0,k.jA)(),[i,A]=(0,a.useState)(!0),[S,C]=(0,a.useState)({name:"",email:"",password:"",confirmPassword:""}),[E,P]=(0,a.useState)(!1),[F,O]=(0,a.useState)(!1),[T,_]=(0,a.useState)(!1),[q,J]=(0,a.useState)(!1),[M,R]=(0,a.useState)(""),[U,D]=(0,a.useState)("");(0,a.useEffect)(()=>{A(!1)},[t,s]),(0,a.useEffect)(()=>{i||!t||s||e.push("/auth/customer/signup/phone")},[t,s,i,e]);let H=e=>{let{name:t,value:s}=e.target;C(e=>({...e,[t]:s}))},I=async t=>{if(t.preventDefault(),R(""),D(""),(()=>{if(!S.name.trim())return R("نام الزامی است"),!1;if(!S.email.trim())return R("ایمیل الزامی است"),!1;if(!S.email.includes("@"))return R("ایمیل معتبر نیست"),!1;let e=(0,N.Oj)(S.password);return e.isValid?S.password===S.confirmPassword||(R("رمز عبور و تأیید آن مطابقت ندارند"),!1):(R(e.errors[0]),!1)})()){J(!0);try{let t=await fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S.name,email:S.email,password:S.password,role:"CUSTOMER"})}),s=await t.json();if(!t.ok)if(400===t.status)throw Error(s.message||"اطلاعات وارد شده نامعتبر است");else if(409===t.status)throw Error("کاربری با این ایمیل قبلاً ثبت نام کرده است");else throw Error("خطای سرور. لطفاً دوباره تلاش کنید");D("ثبت نام با موفقیت انجام شد! در حال ورود..."),await (0,f.SP)(S.email,S.password,"CUSTOMER",g.signIn,e)}catch(e){e instanceof Error?R(e.message):R("خطای غیرمنتظره‌ای رخ داد. لطفاً دوباره تلاش کنید")}finally{J(!1)}}};return(0,r.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-purple-900 via-blue-900 to-indigo-900 p-4",children:(0,r.jsxs)("div",{className:"max-w-md w-full space-y-8 bg-white/10 backdrop-blur-lg rounded-xl border border-white/20 p-8",children:[(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"flex justify-center mb-4",children:(0,r.jsx)("div",{className:"p-3 bg-gradient-to-r from-purple-600 to-blue-600 rounded-full",children:(0,r.jsx)(x.A,{className:"h-8 w-8 text-white"})})}),(0,r.jsx)("h2",{className:"text-3xl font-bold text-white mb-2",children:"ثبت‌نام بازیکن"}),(0,r.jsx)("p",{className:"text-gray-300",children:"عضو جامعه گیمرهای پلیمو شوید"})]}),M&&(0,r.jsx)(m.Fc,{className:"border-red-500/50 bg-red-500/10 text-red-200",children:(0,r.jsx)(m.TN,{children:M})}),U&&(0,r.jsx)(m.Fc,{className:"border-green-500/50 bg-green-500/10 text-green-200",children:(0,r.jsx)(m.TN,{children:U})}),(0,r.jsxs)("form",{onSubmit:I,className:"space-y-6",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)(h.J,{htmlFor:"name",className:"text-white",children:"نام و نام خانوادگی"}),(0,r.jsxs)("div",{className:"relative mt-1",children:[(0,r.jsx)(o.p,{id:"name",name:"name",type:"text",required:!0,value:S.name,onChange:H,className:"bg-white/10 border-white/30 text-white placeholder:text-gray-400 pr-10",placeholder:"نام خود را وارد کنید"}),(0,r.jsx)(u.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(h.J,{htmlFor:"email",className:"text-white",children:"ایمیل"}),(0,r.jsxs)("div",{className:"relative mt-1",children:[(0,r.jsx)(o.p,{id:"email",name:"email",type:"email",required:!0,value:S.email,onChange:H,className:"bg-white/10 border-white/30 text-white placeholder:text-gray-400 pr-10",placeholder:"ایمیل خود را وارد کنید"}),(0,r.jsx)(p.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(h.J,{htmlFor:"password",className:"text-white",children:"رمز عبور"}),(0,r.jsxs)("div",{className:"relative mt-1",children:[(0,r.jsx)(c.y,{id:"password",name:"password",type:E?"text":"password",required:!0,value:S.password,onChange:H,onFocus:()=>_(!0),className:"bg-white/10 border-white/30 text-white placeholder:text-gray-400 pr-10 pl-10",placeholder:"رمز عبور امن وارد کنید"}),(0,r.jsx)(w.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),(0,r.jsx)("button",{type:"button",onClick:()=>P(!E),className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-white",children:E?(0,r.jsx)(y.A,{className:"h-4 w-4"}):(0,r.jsx)(j.A,{className:"h-4 w-4"})})]}),T&&(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)(b.u,{password:S.password})})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)(h.J,{htmlFor:"confirmPassword",className:"text-white",children:"تأیید رمز عبور"}),(0,r.jsxs)("div",{className:"relative mt-1",children:[(0,r.jsx)(c.y,{id:"confirmPassword",name:"confirmPassword",type:F?"text":"password",required:!0,value:S.confirmPassword,onChange:H,className:"bg-white/10 border-white/30 text-white placeholder:text-gray-400 pr-10 pl-10",placeholder:"رمز عبور را مجدداً وارد کنید"}),(0,r.jsx)(w.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),(0,r.jsx)("button",{type:"button",onClick:()=>O(!F),className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-white",children:F?(0,r.jsx)(y.A,{className:"h-4 w-4"}):(0,r.jsx)(j.A,{className:"h-4 w-4"})})]})]}),(0,r.jsx)(d.$,{type:"submit",disabled:q,className:"w-full bg-gradient-to-r from-purple-600 to-blue-600 hover:from-purple-700 hover:to-blue-700 text-white font-medium py-3",children:q?"در حال ثبت نام...":"ثبت نام"}),(0,r.jsxs)("div",{className:"text-center text-sm space-y-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("span",{className:"text-gray-300",children:["قبلاً حساب کاربری دارید؟"," "]}),(0,r.jsx)(n(),{href:(0,v.kk)(),className:"text-purple-400 font-medium hover:text-purple-300 hover:underline",children:"ورود"})]}),!t&&(0,r.jsx)("div",{children:(0,r.jsx)(n(),{href:"/auth/customer/signup/phone",className:"text-gray-400 hover:text-gray-300 hover:underline",children:"ثبت نام با شماره موبایل"})})]})]}),(0,r.jsx)("div",{className:"text-center mt-6",children:(0,r.jsx)(n(),{href:"/",className:"text-sm text-gray-400 hover:text-gray-300 hover:underline",children:"بازگشت به صفحه اصلی"})})]})})}},66049:(e,t,s)=>{Promise.resolve().then(s.bind(s,42284))},99550:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});let r=(0,s(71847).A)("gamepad",[["line",{x1:"6",x2:"10",y1:"12",y2:"12",key:"161bw2"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"15",x2:"15.01",y1:"13",y2:"13",key:"dqpgro"}],["line",{x1:"18",x2:"18.01",y1:"11",y2:"11",key:"meh2c"}],["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}]])}},e=>{e.O(0,[4909,7055,6489,8720,8924,4623,7358],()=>e(e.s=66049)),_N_E=e.O()}]);