feat(i18n): first shoot on translated errors
This commit is contained in:
@@ -89,7 +89,7 @@ export function LoginForm({ from }: LoginFormProps) {
|
||||
{t("login.form.remember")}
|
||||
</label>
|
||||
</div>
|
||||
{error && <ErrorMessage message={error.message} variant="form" />}
|
||||
{error && <ErrorMessage errorCode={error.code} variant="form" />}
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isLoading}
|
||||
|
||||
@@ -5,7 +5,6 @@ import { useRouter } from "next/navigation";
|
||||
import { authService } from "@/lib/services/auth.service";
|
||||
import { AuthError } from "@/types/auth";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
|
||||
@@ -32,7 +31,6 @@ export function RegisterForm({ from }: RegisterFormProps) {
|
||||
if (password !== confirmPassword) {
|
||||
setError({
|
||||
code: ERROR_CODES.AUTH.PASSWORD_MISMATCH,
|
||||
message: getErrorMessage(ERROR_CODES.AUTH.PASSWORD_MISMATCH),
|
||||
});
|
||||
setIsLoading(false);
|
||||
return;
|
||||
@@ -99,7 +97,7 @@ export function RegisterForm({ from }: RegisterFormProps) {
|
||||
className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
/>
|
||||
</div>
|
||||
{error && <ErrorMessage message={error.message} variant="form" />}
|
||||
{error && <ErrorMessage errorCode={error.code} variant="form" />}
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isLoading}
|
||||
|
||||
@@ -271,7 +271,7 @@ export function ClientSettings({ initialConfig, initialTTLConfig }: ClientSettin
|
||||
{/* Messages de succès/erreur */}
|
||||
{error && (
|
||||
<div className="rounded-md bg-destructive/15 p-4">
|
||||
<p className="text-sm text-destructive">{error.message}</p>
|
||||
<p className="text-sm text-destructive">{t(`errors.${error.code}`)}</p>
|
||||
</div>
|
||||
)}
|
||||
{success && (
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
"use client";
|
||||
|
||||
import { AlertCircle } from "lucide-react";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
|
||||
interface ErrorMessageProps {
|
||||
message: string;
|
||||
errorCode: string;
|
||||
variant?: "default" | "form";
|
||||
}
|
||||
|
||||
export const ErrorMessage = ({ message, variant = "default" }: ErrorMessageProps) => {
|
||||
export const ErrorMessage = ({ errorCode, variant = "default" }: ErrorMessageProps) => {
|
||||
const { t } = useTranslate();
|
||||
const message = t(`errors.${errorCode}`);
|
||||
|
||||
if (variant === "form") {
|
||||
return (
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user