From ddebc0842c732123cfca986c9a3f22402d89aed6 Mon Sep 17 00:00:00 2001 From: mauriciabad Date: Sun, 22 Oct 2023 20:39:18 +0200 Subject: [PATCH] Refactor handleSubmit --- .../profile/_components/continue-with-email.tsx | 12 +++++++----- .../[locale]/register/_components/register-form.tsx | 8 ++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/app/[locale]/(app)/profile/_components/continue-with-email.tsx b/src/app/[locale]/(app)/profile/_components/continue-with-email.tsx index a5728d12..4b30763b 100644 --- a/src/app/[locale]/(app)/profile/_components/continue-with-email.tsx +++ b/src/app/[locale]/(app)/profile/_components/continue-with-email.tsx @@ -5,7 +5,7 @@ import { Input } from '@nextui-org/input' import { IconEye, IconEyeOff } from '@tabler/icons-react' import { signIn } from 'next-auth/react' import { useTranslations } from 'next-intl' -import { FC, useState } from 'react' +import { FC, FormEvent, useState } from 'react' export const ContinueWithEmail: FC<{ className?: string @@ -16,11 +16,13 @@ export const ContinueWithEmail: FC<{ const [email, setEmail] = useState('') const [password, setPassword] = useState('') + const handleSubmit = async (e: FormEvent) => { + e.preventDefault() + await signIn('credentials', { email, password }) + } + return ( -
signIn('credentials', { email, password })} - className={className} - > + ) => { + const handleSubmit = async (e: FormEvent) => { e.preventDefault() - register.mutate({ email, password, name }) + await register.mutateAsync({ email, password, name }) - signIn('credentials', { + await signIn('credentials', { email, password, name,