diff --git a/src/components/CameraSettings/CameraSettingFields.tsx b/src/components/CameraSettings/CameraSettingFields.tsx index 9c19c4f..8c5836b 100644 --- a/src/components/CameraSettings/CameraSettingFields.tsx +++ b/src/components/CameraSettings/CameraSettingFields.tsx @@ -104,7 +104,7 @@ const CameraSettingFields = ({ validateOnChange={false} enableReinitialize > - {({ errors, touched, isSubmitting }) => ( + {({ errors, touched }) => (
@@ -119,6 +119,7 @@ const CameraSettingFields = ({ type="text" className="p-2 border border-gray-400 rounded-lg" placeholder="Enter camera name" + disabled />
@@ -135,7 +136,7 @@ const CameraSettingFields = ({ type="text" className="p-2 border border-gray-400 rounded-lg" placeholder="RTSP://..." - autoComplete="street-address" + disabled /> @@ -153,6 +154,7 @@ const CameraSettingFields = ({ className="p-2 border border-gray-400 rounded-lg" placeholder="Enter user name" autoComplete="username" + disabled /> @@ -170,7 +172,7 @@ const CameraSettingFields = ({ type={showPwd ? "text" : "password"} className="p-2 border border-gray-400 rounded-lg w-full " placeholder="Enter password" - autoComplete="new-password" + disabled />
{updateCameraConfigError ? ( - ) : ( )}
diff --git a/src/components/HistoryList/AlertItem.tsx b/src/components/HistoryList/AlertItem.tsx index 48c12ce..ccae950 100644 --- a/src/components/HistoryList/AlertItem.tsx +++ b/src/components/HistoryList/AlertItem.tsx @@ -5,6 +5,7 @@ import InfoBar from "../SightingsWidget/InfoBar"; import { useState } from "react"; import HotListImg from "/Hotlist_Hit.svg"; import { useAlertHitContext } from "../../context/AlertHitContext"; +import { useCameraBlackboard } from "../../hooks/useCameraBlackboard"; import NPED_CAT_A from "/NPED_Cat_A.svg"; import NPED_CAT_B from "/NPED_Cat_B.svg"; import NPED_CAT_C from "/NPED_Cat_C.svg"; @@ -17,6 +18,7 @@ type AlertItemProps = { const AlertItem = ({ item }: AlertItemProps) => { const [isModalOpen, setIsModalOpen] = useState(false); const { dispatch } = useAlertHitContext(); + const { mutation } = useCameraBlackboard(); // const {d} = useCameraBlackboard(); const motionAway = (item?.motion ?? "").toUpperCase() === "AWAY"; @@ -34,12 +36,26 @@ const AlertItem = ({ item }: AlertItemProps) => { setIsModalOpen(false); }; - const handleDelete = () => { + const handleDelete = async (deletedItem: SightingType | null) => { + const res = await mutation.mutateAsync({ + operation: "VIEW", + path: "alertHistory", + }); + const oldArray = res?.result; + const updatedArray = oldArray?.filter( + (item: SightingType) => item?.ref !== deletedItem?.ref + ); + + mutation.mutate({ + operation: "INSERT", + path: "alertHistory", + value: updatedArray, + }); dispatch({ type: "REMOVE", payload: item }); }; return (
-
+
{ {isNPEDHitA && ( hotlistHit )} {isNPEDHitB && ( hotlistHit )} {isNPEDHitC && ( hotlistHit )} diff --git a/src/components/HistoryList/HistoryList.tsx b/src/components/HistoryList/HistoryList.tsx index 81f958f..1cd3735 100644 --- a/src/components/HistoryList/HistoryList.tsx +++ b/src/components/HistoryList/HistoryList.tsx @@ -11,9 +11,22 @@ const HistoryList = () => { const { state, dispatch, isLoading, error } = useAlertHitContext(); const { mutation } = useCameraBlackboard(); - const handleDeleteClick = (alertItem: SightingType, idx?: number) => { - dispatch({ type: "REMOVE", payload: alertItem }); - mutation.mutate({ operation: "POP", path: "alertHistory", value: idx }); + const handleDeleteClick = async (deletedItem: SightingType) => { + const res = await mutation.mutateAsync({ + operation: "VIEW", + path: "alertHistory", + }); + const oldArray = res?.result; + const updatedArray = oldArray?.filter( + (item: SightingType) => item?.ref !== deletedItem?.ref + ); + + mutation.mutate({ + operation: "INSERT", + path: "alertHistory", + value: updatedArray, + }); + dispatch({ type: "REMOVE", payload: deletedItem }); }; const handleClearListClick = (listName: CameraBlackBoardOptions) => { @@ -40,7 +53,7 @@ const HistoryList = () => { state?.alertList?.map((alertItem, index) => (
-