Add translations
This commit is contained in:
1 parent
ab6a6ad5df
commit
498a85b9f2
6 files changed
+64
-28
No files matched your search
@@ -1,8 +1,10 @@
|
||||
import Image from "next/image";
|
||||
import key from "./icons/key.svg";
|
||||
import ResetCodeForm from "@/widgets/forms/ResetCodeForm";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
const ResetCode = () => {
|
||||
const t = useTranslations("resetCode");
|
||||
return (
|
||||
<div className="h-full min-h-[800px] flex justify-center w-full ">
|
||||
<div className="flex flex-col items-center gap-6">
|
||||
@@ -12,12 +14,9 @@ const ResetCode = () => {
|
||||
|
||||
<div className="mb-2 flex flex-col items-center gap-2 text-center">
|
||||
<h2 className="text-[24px] font-bold leading-8 text-gray-900">
|
||||
Введите новый пароль
|
||||
{t("enterPassword")}
|
||||
</h2>
|
||||
<p className="leading-6 text-gray-500">
|
||||
Пароль должен содерждать минимум 8 символов, 1 заглавная буква и
|
||||
цифра
|
||||
</p>
|
||||
<p className="leading-6 text-gray-500">{t("passInfo")}</p>
|
||||
</div>
|
||||
|
||||
<ResetCodeForm />
|
||||
|
||||
@@ -14,11 +14,10 @@ import Image from "next/image";
|
||||
import eye_off from "./icons/eye-off.svg";
|
||||
import eye_on from "./icons/eye-on.svg";
|
||||
import alert from "./icons/alert-circle.svg";
|
||||
import { useTranslations } from "next-intl";
|
||||
|
||||
const ResetCodeForm = () => {
|
||||
const [passwordWarning, setPasswordWarning] = useState<string>("");
|
||||
const [passwordConfirmWarning, setPasswordConfirmWarning] =
|
||||
useState<string>("");
|
||||
const t = useTranslations("resetCode");
|
||||
const [error, setError] = useState<string>("");
|
||||
const [loader, setLoader] = useState<boolean>(false);
|
||||
const [showPasswordOne, setShowPasswordOne] = useState(false);
|
||||
@@ -28,15 +27,11 @@ const ResetCodeForm = () => {
|
||||
|
||||
const resetCodeFormScheme = z
|
||||
.object({
|
||||
new_password1: z
|
||||
.string()
|
||||
.min(8, "Пароль должен содержать минимум 8 символов"),
|
||||
new_password2: z
|
||||
.string()
|
||||
.min(8, "Пароль должен содержать минимум 8 символов"),
|
||||
new_password1: z.string().min(8, t("passInfo")),
|
||||
new_password2: z.string().min(8, t("passInfo")),
|
||||
})
|
||||
.refine((data) => data.new_password1 === data.new_password2, {
|
||||
message: "Пароли не совпадают",
|
||||
message: t("noMatch"),
|
||||
path: ["new_password2"],
|
||||
});
|
||||
type FormFields = z.infer<typeof resetCodeFormScheme>;
|
||||
@@ -81,12 +76,12 @@ const ResetCodeForm = () => {
|
||||
if (
|
||||
[500, 501, 502, 503, 504].includes(error.response?.status as number)
|
||||
) {
|
||||
setError("Ошибка на стороне сервера");
|
||||
setError(t("serverError"));
|
||||
} else if ([400, 404].includes(error.response?.status as number)) {
|
||||
setError("Слабый пароль, прошу избегайте очевидных паролей");
|
||||
setError(t("noPassword"));
|
||||
}
|
||||
} else {
|
||||
setError("Произошла непредвиденная ошибка");
|
||||
setError(t("errorOccured"));
|
||||
}
|
||||
} finally {
|
||||
setLoader(false);
|
||||
@@ -98,7 +93,7 @@ const ResetCodeForm = () => {
|
||||
<div className="flex flex-col gap-8">
|
||||
<div>
|
||||
<label className="text-[14px] leading-5 text-gray-700">
|
||||
Введите пароль
|
||||
{t("enterPass")}
|
||||
</label>
|
||||
<div
|
||||
className={`flex items-center border border-gray-300 rounded-lg shadow-sm bg-white${
|
||||
@@ -106,7 +101,7 @@ const ResetCodeForm = () => {
|
||||
}`}
|
||||
>
|
||||
<input
|
||||
placeholder="Введите новый пароль"
|
||||
placeholder={t("enterPassword")}
|
||||
className="w-full text-[16px] leading-6 text-gray-900 px-[10px] py-[14px]"
|
||||
type={showPasswordOne ? "text" : "password"}
|
||||
{...register("new_password1", { required: true })}
|
||||
@@ -128,7 +123,7 @@ const ResetCodeForm = () => {
|
||||
</div>
|
||||
<div>
|
||||
<label className="text-[14px] leading-5 text-gray-700">
|
||||
Повторите пароль
|
||||
{t("repeatPassword")}
|
||||
</label>
|
||||
<div
|
||||
className={`flex items-center border border-gray-300 rounded-lg shadow-sm bg-white${
|
||||
@@ -136,7 +131,7 @@ const ResetCodeForm = () => {
|
||||
}`}
|
||||
>
|
||||
<input
|
||||
placeholder="Повторите новый пароль"
|
||||
placeholder={t("repeatPass")}
|
||||
className="w-full text-[16px] leading-6 text-gray-900 px-[10px] py-[14px]"
|
||||
type={showPasswordTwo ? "text" : "password"}
|
||||
{...register("new_password2", { required: true })}
|
||||
@@ -165,7 +160,7 @@ const ResetCodeForm = () => {
|
||||
className="mt-8 h-[44px] w-full rounded-md shadow-sm bg-light-blue font-bold leading-6 text-white"
|
||||
type="submit"
|
||||
>
|
||||
{loader ? <Loader /> : "Сохранить"}
|
||||
{loader ? <Loader /> : t("save")}
|
||||
</button>
|
||||
</form>
|
||||
);
|
||||
|
||||
@@ -21,8 +21,8 @@ const SignInForm = ({}) => {
|
||||
const [error, setError] = React.useState<string>("");
|
||||
|
||||
const signInFormScheme = z.object({
|
||||
email: z.string().email("Неверный формат email"),
|
||||
password: z.string().min(8, "Пароль должен содержать минимум 8 символов"),
|
||||
email: z.string().email(t("emailFormat")),
|
||||
password: z.string().min(8, t("passwordMin")),
|
||||
});
|
||||
|
||||
type FormFields = z.infer<typeof signInFormScheme>;
|
||||
|
||||
Reference in new issue
Block a user