feat(i18n): translate error messages

This commit is contained in:
Amruth Pillai
2023-11-14 13:02:38 +01:00
parent 888b4db0bb
commit 2db52b7ef2
97 changed files with 10452 additions and 36506 deletions

View File

@ -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,
});
}
}
};

View File

@ -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) {

View File

@ -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,
});
}
}
};

View File

@ -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,
});
}
}
};

View File

@ -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,
});
}
}
};

View File

@ -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;

View File

@ -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,
});
}
}
};