habitica-self-host/website/common/script/libs/isFreeRebirth.js

15 lines
425 B
JavaScript
Raw Normal View History

import moment from 'moment';
import { MAX_LEVEL } from '../constants';
2019-10-01 15:53:48 +00:00
export default function isFreeRebirth (user) {
let daysFromLastFreeRebirth = user.flags.lastFreeRebirth;
if (daysFromLastFreeRebirth) {
daysFromLastFreeRebirth = moment().diff(moment(user.flags.lastFreeRebirth), 'days');
} else {
daysFromLastFreeRebirth = 999;
}
return user.stats.lvl >= MAX_LEVEL && daysFromLastFreeRebirth > 45;
2019-10-01 15:53:48 +00:00
}