diff --git a/src/client/src/api/borehole.ts b/src/client/src/api/borehole.ts index 341c4b08d..ab14bc2ed 100644 --- a/src/client/src/api/borehole.ts +++ b/src/client/src/api/borehole.ts @@ -79,3 +79,8 @@ export const importBoreholes = async (workgroupId: string, combinedFormData: any export const copyBorehole = async (boreholeId: GridRowSelectionModel, workgroupId: string | null) => { return await fetchApiV2(`borehole/copy?id=${boreholeId}&workgroupId=${workgroupId}`, "POST"); }; + +export const getAllBoreholes = async (ids: number[] | GridRowSelectionModel, pageNumber: number, pageSize: number) => { + const idsQuery = ids.map(id => `ids=${id}`).join("&"); + return await fetchApiV2(`borehole?${idsQuery}&pageNumber=${pageNumber}&pageSize=${pageSize}`, "GET"); +}; diff --git a/src/client/src/pages/detail/detailHeader.tsx b/src/client/src/pages/detail/detailHeader.tsx index d74d254e2..5f62f452d 100644 --- a/src/client/src/pages/detail/detailHeader.tsx +++ b/src/client/src/pages/detail/detailHeader.tsx @@ -85,7 +85,7 @@ const DetailHeader = ({ }; const handleExport = () => { - const jsonString = JSON.stringify(borehole, null, 2); + const jsonString = JSON.stringify([borehole], null, 2); const blob = new Blob([jsonString], { type: "application/json" }); const url = URL.createObjectURL(blob); const link = document.createElement("a"); diff --git a/src/client/src/pages/overview/boreholeTable/bottomBarContainer.tsx b/src/client/src/pages/overview/boreholeTable/bottomBarContainer.tsx index 663164872..46298fc25 100644 --- a/src/client/src/pages/overview/boreholeTable/bottomBarContainer.tsx +++ b/src/client/src/pages/overview/boreholeTable/bottomBarContainer.tsx @@ -4,7 +4,7 @@ import { useHistory } from "react-router-dom"; import { GridRowSelectionModel, GridSortDirection, GridSortModel } from "@mui/x-data-grid"; import { deleteBoreholes } from "../../../api-lib"; import { Boreholes, ReduxRootState, User } from "../../../api-lib/ReduxStateInterfaces.ts"; -import { copyBorehole } from "../../../api/borehole.ts"; +import { copyBorehole, getAllBoreholes } from "../../../api/borehole.ts"; import { OverViewContext } from "../overViewContext.tsx"; import { FilterContext } from "../sidePanelContent/filter/filterContext.tsx"; import { BoreholeTable } from "./boreholeTable.tsx"; @@ -89,8 +89,8 @@ const BottomBarContainer = ({ }; const onExportMultiple = async () => { - const exportBoreholes = boreholes.data.filter(borehole => selectionModel.includes(borehole.id)); - const jsonString = JSON.stringify(exportBoreholes, null, 2); + const paginatedResponse = await getAllBoreholes(selectionModel, 1, selectionModel.length); + const jsonString = JSON.stringify(paginatedResponse.boreholes, null, 2); const blob = new Blob([jsonString], { type: "application/json" }); const url = URL.createObjectURL(blob); const link = document.createElement("a");