From 45f54058d40b69260abe03337c2757f780bc6d1b Mon Sep 17 00:00:00 2001 From: br0kenpixel <23280129+br0kenpixel@users.noreply.github.com> Date: Sun, 16 Nov 2025 16:25:40 +0100 Subject: [PATCH] refactor: move `triggerDownload` function to `utils` --- frontend/app/components/InternshipDocumentViewer.vue | 10 ---------- frontend/app/utils/index.ts | 9 +++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 frontend/app/utils/index.ts diff --git a/frontend/app/components/InternshipDocumentViewer.vue b/frontend/app/components/InternshipDocumentViewer.vue index 38a9819..d4dbb63 100644 --- a/frontend/app/components/InternshipDocumentViewer.vue +++ b/frontend/app/components/InternshipDocumentViewer.vue @@ -7,16 +7,6 @@ const props = defineProps<{ const client = useSanctumClient(); -function triggerDownload(file: Blob, file_name: string) { - const url = window.URL.createObjectURL(file); - const link = document.createElement('a'); - link.href = url; - link.download = `${file_name}.pdf`; - link.target = "_blank"; - link.click(); - window.URL.revokeObjectURL(url); -} - async function downloadAgreement() { const agreement: Blob = await client(`/api/internships/${props.internship.id}/agreement`); triggerDownload(agreement, `agreement-${props.internship.id}`); diff --git a/frontend/app/utils/index.ts b/frontend/app/utils/index.ts new file mode 100644 index 0000000..55c4517 --- /dev/null +++ b/frontend/app/utils/index.ts @@ -0,0 +1,9 @@ +export function triggerDownload(file: Blob, file_name: string) { + const url = window.URL.createObjectURL(file); + const link = document.createElement('a'); + link.href = url; + link.download = `${file_name}.pdf`; + link.target = "_blank"; + link.click(); + window.URL.revokeObjectURL(url); +} \ No newline at end of file