'use client' import { AlertTriangle, ArrowRight, RotateCcw } from 'lucide-react' interface CropMismatchBlockProps { /** Crop the user selected (lowercase, e.g. "corn"). */ selectedCrop: string /** Crop the image actually looks like (lowercase), or null if unknown. */ suggestedCrop: string | null /** Suggested crop's match strength, 0–100. */ suggestedConfidence: number | null /** Re-run the diagnosis under the suggested crop (only when one is known). */ onUseSuggested?: () => void /** Escape hatch: re-run for the originally selected crop, skipping the gate. */ onOverride?: () => void /** Clear the photo so the farmer can take another. */ onRetake: () => void } const cap = (s: string) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : s) export default function CropMismatchBlock({ selectedCrop, suggestedCrop, suggestedConfidence, onUseSuggested, onOverride, onRetake, }: CropMismatchBlockProps) { return (
{suggestedCrop ? ( <> The photo looks more like a{' '} {cap(suggestedCrop)} leaf {typeof suggestedConfidence === 'number' ? ` (${suggestedConfidence.toFixed(0)}% match)` : ''} . To avoid a wrong diagnosis, we didn't run the{' '} {cap(selectedCrop)} check. Switch to {cap(suggestedCrop)}, or take another clear photo of a single {cap(selectedCrop)} leaf. > ) : ( <> We couldn't confidently match this to a {cap(selectedCrop)}{' '} leaf, so we didn't run the check. Make sure you picked the right crop, then take another clear, close-up photo of one leaf. > )}