From b2c2b36b3878d19ce05c9d47679e4dc7545727af Mon Sep 17 00:00:00 2001 From: Dennis Chen Date: Mon, 5 Aug 2024 15:19:49 -0700 Subject: [PATCH] Implement error toasts Pretty trivial; replace non-existent toast.error method with addAlert(-, 'error') --- frontend/src/components/listing/FileUpload.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/listing/FileUpload.tsx b/frontend/src/components/listing/FileUpload.tsx index 7bb34f23..72c962be 100644 --- a/frontend/src/components/listing/FileUpload.tsx +++ b/frontend/src/components/listing/FileUpload.tsx @@ -1,5 +1,6 @@ import { buttonVariants } from "components/ui/Button/Button"; import { Input } from "components/ui/Input/Input"; +import { useAlertQueue } from "hooks/useAlertQueue"; import { Trash2 as RemoveIcon } from "lucide-react"; import { createContext, @@ -69,6 +70,8 @@ export const FileUploader = forwardRef< }, ref, ) => { + const {addAlert} = useAlertQueue(); + const [isFileTooBig, setIsFileTooBig] = useState(false); const [isLOF, setIsLOF] = useState(false); const [activeIndex, setActiveIndex] = useState(-1); @@ -154,7 +157,7 @@ export const FileUploader = forwardRef< const files = acceptedFiles; if (!files) { - // Toast.error("file error , probably too big"); + addAlert("file error , probably too big", "error"); return; } @@ -175,13 +178,17 @@ export const FileUploader = forwardRef< if (rejectedFiles.length > 0) { for (let i = 0; i < rejectedFiles.length; i++) { if (rejectedFiles[i].errors[0]?.code === "file-too-large") { - // toast.error( - // `File is too large. Max size is ${maxSize / 1024 / 1024}MB` - // ); + addAlert( + `File is too large. Max size is ${maxSize / 1024 / 1024}MB`, + "error", + ); break; } if (rejectedFiles[i].errors[0]?.message) { - // toast.error(rejectedFiles[i].errors[0].message); + addAlert( + rejectedFiles[i].errors[0].message, + "error", + ); break; } }