mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-28 14:16:41 +07:00
17 lines
429 B
TypeScript
17 lines
429 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;
|
|
}
|
|
};
|