field added

This commit is contained in:
brkcvn 2023-11-15 15:37:27 +03:00
parent 9263d1063c
commit 6492c4483e
2 changed files with 114 additions and 94 deletions

View File

@ -18,8 +18,10 @@ export default function RegisterPage() {
input: { input: {
email: data.get('email') as string, email: data.get('email') as string,
password: data.get('password') as string, password: data.get('password') as string,
}, firstName: data.get('firstname') as string,
}, lastName: data.get('lastname') as string
}
}
}); });
if (res.body.data.customerCreate.customer) { if (res.body.data.customerCreate.customer) {
@ -28,22 +30,17 @@ export default function RegisterPage() {
input: { input: {
email: data.get('email') as string, email: data.get('email') as string,
password: data.get('password') as string, password: data.get('password') as string,
}, }
}, }
}); });
if ( if (loginRes.body.data.customerAccessTokenCreate.customerAccessToken?.accessToken) {
loginRes.body.data.customerAccessTokenCreate.customerAccessToken
?.accessToken
) {
cookies().set({ cookies().set({
name: 'customerAccessToken', name: 'customerAccessToken',
value: value: loginRes.body.data.customerAccessTokenCreate.customerAccessToken.accessToken,
loginRes.body.data.customerAccessTokenCreate.customerAccessToken
.accessToken,
httpOnly: true, httpOnly: true,
path: '/', path: '/',
expires: new Date(Date.now() + 20 * 60 * 1000 + 5 * 1000), expires: new Date(Date.now() + 20 * 60 * 1000 + 5 * 1000)
}); });
redirect('/account'); redirect('/account');
} }
@ -68,11 +65,34 @@ export default function RegisterPage() {
return ( return (
<AuthLayout> <AuthLayout>
<FormHeader title="Create an Account" /> <FormHeader title="Create an Account" />
<form <form action={handleSubmit} noValidate className="mb-4 mt-4 space-y-3 pb-8 pt-6">
action={handleSubmit} <div>
noValidate <input
className="pt-6 pb-8 mt-4 mb-4 space-y-3" className={`mb-1`}
> id="firstname"
name="firstname"
type="text"
required
placeholder="First Name"
aria-label="First Name"
autoFocus
/>
</div>
<div>
<input
className={`mb-1`}
id="lastname"
name="lastname"
type="text"
autoComplete="email"
required
placeholder="Last Name"
aria-label="Last Name"
autoFocus
/>
</div>
<div> <div>
<input <input
className={`mb-1`} className={`mb-1`}
@ -85,9 +105,7 @@ export default function RegisterPage() {
aria-label="Email address" aria-label="Email address"
autoFocus autoFocus
/> />
{emailError && ( {emailError && <p className="text-xs text-red-500">{emailError} &nbsp;</p>}
<p className="text-red-500 text-xs">{emailError} &nbsp;</p>
)}
</div> </div>
<div> <div>
<input <input
@ -102,9 +120,7 @@ export default function RegisterPage() {
required required
autoFocus autoFocus
/> />
{passwordError && ( {passwordError && <p className="text-xs text-red-500"> {passwordError} &nbsp;</p>}
<p className="text-red-500 text-xs"> {passwordError} &nbsp;</p>
)}
</div> </div>
<FormButton btnText="Create Account" /> <FormButton btnText="Create Account" />
<FormFooter page="register" /> <FormFooter page="register" />

View File

@ -301,6 +301,8 @@ export async function createCustomer({
input: { input: {
email: string; email: string;
password: string; password: string;
firstName: string;
lastName: string;
}; };
}; };
}) { }) {
@ -312,6 +314,8 @@ export async function createCustomer({
input: { input: {
email: string; email: string;
password: string; password: string;
firstName: string;
lastName: string;
}; };
}; };
}>({ }>({