From 79b82d317b425a99741ed16f9b8b62dd42e9912d Mon Sep 17 00:00:00 2001 From: Sergey Yarkov Date: Mon, 13 Sep 2021 18:36:48 +0300 Subject: [PATCH] feat: added 422 handle error on update email --- src/hooks/useUpdateUserEmailQuery.ts.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hooks/useUpdateUserEmailQuery.ts.ts b/src/hooks/useUpdateUserEmailQuery.ts.ts index 1c5de0a..31fa535 100644 --- a/src/hooks/useUpdateUserEmailQuery.ts.ts +++ b/src/hooks/useUpdateUserEmailQuery.ts.ts @@ -41,7 +41,8 @@ const useUpdateUserEmailQuery = () => { } if (error.response) { - if (error.response.status === 503) { + const status = error.response.status; + if (status === 503) { switch (error.response.data.code) { case 'E_CONFIRM_CODE_EXIST': toast({ title: 'Please, try send code later.', status: 'info' }); @@ -50,6 +51,8 @@ const useUpdateUserEmailQuery = () => { toast({ title: `Unable to send confirmation code, try again later.`, status: 'error' }); break; } + } else if (status === 422) { + toast({ title: error.response.data.errors[0].message, status: 'error' }); } else { handleError(error); }