diff --git a/frontend/src/Components/cards/HelpfulLinkCard.tsx b/frontend/src/Components/cards/HelpfulLinkCard.tsx
index cc49b703b..bee26de22 100644
--- a/frontend/src/Components/cards/HelpfulLinkCard.tsx
+++ b/frontend/src/Components/cards/HelpfulLinkCard.tsx
@@ -73,11 +73,17 @@ export default function HelpfulLinkCard({
return (
{
void handleHelpfulLinkClick(link.id);
}}
>
+
+
+
+
+
{link.title}
+
{AdminRoles.includes(role) ? (
showModal != undefined && (
@@ -98,28 +104,31 @@ export default function HelpfulLinkCard({
)
) : (
-
{
- if (e) void handleToggleAction('favorite', e);
- }}
- />
- )}
-
- {link.title}
- {link.description}
-
- {AdminRoles.includes(role) && (
- void handleToggleAction('toggle')}
- />
+ void handleToggleAction('favorite', e)}
+ >
+
+
)}
+
+
+ {link.description}
+
+ {AdminRoles.includes(role) && (
+
+ void handleToggleAction('toggle')
+ }
+ />
+ )}
+
);
}
diff --git a/frontend/src/Pages/HelpfulLinks.tsx b/frontend/src/Pages/HelpfulLinks.tsx
index f1656f7a8..8891a69dc 100644
--- a/frontend/src/Pages/HelpfulLinks.tsx
+++ b/frontend/src/Pages/HelpfulLinks.tsx
@@ -5,41 +5,68 @@ import {
UserRole
} from '@/common';
import HelpfulLinkCard from '@/Components/cards/HelpfulLinkCard';
+import Pagination from '@/Components/Pagination';
import { AxiosError } from 'axios';
+import { useState } from 'react';
import useSWR from 'swr';
export default function HelpfulLinks() {
+ const [perPage, setPerPage] = useState(20);
+ const [pageQuery, setPageQuery] = useState(1);
const {
data: helpfulLinks,
mutate: mutateHelpfulFavs,
isLoading,
error
} = useSWR, AxiosError>(
- `/api/helpful-links`
+ `/api/helpful-links?page=${pageQuery}&per_page=${perPage}`
);
function updateFavorites() {
void mutateHelpfulFavs();
}
+ const handleSetPerPage = (perPage: number) => {
+ setPerPage(perPage);
+ setPageQuery(1);
+ updateFavorites();
+ };
+ const helpfulLinksMeta = helpfulLinks?.data?.meta ?? {
+ total: 0,
+ per_page: 20,
+ page: 1,
+ current_page: 1,
+ last_page: 1
+ };
return (
-
- {helpfulLinks?.data?.helpful_links.map((link: HelpfulLink) => (
-
- ))}
- {error && (
-
- Failed to load helpful links.
-
- )}
- {!isLoading &&
- !error &&
- helpfulLinks?.data.helpful_links.length === 0 && (
-
No results
+ <>
+
+ {helpfulLinks?.data?.helpful_links.map((link: HelpfulLink) => (
+
+ ))}
+ {error && (
+
+ Failed to load helpful links.
+
)}
-
+ {!isLoading &&
+ !error &&
+ helpfulLinks?.data.helpful_links.length === 0 && (
+
No results
+ )}
+
+ {!isLoading && !error && helpfulLinksMeta && (
+
+ )}
+ >
);
}