From 39261c208c1d6ccf5ba7c489c012b690c758cee0 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sun, 18 Aug 2024 07:17:17 -0600 Subject: [PATCH] Handle frigate+ error --- .../overlay/dialog/FrigatePlusDialog.tsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/web/src/components/overlay/dialog/FrigatePlusDialog.tsx b/web/src/components/overlay/dialog/FrigatePlusDialog.tsx index 3c5f3890d..d6b8c39b8 100644 --- a/web/src/components/overlay/dialog/FrigatePlusDialog.tsx +++ b/web/src/components/overlay/dialog/FrigatePlusDialog.tsx @@ -13,6 +13,7 @@ import { FrigateConfig } from "@/types/frigateConfig"; import axios from "axios"; import { useCallback, useMemo } from "react"; import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch"; +import { toast } from "sonner"; import useSWR from "swr"; type FrigatePlusDialogProps = { @@ -55,14 +56,24 @@ export function FrigatePlusDialog({ return; } - falsePositive + const req = falsePositive ? axios.put(`events/${upload.id}/false_positive`) : axios.post(`events/${upload.id}/plus`, { include_annotation: 1, }); - onEventUploaded(); - onClose(); + req + .then((resp) => { + if (resp.status == 200) { + onEventUploaded(); + onClose(); + } + }) + .catch(() => { + toast.error("Failed to upload image.", { + position: "top-center", + }); + }); }, [upload, onClose, onEventUploaded], );