You've already forked isop-mirror
feat: update triggerDownload function to accept file extension parameter
This commit is contained in:
@@ -15,7 +15,7 @@ async function requestDownload() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const proof = await client<Blob>(`/api/internships/${props.internship_id}/default-proof`);
|
const proof = await client<Blob>(`/api/internships/${props.internship_id}/default-proof`);
|
||||||
triggerDownload(proof, `default-proof-${props.internship_id}`);
|
triggerDownload(proof, `default-proof-${props.internship_id}`, 'pdf');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof FetchError) {
|
if (e instanceof FetchError) {
|
||||||
alert(`Nepodarilo sa vygenerovať zmluvu: ${e.statusMessage}`);
|
alert(`Nepodarilo sa vygenerovať zmluvu: ${e.statusMessage}`);
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ const client = useSanctumClient();
|
|||||||
|
|
||||||
async function downloadAgreement() {
|
async function downloadAgreement() {
|
||||||
const proof: Blob = await client(`/api/internships/${props.internship.id}/proof`);
|
const proof: Blob = await client(`/api/internships/${props.internship.id}/proof`);
|
||||||
triggerDownload(proof, `proof-${props.internship.id}`);
|
triggerDownload(proof, `proof-${props.internship.id}`, 'pdf');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadReport() {
|
async function downloadReport() {
|
||||||
const report: Blob = await client(`/api/internships/${props.internship.id}/report`);
|
const report: Blob = await client(`/api/internships/${props.internship.id}/report`);
|
||||||
triggerDownload(report, `report-${props.internship.id}`);
|
triggerDownload(report, `report-${props.internship.id}`, 'pdf');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
export function triggerDownload(file: Blob, file_name: string) {
|
export function triggerDownload(file: Blob, file_name: string, ext: string) {
|
||||||
const url = window.URL.createObjectURL(file);
|
const url = window.URL.createObjectURL(file);
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.download = `${file_name}.pdf`;
|
link.download = `${file_name}.${ext}`;
|
||||||
link.target = "_blank";
|
link.target = "_blank";
|
||||||
link.click();
|
link.click();
|
||||||
window.URL.revokeObjectURL(url);
|
window.URL.revokeObjectURL(url);
|
||||||
|
|||||||
Reference in New Issue
Block a user