2024-03-21 03:56:15 +01:00
|
|
|
import { useEventSegmentUtils } from "@/hooks/use-event-segment-utils";
|
2024-03-21 15:00:04 +01:00
|
|
|
import { ReviewSegment, ReviewSeverity } from "@/types/review";
|
2024-03-21 03:56:15 +01:00
|
|
|
import React, { useMemo } from "react";
|
|
|
|
// import useTapUtils from "@/hooks/use-tap-utils";
|
|
|
|
|
|
|
|
type SummarySegmentProps = {
|
|
|
|
events: ReviewSegment[];
|
|
|
|
segmentTime: number;
|
|
|
|
segmentDuration: number;
|
|
|
|
segmentHeight: number;
|
2024-03-21 15:00:04 +01:00
|
|
|
severityType: ReviewSeverity;
|
2024-03-21 03:56:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export function SummarySegment({
|
|
|
|
events,
|
|
|
|
segmentTime,
|
|
|
|
segmentDuration,
|
|
|
|
segmentHeight,
|
2024-03-21 15:00:04 +01:00
|
|
|
severityType,
|
2024-03-21 03:56:15 +01:00
|
|
|
}: SummarySegmentProps) {
|
|
|
|
const { getSeverity, getReviewed, displaySeverityType } =
|
|
|
|
useEventSegmentUtils(segmentDuration, events, severityType);
|
|
|
|
|
|
|
|
const severity = useMemo(
|
|
|
|
() => getSeverity(segmentTime, displaySeverityType),
|
|
|
|
[getSeverity, segmentTime, displaySeverityType],
|
|
|
|
);
|
|
|
|
|
|
|
|
const reviewed = useMemo(
|
|
|
|
() => getReviewed(segmentTime),
|
|
|
|
[getReviewed, segmentTime],
|
|
|
|
);
|
|
|
|
|
|
|
|
const segmentKey = useMemo(() => segmentTime, [segmentTime]);
|
|
|
|
|
|
|
|
const severityColors: { [key: number]: string } = {
|
2024-03-25 03:37:44 +01:00
|
|
|
1: reviewed
|
|
|
|
? "bg-severity_significant_motion/50"
|
|
|
|
: "bg-severity_significant_motion",
|
2024-03-21 03:56:15 +01:00
|
|
|
2: reviewed ? "bg-severity_detection/50" : "bg-severity_detection",
|
|
|
|
3: reviewed ? "bg-severity_alert/50" : "bg-severity_alert",
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
key={segmentKey}
|
|
|
|
className="relative w-full"
|
|
|
|
style={{ height: segmentHeight }}
|
|
|
|
>
|
2024-03-21 15:00:04 +01:00
|
|
|
{severity.map((severityValue: number, index: number) => (
|
|
|
|
<React.Fragment key={index}>
|
|
|
|
{severityValue === displaySeverityType && (
|
2024-03-21 03:56:15 +01:00
|
|
|
<div
|
2024-05-14 17:06:44 +02:00
|
|
|
className="flex cursor-pointer justify-end"
|
2024-03-21 03:56:15 +01:00
|
|
|
style={{ height: segmentHeight }}
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
key={`${segmentKey}_${index}_secondary_data`}
|
|
|
|
style={{ height: segmentHeight }}
|
|
|
|
className={`w-[10px] ${severityColors[severityValue]}`}
|
|
|
|
></div>
|
|
|
|
</div>
|
2024-03-21 15:00:04 +01:00
|
|
|
)}
|
|
|
|
</React.Fragment>
|
|
|
|
))}
|
2024-03-21 03:56:15 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SummarySegment;
|