mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-17 18:21:28 +10:00
feat(i18n): translate error messages
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { t } from "@lingui/macro";
|
||||
import { Warning } from "@phosphor-icons/react";
|
||||
import { twoFactorBackupSchema } from "@reactive-resume/dto";
|
||||
import { usePasswordToggle } from "@reactive-resume/hooks";
|
||||
import {
|
||||
@ -13,13 +12,11 @@ import {
|
||||
FormMessage,
|
||||
Input,
|
||||
} from "@reactive-resume/ui";
|
||||
import { AxiosError } from "axios";
|
||||
import { useRef } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { z } from "zod";
|
||||
|
||||
import { toast } from "@/client/hooks/use-toast";
|
||||
import { useBackupOtp } from "@/client/services/auth";
|
||||
|
||||
type FormValues = z.infer<typeof twoFactorBackupSchema>;
|
||||
@ -43,17 +40,6 @@ export const BackupOtpPage = () => {
|
||||
navigate("/dashboard");
|
||||
} catch (error) {
|
||||
form.reset();
|
||||
|
||||
if (error instanceof AxiosError) {
|
||||
const message = error.response?.data.message || error.message;
|
||||
|
||||
toast({
|
||||
variant: "error",
|
||||
icon: <Warning size={16} weight="bold" />,
|
||||
title: t`An error occurred while trying to sign in to your account.`,
|
||||
description: message,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { t } from "@lingui/macro";
|
||||
import { Warning } from "@phosphor-icons/react";
|
||||
import { forgotPasswordSchema } from "@reactive-resume/dto";
|
||||
import {
|
||||
Alert,
|
||||
@ -14,12 +13,10 @@ import {
|
||||
FormMessage,
|
||||
Input,
|
||||
} from "@reactive-resume/ui";
|
||||
import { AxiosError } from "axios";
|
||||
import { useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
import { toast } from "@/client/hooks/use-toast";
|
||||
import { useForgotPassword } from "@/client/services/auth";
|
||||
|
||||
type FormValues = z.infer<typeof forgotPasswordSchema>;
|
||||
@ -34,22 +31,10 @@ export const ForgotPasswordPage = () => {
|
||||
});
|
||||
|
||||
const onSubmit = async (data: FormValues) => {
|
||||
try {
|
||||
await forgotPassword(data);
|
||||
setSubmitted(true);
|
||||
form.reset();
|
||||
} catch (error) {
|
||||
if (error instanceof AxiosError) {
|
||||
const message = error.response?.data.message || error.message;
|
||||
await forgotPassword(data);
|
||||
|
||||
toast({
|
||||
variant: "error",
|
||||
icon: <Warning size={16} weight="bold" />,
|
||||
title: t`An error occurred while trying to send your password recovery email.`,
|
||||
description: message,
|
||||
});
|
||||
}
|
||||
}
|
||||
setSubmitted(true);
|
||||
form.reset();
|
||||
};
|
||||
|
||||
if (submitted) {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { t, Trans } from "@lingui/macro";
|
||||
import { ArrowRight, Warning } from "@phosphor-icons/react";
|
||||
import { ArrowRight } from "@phosphor-icons/react";
|
||||
import { loginSchema } from "@reactive-resume/dto";
|
||||
import { usePasswordToggle } from "@reactive-resume/hooks";
|
||||
import {
|
||||
@ -14,19 +14,16 @@ import {
|
||||
FormMessage,
|
||||
Input,
|
||||
} from "@reactive-resume/ui";
|
||||
import { AxiosError } from "axios";
|
||||
import { useRef } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { Link } from "react-router-dom";
|
||||
import { z } from "zod";
|
||||
|
||||
import { useToast } from "@/client/hooks/use-toast";
|
||||
import { useLogin } from "@/client/services/auth";
|
||||
|
||||
type FormValues = z.infer<typeof loginSchema>;
|
||||
|
||||
export const LoginPage = () => {
|
||||
const { toast } = useToast();
|
||||
const { login, loading } = useLogin();
|
||||
|
||||
const formRef = useRef<HTMLFormElement>(null);
|
||||
@ -42,17 +39,6 @@ export const LoginPage = () => {
|
||||
await login(data);
|
||||
} catch (error) {
|
||||
form.reset();
|
||||
|
||||
if (error instanceof AxiosError) {
|
||||
const message = error.response?.data.message || error.message;
|
||||
|
||||
toast({
|
||||
variant: "error",
|
||||
icon: <Warning size={16} weight="bold" />,
|
||||
title: t`An error occurred while trying to sign in to your account.`,
|
||||
description: message,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { t, Trans } from "@lingui/macro";
|
||||
import { ArrowRight, Warning } from "@phosphor-icons/react";
|
||||
import { ArrowRight } from "@phosphor-icons/react";
|
||||
import { registerSchema } from "@reactive-resume/dto";
|
||||
import { usePasswordToggle } from "@reactive-resume/hooks";
|
||||
import {
|
||||
@ -14,13 +14,11 @@ import {
|
||||
FormMessage,
|
||||
Input,
|
||||
} from "@reactive-resume/ui";
|
||||
import { AxiosError } from "axios";
|
||||
import { useRef } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
import { z } from "zod";
|
||||
|
||||
import { toast } from "@/client/hooks/use-toast";
|
||||
import { useRegister } from "@/client/services/auth";
|
||||
|
||||
type FormValues = z.infer<typeof registerSchema>;
|
||||
@ -50,17 +48,6 @@ export const RegisterPage = () => {
|
||||
navigate("/auth/verify-email");
|
||||
} catch (error) {
|
||||
form.reset();
|
||||
|
||||
if (error instanceof AxiosError) {
|
||||
const message = error.response?.data.message || error.message;
|
||||
|
||||
toast({
|
||||
variant: "error",
|
||||
icon: <Warning size={16} weight="bold" />,
|
||||
title: t`An error occurred while trying to create a new account.`,
|
||||
description: message,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { t, Trans } from "@lingui/macro";
|
||||
import { Warning } from "@phosphor-icons/react";
|
||||
import { resetPasswordSchema } from "@reactive-resume/dto";
|
||||
import { usePasswordToggle } from "@reactive-resume/hooks";
|
||||
import {
|
||||
@ -14,13 +13,11 @@ import {
|
||||
FormMessage,
|
||||
Input,
|
||||
} from "@reactive-resume/ui";
|
||||
import { AxiosError } from "axios";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
||||
import { z } from "zod";
|
||||
|
||||
import { toast } from "@/client/hooks/use-toast";
|
||||
import { useResetPassword } from "@/client/services/auth";
|
||||
|
||||
type FormValues = z.infer<typeof resetPasswordSchema>;
|
||||
@ -47,17 +44,6 @@ export const ResetPasswordPage = () => {
|
||||
navigate("/auth/login");
|
||||
} catch (error) {
|
||||
form.reset();
|
||||
|
||||
if (error instanceof AxiosError) {
|
||||
const message = error.response?.data.message || error.message;
|
||||
|
||||
toast({
|
||||
variant: "error",
|
||||
icon: <Warning size={16} weight="bold" />,
|
||||
title: t`An error occurred while trying to reset your password.`,
|
||||
description: message,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { t, Trans } from "@lingui/macro";
|
||||
import { ArrowRight, Info, SealCheck, Warning } from "@phosphor-icons/react";
|
||||
import { ArrowRight, Info, SealCheck } from "@phosphor-icons/react";
|
||||
import { Alert, AlertDescription, AlertTitle, Button } from "@reactive-resume/ui";
|
||||
import { AxiosError } from "axios";
|
||||
import { useEffect } from "react";
|
||||
import { Link, useNavigate, useSearchParams } from "react-router-dom";
|
||||
|
||||
@ -19,29 +18,16 @@ export const VerifyEmailPage = () => {
|
||||
|
||||
useEffect(() => {
|
||||
const handleVerifyEmail = async (token: string) => {
|
||||
try {
|
||||
await verifyEmail({ token });
|
||||
await queryClient.invalidateQueries({ queryKey: ["user"] });
|
||||
await verifyEmail({ token });
|
||||
await queryClient.invalidateQueries({ queryKey: ["user"] });
|
||||
|
||||
toast({
|
||||
variant: "success",
|
||||
icon: <SealCheck size={16} weight="bold" />,
|
||||
title: t`Your email address has been verified successfully.`,
|
||||
});
|
||||
toast({
|
||||
variant: "success",
|
||||
icon: <SealCheck size={16} weight="bold" />,
|
||||
title: t`Your email address has been verified successfully.`,
|
||||
});
|
||||
|
||||
navigate("/dashboard/resumes", { replace: true });
|
||||
} catch (error) {
|
||||
if (error instanceof AxiosError) {
|
||||
const message = error.response?.data.message || error.message;
|
||||
|
||||
toast({
|
||||
variant: "error",
|
||||
icon: <Warning size={16} weight="bold" />,
|
||||
title: t`An error occurred while trying to verify your email address.`,
|
||||
description: message,
|
||||
});
|
||||
}
|
||||
}
|
||||
navigate("/dashboard/resumes", { replace: true });
|
||||
};
|
||||
|
||||
if (!token) return;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { t } from "@lingui/macro";
|
||||
import { ArrowRight, Warning } from "@phosphor-icons/react";
|
||||
import { ArrowRight } from "@phosphor-icons/react";
|
||||
import { twoFactorSchema } from "@reactive-resume/dto";
|
||||
import { usePasswordToggle } from "@reactive-resume/hooks";
|
||||
import {
|
||||
@ -13,13 +13,11 @@ import {
|
||||
FormMessage,
|
||||
Input,
|
||||
} from "@reactive-resume/ui";
|
||||
import { AxiosError } from "axios";
|
||||
import { useRef } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
import { z } from "zod";
|
||||
|
||||
import { toast } from "@/client/hooks/use-toast";
|
||||
import { useVerifyOtp } from "@/client/services/auth";
|
||||
|
||||
type FormValues = z.infer<typeof twoFactorSchema>;
|
||||
@ -43,17 +41,6 @@ export const VerifyOtpPage = () => {
|
||||
navigate("/dashboard");
|
||||
} catch (error) {
|
||||
form.reset();
|
||||
|
||||
if (error instanceof AxiosError) {
|
||||
const message = error.response?.data.message || error.message;
|
||||
|
||||
toast({
|
||||
variant: "error",
|
||||
icon: <Warning size={16} weight="bold" />,
|
||||
title: t`An error occurred while trying to sign in to your account.`,
|
||||
description: message,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user