import { baseUrl } from "@/api/baseUrl"; import { useFormattedTimestamp } from "@/hooks/use-date-utils"; import { FrigateConfig } from "@/types/frigateConfig"; import { ReviewSegment } from "@/types/review"; import { getIconForLabel } from "@/utils/iconUtil"; import { isSafari } from "react-device-detect"; import useSWR from "swr"; import TimeAgo from "../dynamic/TimeAgo"; import { useMemo } from "react"; import useImageLoaded from "@/hooks/use-image-loaded"; import ImageLoadingIndicator from "../indicators/ImageLoadingIndicator"; type ReviewCardProps = { event: ReviewSegment; currentTime: number; onClick?: () => void; }; export default function ReviewCard({ event, currentTime, onClick, }: ReviewCardProps) { const { data: config } = useSWR("config"); const [imgRef, imgLoaded, onImgLoad] = useImageLoaded(); const formattedDate = useFormattedTimestamp( event.start_time, config?.ui.time_format == "24hour" ? "%H:%M" : "%I:%M %p", ); const isSelected = useMemo( () => event.start_time <= currentTime && event.end_time >= currentTime, [event, currentTime], ); return (
{ onImgLoad(); }} />
{event.data.objects.map((object) => { return getIconForLabel(object, "size-3 text-white"); })} {event.data.audio.map((audio) => { return getIconForLabel(audio, "size-3 text-white"); })}
{formattedDate}
); }