fix: improve export filename and import confirmation UX (#232)

Export filename:
- Include username for multi-user/instance distinction
- Include timestamp with time (YYYYMMDD-HHMM) instead of date only
- Example: medassist-export-daniel-20260216-2108.json

Import confirmation:
- Show friendly 'Import Data?' dialog on empty instances instead of
  scary 'Replace All Data?' warning with danger button
- Only show destructive warning when there is existing data to replace
- Use primary button style for empty-state import

Closes #231
This commit is contained in:
Daniel Volz
2026-02-16 22:20:20 +01:00
committed by GitHub
parent e41efdf98b
commit 08a18fc14a
6 changed files with 30 additions and 10 deletions
+4 -2
View File
@@ -522,9 +522,11 @@ export function AppProvider({ children }: { children: React.ReactNode }) {
const blob = new Blob([JSON.stringify(data, null, 2)], { type: "application/json" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
const dateStr = new Date().toISOString().split("T")[0];
const now = new Date();
const dateStr = now.toISOString().replace(/[-:]/g, "").replace(/T/, "-").slice(0, 13);
const userPart = user?.username ? `-${user.username}` : "";
a.href = url;
a.download = `${t("exportImport.downloadFilename")}-${dateStr}.json`;
a.download = `${t("exportImport.downloadFilename")}${userPart}-${dateStr}.json`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);