import { useState } from 'react'; import { ArrowLeft, ChevronRight, Camera, X } from 'lucide-react'; interface Tank { name: string; type: 'VEG' | 'FLOWER'; } interface ReservoirCheckData { tankName: string; tankType: 'VEG' | 'FLOWER'; levelPercent: number; status: 'OK' | 'LOW' | 'CRITICAL'; photoUrl?: string; notes?: string; } interface ReservoirChecklistProps { onComplete: (checks: ReservoirCheckData[]) => void; onBack: () => void; isPhotoRequired: boolean; } export default function ReservoirChecklist({ onComplete, onBack, isPhotoRequired }: ReservoirChecklistProps) { const tanks: Tank[] = [ { name: 'Veg Tank 1', type: 'VEG' }, { name: 'Veg Tank 2', type: 'VEG' }, { name: 'Flower Tank 1', type: 'FLOWER' }, { name: 'Flower Tank 2', type: 'FLOWER' }, ]; const [checks, setChecks] = useState>(new Map()); const [currentTankIndex, setCurrentTankIndex] = useState(0); const [levelPercent, setLevelPercent] = useState(100); const [notes, setNotes] = useState(''); const [photo, setPhoto] = useState(null); const currentTank = tanks[currentTankIndex]; const isLastTank = currentTankIndex === tanks.length - 1; const getStatus = (level: number): 'OK' | 'LOW' | 'CRITICAL' => { if (level >= 70) return 'OK'; if (level >= 30) return 'LOW'; return 'CRITICAL'; }; const handleNext = () => { if (isPhotoRequired && !photo) { alert('Photo is required for this step.'); return; } const checkData: ReservoirCheckData = { tankName: currentTank.name, tankType: currentTank.type, levelPercent, status: getStatus(levelPercent), notes: notes || undefined, photoUrl: photo || undefined }; const newChecks = new Map(checks); newChecks.set(currentTank.name, checkData); setChecks(newChecks); if (isLastTank) { onComplete(Array.from(newChecks.values())); } else { setCurrentTankIndex(currentTankIndex + 1); setLevelPercent(100); setNotes(''); setPhoto(null); } }; const status = getStatus(levelPercent); const statusConfig = { OK: { color: 'bg-success', text: 'Good' }, LOW: { color: 'bg-warning', text: 'Low' }, CRITICAL: { color: 'bg-destructive', text: 'Critical' }, }[status]; return (
{/* Header */}

Reservoir {currentTankIndex + 1}/{tanks.length}

{currentTank.name}

{currentTank.type}
{/* Progress */}
{tanks.map((_, i) => (
))}
{/* Level Indicator */}
{levelPercent}%
setLevelPercent(parseInt(e.target.value))} className="w-full h-1.5 bg-tertiary rounded-full appearance-none cursor-pointer accent-accent" />
{statusConfig.text}
{/* Notes - compact */}
setNotes(e.target.value)} placeholder="Notes (optional)" className="input w-full text-sm" />
{/* Photo - only show when needed */} {(isPhotoRequired || status !== 'OK') && (
{ if (e.target.files?.[0]) { setPhoto(URL.createObjectURL(e.target.files[0])); } }} /> {photo ? (
Preview
) : ( )}
)} {/* Actions */}
); }