import { FrigateConfig } from "@/types/frigateConfig"; import useSWR from "swr"; type MinimapSegmentProps = { isFirstSegmentInMinimap: boolean; isLastSegmentInMinimap: boolean; alignedMinimapStartTime: number; alignedMinimapEndTime: number; firstMinimapSegmentRef: React.MutableRefObject; dense: boolean; }; type TickSegmentProps = { timestamp: Date; timestampSpread: number; }; type TimestampSegmentProps = { isFirstSegmentInMinimap: boolean; isLastSegmentInMinimap: boolean; timestamp: Date; timestampSpread: number; segmentKey: number; }; export function MinimapBounds({ isFirstSegmentInMinimap, isLastSegmentInMinimap, alignedMinimapStartTime, alignedMinimapEndTime, firstMinimapSegmentRef, dense, }: MinimapSegmentProps) { const { data: config } = useSWR("config"); return ( <> {isFirstSegmentInMinimap && (
{new Date(alignedMinimapStartTime * 1000).toLocaleTimeString([], { hour12: config?.ui.time_format != "24hour", hour: "2-digit", minute: "2-digit", ...(!dense && { month: "short", day: "2-digit" }), })}
)} {isLastSegmentInMinimap && (
{new Date(alignedMinimapEndTime * 1000).toLocaleTimeString([], { hour12: config?.ui.time_format != "24hour", hour: "2-digit", minute: "2-digit", ...(!dense && { month: "short", day: "2-digit" }), })}
)} ); } export function Tick({ timestamp, timestampSpread }: TickSegmentProps) { return (
); } export function Timestamp({ isFirstSegmentInMinimap, isLastSegmentInMinimap, timestamp, timestampSpread, segmentKey, }: TimestampSegmentProps) { const { data: config } = useSWR("config"); return (
{!isFirstSegmentInMinimap && !isLastSegmentInMinimap && (
{timestamp.getMinutes() % timestampSpread === 0 && timestamp.getSeconds() === 0 && timestamp.toLocaleTimeString([], { hour12: config?.ui.time_format != "24hour", hour: "2-digit", minute: "2-digit", })}
)}
); }