import {FC} from 'react'; type UserStatusProps = { lastOnline?: string | null; }; const convertDateFormat = (lastOnline: string | null | undefined): number | null => { if (!lastOnline) { return null; } const date = new Date(lastOnline + 'Z'); return Math.floor(date.getTime() / 1000); }; export const OnlineBadge: FC = ({lastOnline}) => { const currentTimeInSeconds = Math.floor(Date.now() / 1000); const unixTime = convertDateFormat(lastOnline); if (typeof lastOnline === 'undefined' || lastOnline === null) { return
; } const timeDifferenceInSeconds = unixTime ? currentTimeInSeconds - unixTime : Infinity; if (timeDifferenceInSeconds > 0 && timeDifferenceInSeconds <= 60) { return
; } return
; };