diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 45b0c39..1871dc0 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,6 +1,7 @@ import type { Metadata } from 'next'; import { Inter, Righteous } from 'next/font/google'; import '../styles/globals.css'; +import { Toaster } from 'sonner'; export const metadata: Metadata = { icons: { @@ -22,7 +23,19 @@ const righteous = Righteous({ export default function RootLayout({ children }: { children: React.ReactNode }) { return ( - {children} + + {children} + + ); } diff --git a/src/common/utils/errors/auth.ts b/src/common/utils/errors/auth.ts index d007c20..2439421 100644 --- a/src/common/utils/errors/auth.ts +++ b/src/common/utils/errors/auth.ts @@ -2,16 +2,16 @@ import { HttpError } from '@/services/base'; const MESSAGES = { INVALID_CREDENTIALS: 'Email o contraseña incorrectos', + ACCESS_DENIED: 'Acceso denegado', NETWORK: 'Error de red, intente nuevamente', GENERIC: 'Ocurrió un error inesperado, intente nuevamente', } as const; -const UNAUTHORIZED_STATUSES = new Set([401, 403]); - export function getAuthErrorMessage(error: unknown): string { if (error instanceof TypeError) return MESSAGES.NETWORK; - if (error instanceof HttpError && UNAUTHORIZED_STATUSES.has(error.status)) { - return MESSAGES.INVALID_CREDENTIALS; + if (error instanceof HttpError) { + if (error.status === 401) return MESSAGES.INVALID_CREDENTIALS; + if (error.status === 403) return MESSAGES.ACCESS_DENIED; } return MESSAGES.GENERIC; } diff --git a/src/layouts/AdminLayout.tsx b/src/layouts/AdminLayout.tsx index c684462..2ab365a 100644 --- a/src/layouts/AdminLayout.tsx +++ b/src/layouts/AdminLayout.tsx @@ -2,7 +2,6 @@ import React, { useState } from 'react'; import { usePathname, useRouter } from 'next/navigation'; -import { Toaster } from 'sonner'; import { useTheme } from '@/common/hooks/useTheme'; import { useAuthGuard } from '@/common/hooks/useAuthGuard'; import { useCurrentAdmin } from '@/common/hooks/useCurrentAdmin'; @@ -58,17 +57,6 @@ export default function AdminLayout({ children }: { children: React.ReactNode })
{children}
- - ); }