@@ -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 47e74668..4e9d6de9 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,
@@ -111,14 +113,19 @@ const SearchScreenDataTable: React.FC = ({
}, [rows, totalItems]);
// Function to handle row selection changes
- const handleRowSelectionChanged = (rowId: string) => {
+
+ const handleRowSelectionChanged = (openingId: string) => {
setSelectedRows((prevSelectedRows) => {
- if (prevSelectedRows.includes(rowId)) {
+ if (prevSelectedRows.includes(openingId)) {
// If the row is already selected, remove it from the selected rows
- return prevSelectedRows.filter((id) => id !== rowId);
+ 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, rowId];
+ // If the row is not selected, add it to the selected rows
+ const selectedValues = [...prevSelectedRows, openingId];
+ setOpeningIds(selectedValues.map(parseFloat));
+ return selectedValues;
}
});
};
@@ -176,6 +183,7 @@ const SearchScreenDataTable: React.FC = ({