From 4dde38004f0482bffcac6bc93e56657f3ce64f1b Mon Sep 17 00:00:00 2001 From: root Date: Mon, 25 May 2026 15:54:56 -0400 Subject: [PATCH] fix --- src/api/invoices.ts | 3 ++- src/api/paymentManagement.ts | 3 ++- src/api/printables.ts | 12 +++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/api/invoices.ts b/src/api/invoices.ts index 4995391..af1494a 100644 --- a/src/api/invoices.ts +++ b/src/api/invoices.ts @@ -60,7 +60,8 @@ export async function fetchInvoicePdfBlob(invoiceId: string | number): Promise '') throw new Error(text || `PDF HTTP ${res.status}`) } - return res.blob() + const raw = await res.blob() + return new Blob([await raw.arrayBuffer()], { type: 'application/pdf' }) } export function openPdfBlobInNewTab(blob: Blob): void { diff --git a/src/api/paymentManagement.ts b/src/api/paymentManagement.ts index 4248739..640bb01 100644 --- a/src/api/paymentManagement.ts +++ b/src/api/paymentManagement.ts @@ -359,7 +359,8 @@ export async function downloadFinancialSummaryPdf(params: { school_year?: string if (token) headers.set('Authorization', `Bearer ${token}`) const res = await fetch(apiUrl(path), { headers }) if (!res.ok) throw new ApiHttpError(`HTTP ${res.status}`, res.status, null) - const blob = await res.blob() + const raw = await res.blob() + const blob = new Blob([await raw.arrayBuffer()], { type: 'application/pdf' }) const url = URL.createObjectURL(blob) const a = document.createElement('a') a.href = url diff --git a/src/api/printables.ts b/src/api/printables.ts index be182d6..4c211e3 100644 --- a/src/api/printables.ts +++ b/src/api/printables.ts @@ -53,7 +53,8 @@ export async function postStickerGenerate(formData: FormData): Promise { : '' throw new ApiHttpError(msg || `HTTP ${res.status}`, res.status, errBody) } - return res.blob() + const raw = await res.blob() + return new Blob([await raw.arrayBuffer()], { type: 'application/pdf' }) } export async function postBadgeGenerate(formData: FormData): Promise { @@ -73,7 +74,8 @@ export async function postBadgeGenerate(formData: FormData): Promise { : '' throw new ApiHttpError(msg || `HTTP ${res.status}`, res.status, errBody) } - return res.blob() + const raw = await res.blob() + return new Blob([await raw.arrayBuffer()], { type: 'application/pdf' }) } export type StickerPreviewCounts = { @@ -271,7 +273,7 @@ export async function openReportCardDownload(url: string): Promise { if (token) headers.set('Authorization', `Bearer ${token}`) const res = await fetch(url, { headers }) if (!res.ok) throw new ApiHttpError(`HTTP ${res.status}`, res.status, null) - const blob = await res.blob() - const r = URL.createObjectURL(blob) - window.open(r, '_blank', 'noopener') + const raw = await res.blob() + const blob = new Blob([await raw.arrayBuffer()], { type: 'application/pdf' }) + window.open(URL.createObjectURL(blob), '_blank', 'noopener') }