- fixed but to delete specific alert item

- need to remove rawcamebase from config in prod
This commit is contained in:
2025-10-13 11:48:10 +01:00
parent 9f3674e460
commit 44962e7d81
5 changed files with 46 additions and 18 deletions

View File

@@ -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) => (
<div key={index} className="flex flex-row space-x-2">
<AlertItem item={alertItem} />
<button onClick={() => handleDeleteClick(alertItem, index)}>
<button onClick={() => handleDeleteClick(alertItem)}>
<div className="p-4">
<FontAwesomeIcon icon={faTrash} size="2x" />
</div>