You've already forked isop-mirror
refactor: move triggerDownload function to utils
This commit is contained in:
@@ -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}`);
|
||||
|
||||
9
frontend/app/utils/index.ts
Normal file
9
frontend/app/utils/index.ts
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user