@@ -151,6 +153,7 @@ const OpeningsSearchTab: React.FC = () => {
toggleSpatial={toggleSpatial}
showSpatial={showSpatial}
totalItems={(data?.perPage ?? 0) * (data?.totalPages ?? 0)}
+ setOpeningIds={setSelectedOpeningIds}
/>
)}
>
diff --git a/frontend/src/components/SilvicultureSearch/Openings/SearchScreenDataTable/index.tsx b/frontend/src/components/SilvicultureSearch/Openings/SearchScreenDataTable/index.tsx
index 50e32677..7a9c0afb 100644
--- a/frontend/src/components/SilvicultureSearch/Openings/SearchScreenDataTable/index.tsx
+++ b/frontend/src/components/SilvicultureSearch/Openings/SearchScreenDataTable/index.tsx
@@ -56,6 +56,7 @@ interface ISearchScreenDataTable {
toggleSpatial: () => void;
showSpatial: boolean;
totalItems: number;
+ setOpeningIds: (openingIds: number[]) => void;
}
interface ICellRefs {
@@ -69,7 +70,8 @@ const SearchScreenDataTable: React.FC
= ({
handleCheckboxChange,
toggleSpatial,
showSpatial,
- totalItems
+ totalItems,
+ setOpeningIds
}) => {
const {
handlePageChange,
@@ -114,10 +116,14 @@ const SearchScreenDataTable: React.FC = ({
setSelectedRows((prevSelectedRows) => {
if (prevSelectedRows.includes(openingId)) {
// If the row is already selected, remove it from the selected rows
- return prevSelectedRows.filter((id) => id !== openingId);
+ const selectedValues = prevSelectedRows.filter((id) => id !== openingId);
+ setOpeningIds(selectedValues.map(parseFloat));
+ return selectedValues;
} else {
- // If the row is not selected, add it to the selected rows
- return [...prevSelectedRows, openingId];
+ // If the row is not selected, add it to the selected rows
+ const selectedValues = [...prevSelectedRows, openingId];
+ setOpeningIds(selectedValues.map(parseFloat));
+ return selectedValues;
}
});
};
@@ -126,7 +132,7 @@ const SearchScreenDataTable: React.FC = ({
// Call the mutation to mark as viewed
markAsViewedOpening(openingId, {
onSuccess: () => {
- setOpeningDetails(openingId.toString());
+ setOpeningDetails(openingId);
},
onError: (err: any) => {
// Display error notification (UI needs to be designed for this)
@@ -183,6 +189,7 @@ const SearchScreenDataTable: React.FC = ({