Skip to content

Commit

Permalink
Implement error toasts
Browse files Browse the repository at this point in the history
Pretty trivial; replace non-existent toast.error method with

	addAlert(-, 'error')
  • Loading branch information
chennisden committed Aug 5, 2024
1 parent 43067bb commit b2c2b36
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 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 {addAlert} = 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");
addAlert("file error , probably too big", "error");
return;
}

Expand All @@ -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;
}
}
Expand Down

0 comments on commit b2c2b36

Please sign in to comment.