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.
Label this hazard: