import { formatTimestampWIB, calculateDuration, getActiveStatus } from "@/lib/utils"; interface TimestampCellProps { timestamp: string | Date | null | undefined; firstSeen?: string | Date | null | undefined; showActiveStatus?: boolean; } export function TimestampCell({ timestamp, firstSeen, showActiveStatus = true }: TimestampCellProps) { if (!timestamp) { return -; } const formattedTime = formatTimestampWIB(timestamp); const splitTime = formattedTime.split(' '); // toLocaleString('id-ID') separates date and time with a space usually const dateStr = splitTime[0] || formattedTime; const timeStr = splitTime[1] || ""; const isActive = showActiveStatus ? getActiveStatus(timestamp) : false; const duration = firstSeen ? calculateDuration(firstSeen, timestamp) : null; return (
{dateStr} {timeStr} {showActiveStatus && ( {isActive ? "Active" : "Inactive"} )} {duration && duration !== "-" && ( ⏱ {duration} )}
); }