This commit is contained in:
root
2026-05-25 15:54:56 -04:00
parent 988d04c0a6
commit 4dde38004f
3 changed files with 11 additions and 7 deletions
+2 -1
View File
@@ -60,7 +60,8 @@ export async function fetchInvoicePdfBlob(invoiceId: string | number): Promise<B
const text = await res.text().catch(() => '') const text = await res.text().catch(() => '')
throw new Error(text || `PDF HTTP ${res.status}`) 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 { export function openPdfBlobInNewTab(blob: Blob): void {
+2 -1
View File
@@ -359,7 +359,8 @@ export async function downloadFinancialSummaryPdf(params: { school_year?: string
if (token) headers.set('Authorization', `Bearer ${token}`) if (token) headers.set('Authorization', `Bearer ${token}`)
const res = await fetch(apiUrl(path), { headers }) const res = await fetch(apiUrl(path), { headers })
if (!res.ok) throw new ApiHttpError(`HTTP ${res.status}`, res.status, null) 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 url = URL.createObjectURL(blob)
const a = document.createElement('a') const a = document.createElement('a')
a.href = url a.href = url
+7 -5
View File
@@ -53,7 +53,8 @@ export async function postStickerGenerate(formData: FormData): Promise<Blob> {
: '' : ''
throw new ApiHttpError(msg || `HTTP ${res.status}`, res.status, errBody) 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<Blob> { export async function postBadgeGenerate(formData: FormData): Promise<Blob> {
@@ -73,7 +74,8 @@ export async function postBadgeGenerate(formData: FormData): Promise<Blob> {
: '' : ''
throw new ApiHttpError(msg || `HTTP ${res.status}`, res.status, errBody) 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 = { export type StickerPreviewCounts = {
@@ -271,7 +273,7 @@ export async function openReportCardDownload(url: string): Promise<void> {
if (token) headers.set('Authorization', `Bearer ${token}`) if (token) headers.set('Authorization', `Bearer ${token}`)
const res = await fetch(url, { headers }) const res = await fetch(url, { headers })
if (!res.ok) throw new ApiHttpError(`HTTP ${res.status}`, res.status, null) if (!res.ok) throw new ApiHttpError(`HTTP ${res.status}`, res.status, null)
const blob = await res.blob() const raw = await res.blob()
const r = URL.createObjectURL(blob) const blob = new Blob([await raw.arrayBuffer()], { type: 'application/pdf' })
window.open(r, '_blank', 'noopener') window.open(URL.createObjectURL(blob), '_blank', 'noopener')
} }