mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-26 16:53:52 +00:00
15 lines
428 B
JavaScript
15 lines
428 B
JavaScript
|
|
import moment from 'moment';
|
||
|
|
import { MAX_LEVEL } from '../constants';
|
||
|
|
|
||
|
|
module.exports = 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;
|
||
|
|
};
|