diff --git a/frontend/src/app/admin/event-creator/page.tsx b/frontend/src/app/admin/event-creator/page.tsx index d5dd077e..a6c00664 100644 --- a/frontend/src/app/admin/event-creator/page.tsx +++ b/frontend/src/app/admin/event-creator/page.tsx @@ -109,6 +109,7 @@ export default function EventCreator() { getAllEventDetails() .then((result) => { if (result.success) { + console.log(result.data); const now = new Date(); const utcDateCurrent = now; @@ -128,6 +129,7 @@ export default function EventCreator() { id: item._id.toString(), })); + console.log("current: ", formattedCurrentRows); setCurrentEvents(formattedCurrentRows); const filteredPast = result.data.filter((item) => { @@ -145,6 +147,7 @@ export default function EventCreator() { id: item._id.toString(), })); + console.log("past: ", formattedPastRows); setPastEvents(formattedPastRows); setRow(formattedCurrentRows); @@ -185,9 +188,13 @@ export default function EventCreator() { const handleTogglePage = (index: number) => { if (index === 0) { + setCurrentPage(1); setRowsCurrent(currentEvents); + setTotalPages(Math.ceil(currentEvents.length / 14)); } else if (index === 1) { + setCurrentPage(1); setRowsCurrent(pastEvents); + setTotalPages(Math.ceil(pastEvents.length / 14)); } setPageToggle(index); }; @@ -202,6 +209,7 @@ export default function EventCreator() { useEffect(() => { // Update total pages when rows change setTotalPages(Math.ceil(rows.length / 14)); + console.log("rows.length: ", rows.length); }, [rows]); const handleCellClick: GridEventListener<"rowClick"> = (params) => { @@ -307,7 +315,7 @@ export default function EventCreator() { alignItems: "center", }} > - {pageToggle === 0 && ( + { - )} + } diff --git a/frontend/src/app/admin/newsletter-creator/page.tsx b/frontend/src/app/admin/newsletter-creator/page.tsx index 6fc98570..9eaa295d 100644 --- a/frontend/src/app/admin/newsletter-creator/page.tsx +++ b/frontend/src/app/admin/newsletter-creator/page.tsx @@ -141,9 +141,13 @@ export default function NewsletterCreator() { const handleTogglePage = (index: number) => { if (index === 0) { + setCurrentPage(1); setRowsCurrent(currentNewsletters); + setTotalPages(Math.ceil(currentNewsletters.length / 14)); } else if (index === 1) { + setCurrentPage(1); setRowsCurrent(archiveNewsletters); + setTotalPages(Math.ceil(archiveNewsletters.length / 14)); } setPageToggle(index); };