updated rewards assignment and reward progress

This commit is contained in:
JCEEE
2026-08-31 16:44:37 +01:00
parent cda2cbfcab
commit 3bf78d777c
10 changed files with 549 additions and 209 deletions
@@ -32,9 +32,9 @@
weekdayInTz,
wallClockToUtc,
resolveTz,
periodStart,
periodEnd,
isCompleteForPeriod
isCompleteForPeriod,
bonusWindow,
completionInWindow
} from '@shared/timezone';
let { data } = $props();
@@ -466,20 +466,20 @@
return !cfg.memberId || cfg.memberId === memberId;
})
.map((cfg) => {
const per = cfg.period || 'weekly';
const pStart = periodStart(per, paydayDay, famTz);
const pEnd = periodEnd(per, pStart);
const win = bonusWindow(cfg, paydayDay, famTz);
const pStart = win.from || '';
const pEnd = win.to || '';
const periodDays =
Math.round(
(new Date(pEnd + 'T00:00:00').getTime() - new Date(pStart + 'T00:00:00').getTime()) /
86400000
) + 1;
pStart && pEnd
? Math.round(
(new Date(pEnd + 'T00:00:00').getTime() -
new Date(pStart + 'T00:00:00').getTime()) /
86400000
) + 1
: 1;
const periodCompletions = completions.filter(
(c) =>
c.memberId === memberId &&
(c.date?.slice(0, 10) || c.date) >= pStart &&
(c.date?.slice(0, 10) || c.date) <= pEnd
(c) => c.memberId === memberId && completionInWindow(c, win)
);
// Percent thresholds are "X% of the chores done this period" — the