'use client'; import type { Variants } from 'framer-motion'; import { motion } from 'framer-motion'; import { Plus } from 'lucide-react'; import { useDropzone } from 'react-dropzone'; import { megabytesToBytes } from '@documenso/lib/universal/unit-convertions'; import { cn } from '../lib/utils'; import { Card, CardContent } from './card'; const DocumentDropzoneContainerVariants: Variants = { initial: { scale: 1, }, animate: { scale: 1, }, hover: { transition: { staggerChildren: 0.05, }, }, }; const DocumentDropzoneCardLeftVariants: Variants = { initial: { x: 40, y: -10, rotate: -14, }, animate: { x: 40, y: -10, rotate: -14, }, hover: { x: -25, y: -25, rotate: -22, }, }; const DocumentDropzoneCardRightVariants: Variants = { initial: { x: -40, y: -10, rotate: 14, }, animate: { x: -40, y: -10, rotate: 14, }, hover: { x: 25, y: -25, rotate: 22, }, }; const DocumentDropzoneCardCenterVariants: Variants = { initial: { x: 0, y: 0, }, animate: { x: 0, y: 0, }, hover: { x: 0, y: -25, }, }; const DocumentDescription = { document: { headline: 'Add a document', }, template: { headline: 'Upload Template Document', }, }; export type DocumentDropzoneProps = { className?: string; disabled?: boolean; disabledMessage?: string; onDrop?: (_file: File) => void | Promise; type?: 'document' | 'template'; [key: string]: unknown; }; export const DocumentDropzone = ({ className, onDrop, disabled, disabledMessage = 'You cannot upload documents at this time.', type = 'document', ...props }: DocumentDropzoneProps) => { const { getRootProps, getInputProps } = useDropzone({ accept: { 'application/pdf': ['.pdf'], }, multiple: false, disabled, onDrop: ([acceptedFile]) => { if (acceptedFile && onDrop) { void onDrop(acceptedFile); } }, maxSize: megabytesToBytes(50), }); return ( {/* */}

{DocumentDescription[type].headline}

{disabled ? disabledMessage : 'Drag & drop your document here.'}

); };