Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -22,7 +23,19 @@ const righteous = Righteous({
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en" className={`${inter.variable} ${righteous.variable} h-full antialiased`}>
<body className="min-h-full flex flex-col">{children}</body>
<body className="min-h-full flex flex-col">
{children}
<Toaster
position="bottom-right"
richColors
toastOptions={{
duration: 2500,
classNames: {
toast: 'rounded-xl border border-border shadow-lg',
},
}}
/>
</body>
</html>
);
}
8 changes: 4 additions & 4 deletions src/common/utils/errors/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
12 changes: 0 additions & 12 deletions src/layouts/AdminLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -58,17 +57,6 @@ export default function AdminLayout({ children }: { children: React.ReactNode })

<main className="flex-1 overflow-y-auto">{children}</main>
</div>

<Toaster
position="bottom-right"
richColors
toastOptions={{
duration: 2500,
classNames: {
toast: 'rounded-xl border border-border shadow-lg',
},
}}
/>
</div>
);
}
Loading