import React, { useState } from 'react'; import { Trash2, Plus } from 'lucide-react'; import { Image } from '@/components/ui/image'; const PRESET_TAGS = [ 'Raw meat next to ready-to-eat food', 'Same board for raw + cooked', 'Soiled towel on food surface', 'Food in the temperature danger zone', 'Unwashed hands', 'Improper storage', 'Cross-contact allergen', ]; // Interactive hazard identification — tap a kitchen photo to mark hazards. export default function HazardIdentifier({ course, onSubmit, submitting }) { const imageUrl = course?.challenge?.image_url; const [markers, setMarkers] = useState([]); const [pending, setPending] = useState(null); const [customLabel, setCustomLabel] = useState(''); const addMarker = (e) => { if (submitting || pending) return; const rect = e.currentTarget.getBoundingClientRect(); const x = (e.clientX - rect.left) / rect.width; const y = (e.clientY - rect.top) / rect.height; setPending({ x, y }); }; const confirm = (label) => { if (!pending) return; setMarkers([...markers, { ...pending, label }]); setPending(null); setCustomLabel(''); }; const remove = (i) => setMarkers(markers.filter((_, j) => j !== i)); return (

Tap anywhere on the kitchen photo to mark a hazard. Label each one, then submit for AI evaluation.

{imageUrl ? ( Kitchen scene ) : (
No scene image configured
)} {markers.map((m, i) => (
e.stopPropagation()}> {i + 1} {m.label}
))} {pending && (
)}
{pending && (

Label this hazard:

{PRESET_TAGS.map((t) => ( ))}
setCustomLabel(e.target.value)} placeholder="Or type your own…" className="flex-1 h-8 px-2.5 text-[12px] rounded-lg border border-[#E5E7EB] focus:border-[#0A39DF] focus:outline-none" />
)}
); }