implement character backup

This commit is contained in:
Calli
2023-06-23 19:58:41 +03:00
parent 4be45c0951
commit 5146e0e4ff
3 changed files with 20 additions and 0 deletions

View File

@@ -13,6 +13,7 @@ Features:
- Track extractor status - Track extractor status
- When the cycle will end - When the cycle will end
- Highlight the planet if extractor has stopped or has not been started. - Highlight the planet if extractor has stopped or has not been started.
- Backup to download characters to a file (restore not implemented yet)
## Security ## Security

View File

@@ -0,0 +1,17 @@
import { CharacterContext } from "@/app/context/Context";
import { Button } from "@mui/material";
import { useContext } from "react";
export const DowloadButton = () => {
const { characters } = useContext(CharacterContext);
return (
<Button
href={`data:text/json;charset=utf-8,${encodeURIComponent(
JSON.stringify(characters)
)}`}
download="pi-avanto-tk-characters.json"
>
Backup
</Button>
);
};

View File

@@ -4,6 +4,7 @@ import { LoginButton } from "./Login/LoginButton";
import { AccountCard } from "./Account/AccountCard"; import { AccountCard } from "./Account/AccountCard";
import { AccessToken } from "@/types"; import { AccessToken } from "@/types";
import { CharacterContext } from "../context/Context"; import { CharacterContext } from "../context/Context";
import { DowloadButton } from "./Backup/DowloadButton";
interface Grouped { interface Grouped {
[key: string]: AccessToken[]; [key: string]: AccessToken[];
@@ -24,6 +25,7 @@ export const MainGrid = ({ sessionReady }: { sessionReady: boolean }) => {
<Grid item xs={2}> <Grid item xs={2}>
<Stack direction="row" spacing={1}> <Stack direction="row" spacing={1}>
<LoginButton /> <LoginButton />
<DowloadButton />
</Stack> </Stack>
</Grid> </Grid>
</Grid> </Grid>