32 lines
966 B
TypeScript
32 lines
966 B
TypeScript
import { Button } from "@mui/material";
|
|
import { useConfirm } from "../hooks/context_providers/ConfirmDialogProvider";
|
|
import { SolarEnergyRouteContainer } from "../widgets/SolarEnergyRouteContainer";
|
|
import { APIClient } from "../api/ApiClient";
|
|
|
|
export function ManagementRoute(): React.ReactElement {
|
|
const confirm = useConfirm();
|
|
|
|
const downloadBackup = async () => {
|
|
try {
|
|
if (
|
|
!(await confirm(
|
|
`Do you really want to download a copy of the storage? It will contain sensitive information!`
|
|
))
|
|
)
|
|
return;
|
|
|
|
location.href = APIClient.backendURL() + "/management/download_storage";
|
|
} catch (e) {
|
|
console.error(`Failed to donwload a backup of the storage! Error: ${e}`);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<SolarEnergyRouteContainer label="Management">
|
|
<Button variant="outlined" onClick={downloadBackup}>
|
|
Download a backup of storage
|
|
</Button>
|
|
</SolarEnergyRouteContainer>
|
|
);
|
|
}
|