1 line
1.7 KiB
JavaScript
1 line
1.7 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[592],{7463:function(e,a,t){Promise.resolve().then(t.bind(t,4331))},4331:function(e,a,t){"use strict";t.r(a),t.d(a,{default:function(){return c}});var n=t(7437),s=t(2265),i=t(605);function c(){let[e,a]=(0,s.useState)(""),[t,c]=(0,s.useState)(""),[r,l]=(0,s.useState)(""),[u,o]=(0,s.useState)(""),[d,h]=(0,s.useState)(!1);async function p(a){a.preventDefault(),h(!0),o("");try{let a=await fetch("/api/auth/signup-customer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,email:t,password:r})}),n=await a.json();if(!a.ok)throw Error(n.error||"Sign up failed");await (0,i.signIn)("credentials",{email:t,password:r,redirect:!0,callbackUrl:"/cart"})}catch(e){o(e.message||"Sign up failed.")}finally{h(!1)}}return(0,n.jsx)("main",{className:"auth-page",children:(0,n.jsx)("section",{className:"section",children:(0,n.jsxs)("div",{className:"container auth-page__inner",children:[(0,n.jsx)("h1",{className:"page-title",children:"Create Customer Account"}),(0,n.jsxs)("form",{className:"auth-card",onSubmit:p,children:[(0,n.jsx)("input",{type:"text",placeholder:"Name",value:e,onChange:e=>a(e.target.value)}),(0,n.jsx)("input",{type:"email",placeholder:"Email",value:t,onChange:e=>c(e.target.value)}),(0,n.jsx)("input",{type:"password",placeholder:"Password",value:r,onChange:e=>l(e.target.value)}),(0,n.jsx)("button",{className:"btn",type:"submit",disabled:d,children:d?"Creating...":"Create account"}),u?(0,n.jsx)("div",{className:"connect-message",children:u}):null]}),(0,n.jsxs)("div",{className:"connect-muted",children:["Already have an account? ",(0,n.jsx)("a",{href:"/login",children:"Sign in"})]})]})})})}}},function(e){e.O(0,[605,971,117,744],function(){return e(e.s=7463)}),_N_E=e.O()}]); |