From 08c5cdbe18f77ea0c84e1be6a9966a27d4e6af98 Mon Sep 17 00:00:00 2001 From: "Carlos (Almeira)" Date: Sun, 21 Jun 2026 14:43:11 -0500 Subject: [PATCH] feat: Allow all users to see and use month filter on the news feed --- src/app/page.tsx | 73 ++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 42f5423..d7a0726 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -53,19 +53,20 @@ async function fetchHomeData(page: number = 1, isAdmin: boolean = false, adminMo if (isAdmin) { queries.push(Query.equal('estado', ['Publicado', 'borrador'])); - if (adminMonth) { - const currentYear = new Date().getFullYear(); - // First day of the selected month - const startDate = new Date(currentYear, adminMonth - 1, 1).toISOString(); - // First day of the next month - const endDate = new Date(currentYear, adminMonth, 1).toISOString(); - queries.push(Query.greaterThanEqual('fecha_publicacion', startDate)); - queries.push(Query.lessThan('fecha_publicacion', endDate)); - } } else { queries.push(Query.equal('estado', 'Publicado')); } + if (adminMonth) { + const currentYear = new Date().getFullYear(); + // First day of the selected month + const startDate = new Date(currentYear, adminMonth - 1, 1).toISOString(); + // First day of the next month + const endDate = new Date(currentYear, adminMonth, 1).toISOString(); + queries.push(Query.greaterThanEqual('fecha_publicacion', startDate)); + queries.push(Query.lessThan('fecha_publicacion', endDate)); + } + const postsRes = await client.databases.listDocuments(APPWRITE_ALMEIRA_CONFIG.databaseId, 'posts', queries); posts = postsRes.documents as unknown as Post[]; totalPages = Math.ceil(postsRes.total / postsCount); @@ -157,34 +158,32 @@ export default async function Home(props: { searchParams: Promise<{ [key: string

Feed de Noticias

- {isAdmin && ( -
- - Filtro Admin: - - -
- )} +
+ + Mes: + + +
{posts.length === 0 ? (