-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into add-tvd-and-custom-ids
- Loading branch information
Showing
14 changed files
with
286 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...yComponents/bulkedit/BulkEditFormProps.ts → .../components/bulkedit/BulkEditFormProps.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { useTranslation } from "react-i18next"; | ||
import { Dialog, DialogActions, DialogContent, DialogTitle, Stack, Typography } from "@mui/material"; | ||
import { GridRowSelectionModel } from "@mui/x-data-grid"; | ||
import { exportCSVBorehole, getAllBoreholes } from "../../api/borehole.ts"; | ||
import { downloadData } from "../../utils.ts"; | ||
import { CancelButton, ExportButton } from "../buttons/buttons.tsx"; | ||
|
||
interface ExportDialogProps { | ||
isExporting: boolean; | ||
setIsExporting: React.Dispatch<React.SetStateAction<boolean>>; | ||
selectionModel: GridRowSelectionModel; | ||
fileName: string; | ||
} | ||
export const ExportDialog = ({ isExporting, setIsExporting, selectionModel, fileName }: ExportDialogProps) => { | ||
const { t } = useTranslation(); | ||
|
||
const exportJson = async () => { | ||
const paginatedResponse = await getAllBoreholes(selectionModel, 1, selectionModel.length); | ||
const jsonString = JSON.stringify(paginatedResponse.boreholes, null, 2); | ||
downloadData(jsonString, `${fileName}.json`, "application/json"); | ||
setIsExporting(false); | ||
}; | ||
|
||
const exportCsv = async () => { | ||
const csvData = await exportCSVBorehole(selectionModel.slice(0, 100)); | ||
downloadData(csvData, `${fileName}.csv`, "text/csv"); | ||
setIsExporting(false); | ||
}; | ||
|
||
return ( | ||
<Dialog open={isExporting}> | ||
<Stack sx={{ minWidth: "326px" }}> | ||
<DialogTitle> | ||
<Typography variant="h2">{t("export")}</Typography> | ||
</DialogTitle> | ||
<DialogContent> | ||
<Stack gap={1} sx={{ mt: 3 }}> | ||
<ExportButton label={"JSON"} onClick={exportJson} /> | ||
<ExportButton label={"CSV"} onClick={exportCsv} /> | ||
</Stack> | ||
</DialogContent> | ||
<DialogActions> | ||
<Stack direction="row" justifyContent="flex-end" spacing={2}> | ||
<CancelButton onClick={() => setIsExporting(false)} /> | ||
</Stack> | ||
</DialogActions> | ||
</Stack> | ||
</Dialog> | ||
); | ||
}; |
Oops, something went wrong.