fix: skip image preview for PDF receipt uploads (refs #182)
All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 3m30s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 51s
Deploy to Staging / Verify Staging (pull_request) Successful in 8s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped

URL.createObjectURL on a PDF creates a blob URL that cannot render in
an img tag, showing broken image alt text. Skip preview creation for
PDF files so the review modal displays without a thumbnail.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Eric Gullickson
2026-02-13 21:43:47 -06:00
parent 220f8ea3ac
commit 7f6e4e0ec2

View File

@@ -235,7 +235,9 @@ export function useMaintenanceReceiptOcr(): UseMaintenanceReceiptOcrReturn {
setResult(null);
const imageToProcess = croppedFile || file;
const imageUrl = URL.createObjectURL(imageToProcess);
const isPdf = imageToProcess.type === 'application/pdf' ||
imageToProcess.name.toLowerCase().endsWith('.pdf');
const imageUrl = isPdf ? null : URL.createObjectURL(imageToProcess);
setReceiptImageUrl(imageUrl);
try {
@@ -255,7 +257,7 @@ export function useMaintenanceReceiptOcr(): UseMaintenanceReceiptOcrReturn {
console.error('Maintenance receipt OCR processing failed:', err);
const message = err.response?.data?.message || err.message || 'Failed to process maintenance receipt image';
setError(message);
URL.revokeObjectURL(imageUrl);
if (imageUrl) URL.revokeObjectURL(imageUrl);
setReceiptImageUrl(null);
} finally {
setIsProcessing(false);