add error message handler, add request animation

This commit is contained in:
smanylov
2026-03-04 17:16:30 +07:00
parent a11abdbb56
commit b8c439d2d7
8 changed files with 65 additions and 14 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "no-copy-frontend",
"version": "0.50.0",
"version": "0.51.0",
"private": true,
"scripts": {
"dev": "next dev -p 2999",
+31 -3
View File
@@ -619,16 +619,35 @@ export async function confirmPassword(
if (parsed.message_code === 0) {
await createSession(parsed.message_body.authToken, email as string);
} else {
throw parsed.message_body;
throw parsed;
}
} else {
throw (`${response.status}`);
}
} catch (error: unknown) {
const typedError = error as any;
const errors: Record<string, string> = {};
if (error) {
const typedError = error as any;
switch (typedError.message_code) {
case 1:
errors['server'] = 'unknown-error'
break
case 2:
if (typedError.message_desc === 'Token not found or time expired') {
errors['server'] = 'token-not-found-or-time-expired'
} else {
errors['server'] = 'unknown-error'
}
break;
default:
errors['server'] = 'request-ended-with-an-error'
break;
}
return {
previousState: {
email,
@@ -639,7 +658,16 @@ export async function confirmPassword(
error: errors
};
}
throw error;
return {
previousState: {
email,
password,
confirm_password,
verifyToken
},
error: errors
};
}
redirect('/pages/dashboard');
@@ -115,7 +115,12 @@ export default function ConfirmMailModalWindow({ userId, email, onClose }: { use
className={`${styles['btn']}`}
disabled={confirmCodeValue.length !== 6 || isPending}
>
{isPending ? t('confirming') : t('confirm')}
{t('confirm')}
{isPending && (
<div className="loading-animation">
<div className="global-spinner"></div>
</div>
)}
</button>
<button
+10 -1
View File
@@ -31,8 +31,17 @@ export default function ForgotPasswordForm() {
</p>
)}
</div>
<button type="submit" className={`${styles['btn']}`}>
<button
type="submit"
className={`${styles['btn']}`}
disabled={isPending}
>
{t('recover-password')}
{isPending && (
<div className="loading-animation">
<div className="global-spinner"></div>
</div>
)}
</button>
</form>
)
+13 -4
View File
@@ -194,13 +194,22 @@ export default function ResetPasswordForm() {
</p>
)}
</div>
{/* {state?.error.server && (
{formState?.error?.server && (
<p className={`${styles['form-error']}`}>
{t(state?.error.server)}
{t(formState?.error?.server)}
</p>
)} */}
<button type="submit" className={`${styles['btn']}`}>
)}
<button
type="submit"
className={`${styles['btn']}`}
disabled={isPending}
>
{t('change-password')}
{isPending && (
<div className="loading-animation">
<div className="global-spinner"></div>
</div>
)}
</button>
</form>
)
@@ -5,8 +5,6 @@ import { useTranslations } from 'next-intl';
export function FileInfoModalWindow({ fileInfo, setWindowClose, setWindowChildren }: any) {
const t = useTranslations('Global');
console.log(fileInfo);
return (
<div className="modal-window-view-file">
<div className="modal-window-view-file-header">
+2 -1
View File
@@ -385,6 +385,7 @@
"company-already-registered": "The company is already registered.",
"confirming" : "Confirming",
"server-error": "Server error",
"network-error": "Network error"
"network-error": "Network error",
"token-not-found-or-time-expired": "Token not found or time expired"
}
}
+2 -1
View File
@@ -385,6 +385,7 @@
"company-already-registered": "Компания уже зарегистрирована.",
"confirming": "Подтверждение",
"server-error": "Ошибка сервера",
"network-error": "Сетевая ошибка"
"network-error": "Сетевая ошибка",
"token-not-found-or-time-expired": "Токен не найден или истек срок его действия."
}
}