diff --git a/client/src/pages/NotesPage.jsx b/client/src/pages/NotesPage.jsx index f77c940..5bf666f 100644 --- a/client/src/pages/NotesPage.jsx +++ b/client/src/pages/NotesPage.jsx @@ -115,7 +115,13 @@ const NotesPage = () => { throw new Error(errorData.error || "Failed to fetch notes"); } - const data = await res.json(); + let data = await res.json(); + + // extract isLastPage and assign notes to data + const isLastPage = data?.isLastPage; + if (isLastPage) setHasMore(!isLastPage); + data = data?.notes; + if (!Array.isArray(data)) { throw new Error("Invalid response format"); } @@ -160,20 +166,13 @@ const NotesPage = () => { }; const renderNotesContent = () => { if (loading) { - return ( - - - - - ); + return ; } if (error) { return ( -

{error}

-
); } @@ -182,7 +181,6 @@ const NotesPage = () => { return ( <>
- {notes.map((note) => ( { handleViewPDF={handleViewPDF} /> ))} -
{/* Pagination Controls */} @@ -201,18 +198,15 @@ const NotesPage = () => { - Page {page + 1} @@ -223,7 +217,6 @@ const NotesPage = () => { className={`px-4 py-2 rounded-md transition-colors ${ !hasMore ? "bg-gray-300 dark:bg-gray-600 text-gray-500 cursor-not-allowed" - : "bg-blue-600 hover:bg-blue-700 text-white" }`} > @@ -235,7 +228,6 @@ const NotesPage = () => { } return ( -

@@ -296,13 +288,11 @@ const NotesPage = () => { return (
-

Please login to view notes

- You need to be logged in to access academic notes and study materials.

@@ -336,15 +326,12 @@ const NotesPage = () => {
{ {/* Subject Filter */}