Skip to content

Commit 28099b6

Browse files
committed
chore: add export format
1 parent 35d9978 commit 28099b6

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

apps/frontend/src/routes/_auth/administration/export/index.tsx

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,45 @@
1-
import { Button } from "@quassel/ui";
1+
import { Button, Group, Radio, Stack, useForm } from "@quassel/ui";
22
import { createFileRoute } from "@tanstack/react-router";
33
import { $api } from "../../../../stores/api";
4+
import { i18n } from "../../../../stores/i18n";
5+
import { useStore } from "@nanostores/react";
6+
7+
const messages = i18n("AdministrationExportIndexRoute", {
8+
title: "Carers",
9+
formatLabel: "File format",
10+
csvLabel: "Comma-separated values (CSV)",
11+
sqlLabel: "Database export (SQL)",
12+
formAction: "Download",
13+
});
14+
15+
type FormValues = {
16+
fileType?: "csv" | "sql";
17+
studyId?: string;
18+
period?: [Date, Date];
19+
};
420

521
function AdministrationExportIndex() {
22+
const t = useStore(messages);
23+
const f = useForm<FormValues>({
24+
mode: "uncontrolled",
25+
initialValues: {},
26+
});
27+
628
const { isDownloading, downloadFile } = $api.useDownload("/export", "dump.sql");
729
return (
8-
<div>
9-
<Button loading={isDownloading} onClick={() => downloadFile()}>
10-
Download
11-
</Button>
12-
</div>
30+
<form onSubmit={f.onSubmit(() => downloadFile())}>
31+
<Stack>
32+
<Radio.Group label={t.formatLabel}>
33+
<Group>
34+
<Radio value="csv" label={t.csvLabel} />
35+
<Radio value="sql" label={t.sqlLabel} />
36+
</Group>
37+
</Radio.Group>
38+
<Button type="submit" loading={isDownloading}>
39+
{t.formAction}
40+
</Button>
41+
</Stack>
42+
</form>
1343
);
1444
}
1545

libs/ui/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import "@mantine/core/styles/Title.css";
2929
import "@mantine/core/styles/ActionIcon.css";
3030
import "@mantine/core/styles/Combobox.css";
3131
import "@mantine/core/styles/Stack.css";
32+
import "@mantine/core/styles/Radio.css";
3233

3334
import "@mantine/dates/styles.css";
3435

@@ -65,6 +66,7 @@ export {
6566
NavLink,
6667
Paper,
6768
PasswordInput,
69+
Radio,
6870
Select,
6971
type SelectProps,
7072
Stack,

0 commit comments

Comments
 (0)