From 7288ea834e5b248bd30d4e7c12af76eadf9116ff Mon Sep 17 00:00:00 2001 From: nzambello Date: Fri, 23 Jun 2023 12:33:32 +0200 Subject: [PATCH] feat: add timestamp in csv export filename --- app/routes/importexport/export[.]csv.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/routes/importexport/export[.]csv.tsx b/app/routes/importexport/export[.]csv.tsx index f98cb0d..94819c5 100644 --- a/app/routes/importexport/export[.]csv.tsx +++ b/app/routes/importexport/export[.]csv.tsx @@ -11,11 +11,13 @@ export async function loader({ request }: LoaderArgs) { header: true }); + const timestamp = new Date().toISOString().replace(/\D/g, '').slice(0, -3); + return new Response(csv, { status: 200, headers: { 'Content-Type': 'text/csv', - 'Content-Disposition': 'attachment; filename="export.csv"' - } + 'Content-Disposition': `attachment; filename="work-timer-export-${timestamp}.csv"`, + }, }); }