refactor: move triggerDownload function to utils

This commit is contained in:
2025-11-16 16:25:40 +01:00
parent b8dff75422
commit 45f54058d4
2 changed files with 9 additions and 10 deletions

View File

@@ -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}`);

View File

@@ -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);
}