Handle frigate+ error

This commit is contained in:
Nicolas Mowen 2024-08-18 07:17:17 -06:00
parent a87a9fbbf9
commit 39261c208c

View File

@ -13,6 +13,7 @@ import { FrigateConfig } from "@/types/frigateConfig";
import axios from "axios"; import axios from "axios";
import { useCallback, useMemo } from "react"; import { useCallback, useMemo } from "react";
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch"; import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
import { toast } from "sonner";
import useSWR from "swr"; import useSWR from "swr";
type FrigatePlusDialogProps = { type FrigatePlusDialogProps = {
@ -55,14 +56,24 @@ export function FrigatePlusDialog({
return; return;
} }
falsePositive const req = falsePositive
? axios.put(`events/${upload.id}/false_positive`) ? axios.put(`events/${upload.id}/false_positive`)
: axios.post(`events/${upload.id}/plus`, { : axios.post(`events/${upload.id}/plus`, {
include_annotation: 1, include_annotation: 1,
}); });
onEventUploaded(); req
onClose(); .then((resp) => {
if (resp.status == 200) {
onEventUploaded();
onClose();
}
})
.catch(() => {
toast.error("Failed to upload image.", {
position: "top-center",
});
});
}, },
[upload, onClose, onEventUploaded], [upload, onClose, onEventUploaded],
); );