import { Camera, ImageUp, RefreshCw, X } from 'lucide-react' import { useRef, useState } from 'react' import { Button } from './ui' /** * Empty: a drop zone with "Take or upload a photo" (on phones the button opens the camera or photos). * With a photo: `children` renders it (plain image or attention view) with Change / Remove. */ export default function PhotoPicker({ hasPhoto, onFile, onClear, children, disabled = false, label = 'Take or upload a photo' }) { const inputRef = useRef(null) const [dragging, setDragging] = useState(false) function pick(files) { const file = files?.[0] if (file) onFile(file) if (inputRef.current) inputRef.current.value = '' // choosing the same file again still fires } const input = ( pick(e.target.files)} /> ) if (hasPhoto) { return (
Drag a photo here, or
JPG, PNG or WebP, up to 10 MB
{input}