Files
Shifted/.next/static/chunks/app/auth/page-4bd6d1b6acb62808.js
2026-02-10 01:14:19 +00:00

1 line
2.8 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[235],{5701:function(e,a,t){Promise.resolve().then(t.bind(t,1176))},1176:function(e,a,t){"use strict";t.r(a),t.d(a,{default:function(){return l}});var n=t(7437),s=t(2265),i=t(605);function l(){let[e,a]=(0,s.useState)(""),[t,l]=(0,s.useState)(""),[r,c]=(0,s.useState)(""),[u,o]=(0,s.useState)(!1),[d,h]=(0,s.useState)(""),[p,g]=(0,s.useState)(""),[m,f]=(0,s.useState)(""),[j,v]=(0,s.useState)("storeshifted"),[x,S]=(0,s.useState)(""),[N,b]=(0,s.useState)(!1);async function y(a){a.preventDefault(),o(!0),c("");let n=await (0,i.signIn)("credentials",{email:e,password:t,redirect:!0,callbackUrl:"/connect"});(null==n?void 0:n.error)&&c("Invalid credentials."),o(!1)}async function w(e){e.preventDefault(),b(!0),S("");try{let e=await fetch("/api/auth/signup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d,email:p,password:m,slug:j})}),a=await e.json();if(!e.ok)throw Error(a.error||"Sign up failed");await (0,i.signIn)("credentials",{email:p,password:m,redirect:!0,callbackUrl:"/connect"})}catch(e){S(e.message||"Sign up failed.")}finally{b(!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 auth-page__inner--wide",children:[(0,n.jsx)("h1",{className:"page-title",children:"Sign In / Sign Up"}),(0,n.jsxs)("div",{className:"auth-page__grid",children:[(0,n.jsxs)("form",{className:"auth-card",onSubmit:y,children:[(0,n.jsx)("h2",{children:"Sign In"}),(0,n.jsx)("input",{type:"email",placeholder:"Email",value:e,onChange:e=>a(e.target.value)}),(0,n.jsx)("input",{type:"password",placeholder:"Password",value:t,onChange:e=>l(e.target.value)}),(0,n.jsx)("button",{className:"btn",type:"submit",disabled:u,children:u?"Signing in...":"Sign in"}),r?(0,n.jsx)("div",{className:"connect-message",children:r}):null]}),(0,n.jsxs)("form",{className:"auth-card",onSubmit:w,children:[(0,n.jsx)("h2",{children:"Create Account"}),(0,n.jsx)("input",{type:"text",placeholder:"Name",value:d,onChange:e=>h(e.target.value)}),(0,n.jsx)("input",{type:"email",placeholder:"Email",value:p,onChange:e=>g(e.target.value)}),(0,n.jsx)("input",{type:"password",placeholder:"Password",value:m,onChange:e=>f(e.target.value)}),(0,n.jsx)("input",{type:"text",placeholder:"Store slug (e.g. storeshifted)",value:j,onChange:e=>v(e.target.value)}),(0,n.jsx)("button",{className:"btn",type:"submit",disabled:N,children:N?"Creating...":"Create account"}),x?(0,n.jsx)("div",{className:"connect-message",children:x}):null]})]}),(0,n.jsxs)("div",{className:"connect-muted",style:{marginTop:12},children:["Just shopping? ",(0,n.jsx)("a",{href:"/signup/customer",children:"Create a customer account"})]})]})})})}}},function(e){e.O(0,[605,971,117,744],function(){return e(e.s=5701)}),_N_E=e.O()}]);