import { useCallback } from 'react' import { useDropzone } from 'react-dropzone' import { Upload, Camera } from 'lucide-react' import { cn } from '@/lib/utils' interface DropZoneProps { photoCount: number onDrop: (files: File[]) => void } const MAX = 3 export function DropZone({ photoCount, onDrop }: DropZoneProps) { const remaining = MAX - photoCount const disabled = remaining === 0 const handleDrop = useCallback( (accepted: File[]) => { onDrop(accepted.slice(0, remaining)) }, [onDrop, remaining], ) const { getRootProps, getInputProps, isDragActive } = useDropzone({ accept: { 'image/*': [] }, maxFiles: remaining, disabled, onDrop: handleDrop, }) return (
{isDragActive ? ( ) : ( )}

{isDragActive ? 'Drop photos here' : disabled ? 'Maximum 3 photos reached' : 'Drag photos or tap to shoot'}

{disabled ? '' : `${remaining} of ${MAX} slots remaining ยท JPEG, PNG, WebP`}

) }