@@ -197,6 +197,11 @@ const Account: NextPageWithLayout = () => { [name, lastName, userName] ) + const isRequiredInputEmpty = useMemo( + () => name !== '' || lastName !== '' || userName !== '', + [name, lastName, userName] + ) + const promocodeActivate = async () => { if (!promocode.trim()) { showError('Введите корректный промокод', true) @@ -235,6 +240,11 @@ const Account: NextPageWithLayout = () => { return } + if (isRequiredInputEmpty) { + showError('Заполните обязательные поля', true) + return + } + try { await axios.put( API_URL + '/auth/user-data', @@ -249,7 +259,9 @@ const Account: NextPageWithLayout = () => { showError('Данные успешно изменены!') dispatch(getAllInfo(data?.access)) - } catch (e) {} + } catch (e) { + showError(`Ошибка: ${e}`, true) + } } const deleteAccount = async () => { @@ -382,7 +394,7 @@ const Account: NextPageWithLayout = () => { Имя setName(e.target.value)} fullWidth @@ -391,7 +403,7 @@ const Account: NextPageWithLayout = () => { Фамилия setLastName(e.target.value)} fullWidth @@ -434,7 +446,7 @@ const Account: NextPageWithLayout = () => { Никнейм setUserName(e.target.value)} fullWidth