(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3781],{4766:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>C});var a=t(95155),r=t(12115),l=t(20063),i=t(52619),n=t.n(i),h=t(3998),d=t(65142),o=t(55010),c=t(76444),m=t(18332),x=t(71871),p=t(23664),u=t(69141),w=t(99708),N=t(70532),j=t(57828),y=t(7420),b=t(36489),g=t(58261),f=t(76343),v=t(37861),k=t(66091),A=t(67734);function C(){let e=(0,l.useRouter)(),s=(0,A.Ps)(),t=(0,A.jA)(),[i,C]=(0,r.useState)(!0),[E,S]=(0,r.useState)({businessName:"",ownerName:"",email:"",phone:"",password:"",confirmPassword:""}),[F,M]=(0,r.useState)(!1),[P,_]=(0,r.useState)(!1),[J,O]=(0,r.useState)(!1),[q,T]=(0,r.useState)(!1),[R,W]=(0,r.useState)(""),[z,D]=(0,r.useState)("");(0,r.useEffect)(()=>{C(!1)},[s,t]),(0,r.useEffect)(()=>{i||!s||t||e.push("/auth/business/signup/phone")},[s,t,i,e]);let I=e=>{let{name:s,value:t}=e.target;S(e=>({...e,[s]:t}))},V=async s=>{if(s.preventDefault(),W(""),D(""),(()=>{if(!E.businessName.trim())return W("نام کسب‌وکار الزامی است"),!1;if(!E.ownerName.trim())return W("نام مالک الزامی است"),!1;if(!E.email.trim())return W("ایمیل الزامی است"),!1;if(!E.email.includes("@"))return W("ایمیل معتبر نیست"),!1;if(!E.phone.trim())return W("شماره تماس الزامی است"),!1;let e=(0,f.Oj)(E.password);return e.isValid?E.password===E.confirmPassword||(W("رمز عبور و تأیید آن مطابقت ندارند"),!1):(W(e.errors[0]),!1)})()){T(!0);try{let s=await fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E.ownerName,businessName:E.businessName,email:E.email,phone:E.phone,password:E.password,role:"CAFE_OWNER"})}),t=await s.json();if(!s.ok)if(400===s.status)throw Error(t.message||"اطلاعات وارد شده نامعتبر است");else if(409===s.status)throw Error("کاربری با این ایمیل قبلاً ثبت نام کرده است");else throw Error("خطای سرور. لطفاً دوباره تلاش کنید");D("ثبت نام با موفقیت انجام شد! در حال ورود..."),await (0,g.SP)(E.email,E.password,"CAFE_OWNER",b.signIn,e)}catch(e){e instanceof Error?W(e.message):W("خطای غیرمنتظره‌ای رخ داد. لطفاً دوباره تلاش کنید")}finally{T(!1)}}};return(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-emerald-900 via-teal-900 to-cyan-900 p-4",children:(0,a.jsxs)("div",{className:"max-w-md w-full space-y-8 bg-white/10 backdrop-blur-lg rounded-3xl border border-white/20 p-8 shadow-2xl",children:[(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"flex justify-center mb-4",children:(0,a.jsx)("div",{className:"p-4 rounded-2xl",style:{backgroundColor:"#ffa515"},children:(0,a.jsx)(y.W,{className:"h-12 w-auto"})})}),(0,a.jsx)("h2",{className:"text-3xl font-bold text-white mb-2",children:"ثبت نام کسب‌وکار"}),(0,a.jsx)("p",{className:"text-gray-300",children:"کافه گیمینگ خود را در پلیمو ثبت کنید"})]}),R&&(0,a.jsx)(m.Fc,{className:"border-red-500/50 bg-red-500/10 text-red-200",children:(0,a.jsx)(m.TN,{children:R})}),z&&(0,a.jsx)(m.Fc,{className:"border-green-500/50 bg-green-500/10 text-green-200",children:(0,a.jsx)(m.TN,{children:z})}),(0,a.jsxs)("form",{onSubmit:V,className:"space-y-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(c.J,{htmlFor:"businessName",className:"text-white",children:"نام کسب‌وکار"}),(0,a.jsxs)("div",{className:"relative mt-1",children:[(0,a.jsx)(d.p,{id:"businessName",name:"businessName",type:"text",required:!0,value:E.businessName,onChange:I,className:"bg-white/10 border-white/30 text-white placeholder:text-gray-400 pr-10 rounded-2xl",placeholder:"نام کافه گیمینگ خود را وارد کنید"}),(0,a.jsx)(x.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(c.J,{htmlFor:"ownerName",className:"text-white",children:"نام مالک"}),(0,a.jsxs)("div",{className:"relative mt-1",children:[(0,a.jsx)(d.p,{id:"ownerName",name:"ownerName",type:"text",required:!0,value:E.ownerName,onChange:I,className:"bg-white/10 border-white/30 text-white placeholder:text-gray-400 pr-10 rounded-2xl",placeholder:"نام و نام خانوادگی مالک"}),(0,a.jsx)(x.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(c.J,{htmlFor:"email",className:"text-white",children:"ایمیل کسب‌وکار"}),(0,a.jsxs)("div",{className:"relative mt-1",children:[(0,a.jsx)(d.p,{id:"email",name:"email",type:"email",required:!0,value:E.email,onChange:I,className:"bg-white/10 border-white/30 text-white placeholder:text-gray-400 pr-10 rounded-2xl",placeholder:"ایمیل کسب‌وکار خود را وارد کنید"}),(0,a.jsx)(p.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(c.J,{htmlFor:"phone",className:"text-white",children:"شماره تماس"}),(0,a.jsxs)("div",{className:"relative mt-1",children:[(0,a.jsx)(d.p,{id:"phone",name:"phone",type:"tel",required:!0,value:E.phone,onChange:I,className:"bg-white/10 border-white/30 text-white placeholder:text-gray-400 pr-10",placeholder:"شماره تماس کسب‌وکار"}),(0,a.jsx)(u.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(c.J,{htmlFor:"password",className:"text-white",children:"رمز عبور"}),(0,a.jsxs)("div",{className:"relative mt-1",children:[(0,a.jsx)(o.y,{id:"password",name:"password",type:F?"text":"password",required:!0,value:E.password,onChange:I,onFocus:()=>O(!0),className:"bg-white/10 border-white/30 text-white placeholder:text-gray-400 pr-10 pl-10 rounded-2xl",placeholder:"رمز عبور امن وارد کنید"}),(0,a.jsx)(w.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),(0,a.jsx)("button",{type:"button",onClick:()=>M(!F),className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-white",children:F?(0,a.jsx)(N.A,{className:"h-4 w-4"}):(0,a.jsx)(j.A,{className:"h-4 w-4"})})]}),J&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(v.u,{password:E.password})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(c.J,{htmlFor:"confirmPassword",className:"text-white",children:"تأیید رمز عبور"}),(0,a.jsxs)("div",{className:"relative mt-1",children:[(0,a.jsx)(o.y,{id:"confirmPassword",name:"confirmPassword",type:P?"text":"password",required:!0,value:E.confirmPassword,onChange:I,className:"bg-white/10 border-white/30 text-white placeholder:text-gray-400 pr-10 pl-10",placeholder:"رمز عبور را مجدداً وارد کنید"}),(0,a.jsx)(w.A,{className:"absolute right-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),(0,a.jsx)("button",{type:"button",onClick:()=>_(!P),className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-white",children:P?(0,a.jsx)(N.A,{className:"h-4 w-4"}):(0,a.jsx)(j.A,{className:"h-4 w-4"})})]})]}),(0,a.jsx)(h.$,{type:"submit",disabled:q,className:"w-full bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-700 hover:to-teal-700 text-white font-medium py-3 rounded-2xl shadow-lg transition-all",children:q?"در حال ثبت نام...":"ثبت نام کسب‌وکار"}),(0,a.jsxs)("div",{className:"text-center text-sm space-y-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("span",{className:"text-gray-300",children:["قبلاً ثبت نام کرده‌اید؟"," "]}),(0,a.jsx)(n(),{href:(0,k.aC)(),className:"text-emerald-400 font-medium hover:text-emerald-300 hover:underline",children:"ورود کسب‌وکار"})]}),!s&&(0,a.jsx)("div",{children:(0,a.jsx)(n(),{href:"/auth/business/signup/phone",className:"text-gray-400 hover:text-gray-300 hover:underline",children:"ثبت نام با شماره موبایل"})})]})]}),(0,a.jsx)("div",{className:"text-center mt-6",children:(0,a.jsx)(n(),{href:"/",className:"text-sm text-gray-400 hover:text-gray-300 hover:underline",children:"بازگشت به صفحه اصلی"})})]})})}},69141:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(71847).A)("phone",[["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]])},69479:(e,s,t)=>{Promise.resolve().then(t.bind(t,4766))},71871:(e,s,t)=>{"use strict";t.d(s,{A:()=>a});let a=(0,t(71847).A)("building",[["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3",key:"cabbwy"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2",key:"1uxh74"}]])}},e=>{e.O(0,[7620,8501,6489,8720,3003,4623,7358],()=>e(e.s=69479)),_N_E=e.O()}]);