import { useRef, useState } from "react"; interface Props { onChange: (files: File[]) => void; max?: number; existing?: number; // photos the dog already has — the counter/limit are out of `max` total } // Multi-photo picker with previews. On mobile, `capture="environment"` opens the rear camera // directly (spec §13). export default function PhotoUpload({ onChange, max = 8, existing = 0 }: Props) { const [files, setFiles] = useState([]); const inputRef = useRef(null); const room = Math.max(0, max - existing); // how many NEW photos still fit function addFiles(list: FileList | null) { if (!list) return; const next = [...files, ...Array.from(list)].slice(0, room); setFiles(next); onChange(next); } function removeAt(i: number) { const next = files.filter((_, idx) => idx !== i); setFiles(next); onChange(next); } return (
{files.map((f, i) => (
{`preview
))}
addFiles(e.target.files)} />

On a phone this opens your camera. Clear, well-lit photos of the whole dog match best.

); }