mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
14 lines
409 B
TypeScript
14 lines
409 B
TypeScript
import { differenceInDays, parseISO } from 'date-fns';
|
|
|
|
import { INACTIVE_ACCOUNT_DAYS } from '~/constants/user';
|
|
|
|
const today = new Date();
|
|
|
|
export const useUserActiveStatus = (lastSeen?: string) => {
|
|
try {
|
|
const lastSeenDate = lastSeen ? parseISO(lastSeen) : undefined;
|
|
return lastSeenDate && differenceInDays(today, lastSeenDate) < INACTIVE_ACCOUNT_DAYS;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
};
|