import { useApiHost } from "@/api"; import { Card } from "../ui/card"; import { Event as FrigateEvent } from "@/types/event"; import { LuClock, LuStar } from "react-icons/lu"; import { useCallback } from "react"; import TimeAgo from "../dynamic/TimeAgo"; import { HiOutlineVideoCamera } from "react-icons/hi"; import { MdOutlineLocationOn } from "react-icons/md"; import axios from "axios"; type MiniEventCardProps = { event: FrigateEvent; onUpdate?: () => void; }; export default function MiniEventCard({ event, onUpdate }: MiniEventCardProps) { const baseUrl = useApiHost(); const onSave = useCallback( async (e: Event) => { e.stopPropagation(); let response; if (!event.retain_indefinitely) { response = await axios.post(`events/${event.id}/retain`); } else { response = await axios.delete(`events/${event.id}/retain`); } if (response.status === 200 && onUpdate) { onUpdate(); } }, [event] ); return (
onSave(e)} fill={event.retain_indefinitely ? "currentColor" : "none"} /> {event.end_time ? null : (
In progress
)}
{event.label.replaceAll("_", " ")} {event.sub_label ? `: ${event.sub_label.replaceAll("_", " ")}` : null}
{event.camera.replaceAll("_", " ")}
{event.zones.length ? (
{event.zones.join(", ").replaceAll("_", " ")}
) : null}
); }