diff --git a/app/components/DragAndDropForm.tsx b/app/components/DragAndDropForm.tsx index 6626cfa3..faaa452d 100644 --- a/app/components/DragAndDropForm.tsx +++ b/app/components/DragAndDropForm.tsx @@ -1,14 +1,14 @@ import { ArrowCircleDownIcon } from "@heroicons/react/outline"; -import { useCallback, useRef } from "react"; +import { useCallback, useRef, useState } from "react"; import { useDropzone } from "react-dropzone"; import { Form, useSubmit } from "remix"; import invariant from "tiny-invariant"; - +import ToastPopover from "./UI/ToastPopover"; export function DragAndDropForm() { const formRef = useRef(null); const filenameInputRef = useRef(null); const rawJsonInputRef = useRef(null); - + const [error, setError] = useState(null); const submit = useSubmit(); const onDrop = useCallback( @@ -60,6 +60,10 @@ export function DragAndDropForm() { maxSize: 1024 * 1024 * 1, multiple: false, accept: "application/json", + onDropRejected: (fileRejections) => { + setError(fileRejections[0].errors[0].message); + setTimeout(() => setError(null), 4000); + }, }); return ( @@ -85,6 +89,14 @@ export function DragAndDropForm() { + {error && ( + + )} ); }