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
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:
@@ -235,7 +235,9 @@ export function useMaintenanceReceiptOcr(): UseMaintenanceReceiptOcrReturn {
|
|||||||
setResult(null);
|
setResult(null);
|
||||||
|
|
||||||
const imageToProcess = croppedFile || file;
|
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);
|
setReceiptImageUrl(imageUrl);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -255,7 +257,7 @@ export function useMaintenanceReceiptOcr(): UseMaintenanceReceiptOcrReturn {
|
|||||||
console.error('Maintenance receipt OCR processing failed:', err);
|
console.error('Maintenance receipt OCR processing failed:', err);
|
||||||
const message = err.response?.data?.message || err.message || 'Failed to process maintenance receipt image';
|
const message = err.response?.data?.message || err.message || 'Failed to process maintenance receipt image';
|
||||||
setError(message);
|
setError(message);
|
||||||
URL.revokeObjectURL(imageUrl);
|
if (imageUrl) URL.revokeObjectURL(imageUrl);
|
||||||
setReceiptImageUrl(null);
|
setReceiptImageUrl(null);
|
||||||
} finally {
|
} finally {
|
||||||
setIsProcessing(false);
|
setIsProcessing(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user