2025-02-10 00:13:32 +03:00
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
import { ConsolidatedSegmentData } from "@/types/review";
|
2024-03-21 05:56:15 +03:00
|
|
|
|
|
|
|
|
type SummarySegmentProps = {
|
2025-02-10 00:13:32 +03:00
|
|
|
segmentData: ConsolidatedSegmentData;
|
|
|
|
|
totalDuration: number;
|
2024-03-21 05:56:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function SummarySegment({
|
2025-02-10 00:13:32 +03:00
|
|
|
segmentData,
|
|
|
|
|
totalDuration,
|
2024-03-21 05:56:15 +03:00
|
|
|
}: SummarySegmentProps) {
|
2025-02-10 00:13:32 +03:00
|
|
|
const { startTime, endTime, severity, reviewed } = segmentData;
|
2024-03-21 05:56:15 +03:00
|
|
|
|
2025-02-10 00:13:32 +03:00
|
|
|
const severityColors: { [key: string]: string } = {
|
|
|
|
|
significant_motion: reviewed
|
2024-03-25 05:37:44 +03:00
|
|
|
? "bg-severity_significant_motion/50"
|
|
|
|
|
: "bg-severity_significant_motion",
|
2025-02-10 00:13:32 +03:00
|
|
|
detection: reviewed ? "bg-severity_detection/50" : "bg-severity_detection",
|
|
|
|
|
alert: reviewed ? "bg-severity_alert/50" : "bg-severity_alert",
|
|
|
|
|
empty: "bg-transparent",
|
2024-03-21 05:56:15 +03:00
|
|
|
};
|
|
|
|
|
|
2025-02-10 00:13:32 +03:00
|
|
|
const height = ((endTime - startTime) / totalDuration) * 100;
|
|
|
|
|
|
2024-03-21 05:56:15 +03:00
|
|
|
return (
|
2025-02-10 00:13:32 +03:00
|
|
|
<div className="relative w-full" style={{ height: `${height}%` }}>
|
|
|
|
|
<div className="absolute inset-0 flex h-full cursor-pointer justify-end">
|
|
|
|
|
<div
|
|
|
|
|
className={cn(
|
|
|
|
|
"w-[10px]",
|
|
|
|
|
severityColors[severity],
|
|
|
|
|
height < 0.5 && "min-h-[0.5px]",
|
2024-03-21 17:00:04 +03:00
|
|
|
)}
|
2025-02-10 00:13:32 +03:00
|
|
|
></div>
|
|
|
|
|
</div>
|
2024-03-21 05:56:15 +03:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default SummarySegment;
|