feat: implement plant health scanning functionality with backend integration and UI support
This commit is contained in:
@@ -14,7 +14,7 @@ import { useColors } from '../constants/Colors';
|
||||
import { PlantRecognitionService } from '../services/plantRecognitionService';
|
||||
import { IdentificationResult } from '../types';
|
||||
import { ResultCard } from '../components/ResultCard';
|
||||
import { backendApiClient, isInsufficientCreditsError, isNetworkError } from '../services/backend/backendApiClient';
|
||||
import { backendApiClient, isInsufficientCreditsError, isNetworkError, isTimeoutError } from '../services/backend/backendApiClient';
|
||||
import { isBackendApiError } from '../services/backend/contracts';
|
||||
import { createIdempotencyKey } from '../utils/idempotency';
|
||||
|
||||
@@ -33,6 +33,8 @@ const getBillingCopy = (language: 'de' | 'en' | 'es') => {
|
||||
genericErrorMessage: 'Analyse fehlgeschlagen.',
|
||||
noConnectionTitle: 'Keine Verbindung',
|
||||
noConnectionMessage: 'Keine Verbindung zum Server. Bitte prüfe deine Internetverbindung und versuche es erneut.',
|
||||
timeoutTitle: 'Scan zu langsam',
|
||||
timeoutMessage: 'Die Analyse hat zu lange gedauert. Bitte erneut versuchen.',
|
||||
retryLabel: 'Erneut versuchen',
|
||||
providerErrorMessage: 'KI-Scan gerade nicht verfügbar. Bitte versuche es erneut.',
|
||||
healthProviderErrorMessage: 'KI-Health-Check gerade nicht verfügbar. Bitte versuche es erneut.',
|
||||
@@ -55,6 +57,8 @@ const getBillingCopy = (language: 'de' | 'en' | 'es') => {
|
||||
genericErrorMessage: 'Analisis fallido.',
|
||||
noConnectionTitle: 'Sin conexión',
|
||||
noConnectionMessage: 'Sin conexión al servidor. Comprueba tu internet e inténtalo de nuevo.',
|
||||
timeoutTitle: 'Escaneo lento',
|
||||
timeoutMessage: 'El análisis tardó demasiado. Inténtalo de nuevo.',
|
||||
retryLabel: 'Reintentar',
|
||||
providerErrorMessage: 'Escaneo IA no disponible ahora. Inténtalo de nuevo.',
|
||||
healthProviderErrorMessage: 'Health-check IA no disponible ahora. Inténtalo de nuevo.',
|
||||
@@ -76,6 +80,8 @@ const getBillingCopy = (language: 'de' | 'en' | 'es') => {
|
||||
genericErrorMessage: 'Analysis failed.',
|
||||
noConnectionTitle: 'No connection',
|
||||
noConnectionMessage: 'Could not reach the server. Check your internet connection and try again.',
|
||||
timeoutTitle: 'Scan Too Slow',
|
||||
timeoutMessage: 'Analysis took too long. Please try again.',
|
||||
retryLabel: 'Try again',
|
||||
providerErrorMessage: 'AI scan is currently unavailable. Please try again.',
|
||||
healthProviderErrorMessage: 'AI health check is currently unavailable. Please try again.',
|
||||
@@ -295,6 +301,15 @@ export default function ScannerScreen() {
|
||||
},
|
||||
],
|
||||
);
|
||||
} else if (isTimeoutError(error)) {
|
||||
Alert.alert(
|
||||
billingCopy.timeoutTitle,
|
||||
billingCopy.timeoutMessage,
|
||||
[
|
||||
{ text: billingCopy.dismiss, style: 'cancel' },
|
||||
{ text: billingCopy.retryLabel, onPress: () => analyzeImage(imageUri, galleryImageUri) },
|
||||
],
|
||||
);
|
||||
} else if (isNetworkError(error)) {
|
||||
Alert.alert(
|
||||
billingCopy.noConnectionTitle,
|
||||
|
||||
Reference in New Issue
Block a user