fix: errorMessage has to throw apperror code if apperror
This commit is contained in:
@@ -6,6 +6,7 @@ import { authService } from "@/lib/services/auth.service";
|
||||
import { AppErrorType } from "@/types/global";
|
||||
import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { AppError } from "@/utils/errors";
|
||||
|
||||
interface LoginFormProps {
|
||||
from?: string;
|
||||
@@ -89,7 +90,7 @@ export function LoginForm({ from }: LoginFormProps) {
|
||||
{t("login.form.remember")}
|
||||
</label>
|
||||
</div>
|
||||
{error && <ErrorMessage errorCode={error.code} variant="form" />}
|
||||
{error && error instanceof AppError && <ErrorMessage errorCode={error.code} variant="form" />}
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isLoading}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
||||
import { useTranslate } from "@/hooks/useTranslate";
|
||||
import { getErrorMessage } from "@/utils/errors";
|
||||
import { AppError } from "@/utils/errors";
|
||||
|
||||
interface RegisterFormProps {
|
||||
from?: string;
|
||||
@@ -100,7 +101,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 errorCode={error.code} variant="form" />}
|
||||
{error && error instanceof AppError && <ErrorMessage errorCode={error.code} variant="form" />}
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isLoading}
|
||||
|
||||
@@ -43,7 +43,7 @@ export const ErrorMessage = ({ errorCode, error, variant = "default" }: ErrorMes
|
||||
|
||||
<div className="flex-1">
|
||||
<h3 className="mb-1 font-medium text-destructive dark:text-red-400">
|
||||
Une erreur est survenue
|
||||
{t("errors.GENERIC_ERROR")}
|
||||
</h3>
|
||||
<p className="text-sm text-destructive/90 dark:text-red-300/90">{message}</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user