diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..497474f --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +*.js +/out +/.next +/node_modules diff --git a/almeira-web-deploy.zip b/almeira-web-deploy.zip index 03b9927..4c45bfb 100644 Binary files a/almeira-web-deploy.zip and b/almeira-web-deploy.zip differ diff --git a/eslint.config.mjs b/eslint.config.mjs index 05e726d..b4b6312 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -12,6 +12,7 @@ const eslintConfig = defineConfig([ "out/**", "build/**", "next-env.d.ts", + "*.js", ]), ]); diff --git a/next.config.ts b/next.config.ts index e952bc7..83478ac 100644 --- a/next.config.ts +++ b/next.config.ts @@ -8,6 +8,7 @@ const nextConfig: NextConfig = { experimental: { serverActions: { bodySizeLimit: (process.env.SERVER_ACTIONS_BODY_SIZE_LIMIT as any) || '100mb', + allowedOrigins: ['almeiraproducciones.com', 'news.almeira.com.co', 'www.almeiraproducciones.com', 'localhost:3000'], }, }, }; diff --git a/src/app/clasificados/page.tsx b/src/app/clasificados/page.tsx index 1307aad..7a3b064 100644 --- a/src/app/clasificados/page.tsx +++ b/src/app/clasificados/page.tsx @@ -58,10 +58,10 @@ async function fetchClasificadosData() { Query.equal('$id', mediaIds) ]); const mediaMap = new Map(mediaRes.documents.map(m => [m.$id, m as unknown as MediaItem])); - posts = posts.map(p => ({ + posts = posts.map(p => JSON.parse(JSON.stringify({ ...p, resolved_media: mediaMap.get(p.imagen_destacada_id as string) - })); + }))); } else { posts = JSON.parse(JSON.stringify(posts)); } @@ -78,7 +78,8 @@ export default async function ClasificadosPage() { const { posts, cardSettings } = await fetchClasificadosData(); const hasSidebar = await hasSidebarContent(); - const user = await getLoggedInUser(); + const rawUser = await getLoggedInUser(); + const user = rawUser ? JSON.parse(JSON.stringify(rawUser)) : null; const isAdmin = (user as any)?.labels?.includes('admin') || (user as any)?.labels?.includes('editor') || user?.$id === 'admin-emergency'; return ( diff --git a/src/app/dashboard/layout.tsx b/src/app/dashboard/layout.tsx index feff0c7..1bc0608 100644 --- a/src/app/dashboard/layout.tsx +++ b/src/app/dashboard/layout.tsx @@ -4,6 +4,8 @@ import { redirect } from 'next/navigation'; import { ToastProvider } from '@/components/publications/ToastProvider'; import { ErrorBoundary } from '@/components/publications/ErrorBoundary'; +export const dynamic = 'force-dynamic'; + export default async function DashboardLayout({ children, }: { diff --git a/src/app/dashboard/page.tsx b/src/app/dashboard/page.tsx index a2f94a1..ab338f0 100644 --- a/src/app/dashboard/page.tsx +++ b/src/app/dashboard/page.tsx @@ -11,7 +11,8 @@ import { import Link from 'next/link'; export default async function DashboardPage() { - const user = await getLoggedInUser(); + const rawUser = await getLoggedInUser(); + const user = rawUser ? JSON.parse(JSON.stringify(rawUser)) : null; let stats = { totalPosts: 0, totalMedia: 0, diff --git a/src/app/eventos/page.tsx b/src/app/eventos/page.tsx index 8221fc9..8b18c0e 100644 --- a/src/app/eventos/page.tsx +++ b/src/app/eventos/page.tsx @@ -58,10 +58,10 @@ async function fetchEventosData() { Query.equal('$id', mediaIds) ]); const mediaMap = new Map(mediaRes.documents.map(m => [m.$id, m as unknown as MediaItem])); - posts = posts.map(p => ({ + posts = posts.map(p => JSON.parse(JSON.stringify({ ...p, resolved_media: mediaMap.get(p.imagen_destacada_id as string) - })); + }))); } else { posts = JSON.parse(JSON.stringify(posts)); } @@ -78,7 +78,8 @@ export default async function EventosPage() { const { posts, cardSettings } = await fetchEventosData(); const hasSidebar = await hasSidebarContent(); - const user = await getLoggedInUser(); + const rawUser = await getLoggedInUser(); + const user = rawUser ? JSON.parse(JSON.stringify(rawUser)) : null; const isAdmin = (user as any)?.labels?.includes('admin') || (user as any)?.labels?.includes('editor') || user?.$id === 'admin-emergency'; return ( diff --git a/src/app/page.tsx b/src/app/page.tsx index 10a5e3c..96ebde7 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -101,7 +101,8 @@ export default async function Home(props: { searchParams: Promise<{ [key: string const page = Number(searchParams?.page) || 1; const adminMonth = searchParams?.month ? Number(searchParams.month) : null; - const user = await getLoggedInUser(); + const rawUser = await getLoggedInUser(); + const user = rawUser ? JSON.parse(JSON.stringify(rawUser)) : null; const isAdmin = (user as any)?.labels?.includes('admin') || (user as any)?.labels?.includes('editor') || user?.$id === 'admin-emergency'; const { posts, cardSettings, totalPages } = await fetchHomeData(page, isAdmin, adminMonth); diff --git a/src/components/NewsTicker.tsx b/src/components/NewsTicker.tsx index 2d80f03..8198845 100644 --- a/src/components/NewsTicker.tsx +++ b/src/components/NewsTicker.tsx @@ -1,5 +1,5 @@ import { APPWRITE_ALMEIRA_CONFIG } from '@/lib/appwrite'; -import { createSessionClient } from '@/lib/appwrite.server'; +import { createAdminClient } from '@/lib/appwrite.server'; import { Query } from 'node-appwrite'; import Link from 'next/link'; import { MessageCircle } from 'lucide-react'; @@ -11,12 +11,7 @@ export default async function NewsTicker() { let showNewsDate = true; try { - let client: any = await createSessionClient(); - if (!client) { - const { createAdminClient } = await import('@/lib/appwrite.server'); - client = await createAdminClient(); - } - + const client: any = await createAdminClient(); if (!client) throw new Error("No Appwrite client available"); // 1. Fetch Settings diff --git a/src/lib/appwrite.server.ts b/src/lib/appwrite.server.ts index f244409..f38b110 100644 --- a/src/lib/appwrite.server.ts +++ b/src/lib/appwrite.server.ts @@ -77,6 +77,10 @@ export async function getLoggedInUser() { return await sessionClient.account.get(); } catch (error: any) { + // Next.js uses a specific error to bailout of static generation. We MUST re-throw it. + if (error?.digest === 'DYNAMIC_SERVER_USAGE' || error?.message?.includes('Dynamic server usage')) { + throw error; + } if (error?.code !== 401) { console.error("getLoggedInUser: Error al validar sesión:", error.message || error); }