From 6742f7e5c217c4a88b3272b3a72520e4d8e30bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=98=81=EC=9A=B0?= Date: Wed, 20 Dec 2023 22:25:28 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=EA=B2=80=EC=82=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/signup/step1.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pages/signup/step1.tsx b/pages/signup/step1.tsx index 91c290b..5ce1d7b 100644 --- a/pages/signup/step1.tsx +++ b/pages/signup/step1.tsx @@ -172,8 +172,20 @@ export default function SignUp() { placeholder={signUpTranslation.t('emailPlaceholder') as string} type="email" register={register('email', { - validate: (value) => { - return isValidEmail(value, `${commonTranslation.t('validEmail')}`); + validate: async (value) => { + if (isValidEmail(value, `${commonTranslation.t('validEmail')}`) !== true) { + return commonTranslation.t('validEmail') as string; + } + try { + const data = await postSignup(value); + // @ts-ignore + if (data?.error) { + throw Error; + } + return true; + } catch { + return 'This email is already registered'; + } }, })} error={errors.email as FieldError}