Skip to content

Commit

Permalink
Implement error toasts (#254)
Browse files Browse the repository at this point in the history
Pretty trivial; replace non-existent toast.error method with
addErrorAlert
  • Loading branch information
chennisden authored Aug 6, 2024
1 parent 30c3d04 commit 81d8f0f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions frontend/src/components/listing/FileUpload.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -69,6 +70,8 @@ export const FileUploader = forwardRef<
},
ref,
) => {
const { addErrorAlert } = useAlertQueue();

const [isFileTooBig, setIsFileTooBig] = useState(false);
const [isLOF, setIsLOF] = useState(false);
const [activeIndex, setActiveIndex] = useState(-1);
Expand Down Expand Up @@ -154,7 +157,7 @@ export const FileUploader = forwardRef<
const files = acceptedFiles;

if (!files) {
// Toast.error("file error , probably too big");
addErrorAlert("There was an issue with the file.");
return;
}

Expand All @@ -175,13 +178,13 @@ 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`
// );
addErrorAlert(
`File is too large. The maximum size is ${maxSize / 1024 / 1024}MB.`,
);
break;
}
if (rejectedFiles[i].errors[0]?.message) {
// toast.error(rejectedFiles[i].errors[0].message);
addErrorAlert(rejectedFiles[i].errors[0].message);
break;
}
}
Expand Down

0 comments on commit 81d8f0f

Please sign in to comment.