From ba6f54c952a3549a003481aa165d584fe6a34ac7 Mon Sep 17 00:00:00 2001 From: mai-vu Date: Thu, 23 May 2024 13:26:56 -0700 Subject: [PATCH 1/2] changed 999 to infinity for max pages --- src/app/admin-panel/home/page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/admin-panel/home/page.js b/src/app/admin-panel/home/page.js index b157f18..80312d8 100644 --- a/src/app/admin-panel/home/page.js +++ b/src/app/admin-panel/home/page.js @@ -8,7 +8,7 @@ import jobPostingService from './jobPostingService'; import { useCallback } from 'react'; import Navbar from '@/components/ui/navbar'; -const MAX_PAGES = 999; +const MAX_PAGES = Infinity; // Define your component export default function Home() { From 68cfde57cebb3b4cbf1a52c52ce7a710b155c2b0 Mon Sep 17 00:00:00 2001 From: mai-vu Date: Thu, 23 May 2024 13:27:25 -0700 Subject: [PATCH 2/2] reversedjob postings array to show most recent one first --- src/app/admin-panel/home/page.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/admin-panel/home/page.js b/src/app/admin-panel/home/page.js index 80312d8..70c126f 100644 --- a/src/app/admin-panel/home/page.js +++ b/src/app/admin-panel/home/page.js @@ -50,6 +50,7 @@ export default function Home() { let jobPostingsArray = []; while (page <= MAX_PAGES) { + // while (true) is not allowed with eslint const apiURL = `${JOB_POSTING_API_URL}?page_num=${page}&email=${user.email}`; const response = await fetch(apiURL, { method: 'GET', @@ -79,6 +80,9 @@ export default function Home() { console.error('Failed to fetch job postings:', response.statusText); break; } + + //reverse the array to show the latest job postings first + jobPostingsArray = jobPostingsArray.reverse(); } // Set the job postings array in state