fix: OCR API error
All checks were successful
Deploy to Staging / Build Images (push) Successful in 7m45s
Deploy to Staging / Deploy to Staging (push) Successful in 51s
Deploy to Staging / Verify Staging (push) Successful in 2m31s
Deploy to Staging / Notify Staging Ready (push) Successful in 8s
Deploy to Staging / Notify Staging Failure (push) Has been skipped

This commit is contained in:
Eric Gullickson
2026-02-06 13:01:32 -06:00
parent 88db803b6a
commit 66314a0493
6 changed files with 244 additions and 26 deletions

View File

@@ -41,13 +41,13 @@ export interface UseVinOcrReturn extends UseVinOcrState {
}
/**
* Extract VIN from image using OCR service
* Extract VIN from image using VIN-specific OCR endpoint
*/
async function extractVinFromImage(file: File): Promise<VinOcrResult> {
const formData = new FormData();
formData.append('file', file);
const response = await apiClient.post('/ocr/extract', formData, {
const response = await apiClient.post('/ocr/extract/vin', formData, {
headers: { 'Content-Type': 'multipart/form-data' },
timeout: 30000, // 30 seconds for OCR processing
});
@@ -55,19 +55,17 @@ async function extractVinFromImage(file: File): Promise<VinOcrResult> {
const data = response.data;
if (!data.success) {
throw new Error('OCR extraction failed');
throw new Error(data.error || 'VIN extraction failed');
}
// Extract VIN from the response
const vinField = data.extractedFields?.vin;
if (!vinField?.value) {
if (!data.vin) {
throw new Error('No VIN found in image. Please ensure the VIN is clearly visible.');
}
return {
vin: vinField.value.toUpperCase().replace(/[^A-HJ-NPR-Z0-9]/g, ''),
confidence: vinField.confidence,
rawText: data.rawText,
vin: data.vin.toUpperCase().replace(/[^A-HJ-NPR-Z0-9]/g, ''),
confidence: data.confidence,
rawText: data.vin,
};
}