import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { useAlertHitContext } from "../../context/AlertHitContext"; import { useCameraBlackboard } from "../../hooks/useCameraBlackboard"; import type { CameraBlackBoardOptions, SightingType } from "../../types/types"; import Card from "../UI/Card"; import CardHeader from "../UI/CardHeader"; import AlertItem from "./AlertItem"; import { faTrash } from "@fortawesome/free-solid-svg-icons"; 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 handleClearListClick = (listName: CameraBlackBoardOptions) => { dispatch({ type: "DELETE", payload: [] }); mutation.mutate({ operation: "DELETE", path: listName.path, }); }; return ( {isLoading &&

Loading...

} {error &&

Error: {error.message}

}
{state?.alertList?.length > 0 ? ( state?.alertList?.map((alertItem, index) => (
)) ) : (

No Alert results

)}
); }; export default HistoryList;