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:
@@ -475,7 +475,11 @@ export async function exportRoutes(app: FastifyInstance) {
|
||||
};
|
||||
|
||||
// Set download headers
|
||||
const filename = `medassist-export-${new Date().toISOString().split("T")[0]}.json`;
|
||||
const now = new Date();
|
||||
const dateStr = now.toISOString().replace(/[-:]/g, "").replace(/T/, "-").slice(0, 13);
|
||||
const authUser = env.AUTH_ENABLED ? (request.user as unknown as AuthUser | null) : null;
|
||||
const userPart = authUser?.username ? `-${authUser.username}` : "";
|
||||
const filename = `medassist-export${userPart}-${dateStr}.json`;
|
||||
reply.header("Content-Type", "application/json");
|
||||
reply.header("Content-Disposition", `attachment; filename="${filename}"`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user