Add FamDone Brand component and add rewards count system
This commit is contained in:
@@ -58,7 +58,15 @@ export async function evaluateFam(pb: any, famId: string) {
|
||||
// Pocket money pauses until the parent sets an amount.
|
||||
if (cfg.isPocketMoney && !cfg.rewardValue) continue;
|
||||
const win = bonusWindow(cfg, paydayEval, tzEval);
|
||||
const periodCompletions = allCompletions.filter((c: any) => completionInWindow(c, win));
|
||||
let periodCompletions = allCompletions.filter((c: any) => completionInWindow(c, win));
|
||||
|
||||
// Count-type rewards can pin against a single assigned chore (targetChoreId).
|
||||
// When set, only completions of that specific chore count toward the target.
|
||||
if (cfg.type === 'count' && cfg.targetChoreId) {
|
||||
periodCompletions = periodCompletions.filter(
|
||||
(c: any) => c.assignedChoreId === cfg.targetChoreId
|
||||
);
|
||||
}
|
||||
|
||||
const existingRewards = allRewards.filter((r: any) => r.bonusConfigId === cfg.id);
|
||||
let createdReward = false;
|
||||
@@ -241,7 +249,15 @@ export async function progress(pb: any, famId: string) {
|
||||
const win = bonusWindow(cfg, payday, tz);
|
||||
const pStart = win.from;
|
||||
const pEnd = win.to;
|
||||
const periodCompletions = completionsList.filter((c: any) => completionInWindow(c, win));
|
||||
let periodCompletions = completionsList.filter((c: any) => completionInWindow(c, win));
|
||||
|
||||
// Count-type rewards pinned to a specific chore only count that chore's
|
||||
// completions toward the target.
|
||||
if (cfg.type === 'count' && cfg.targetChoreId) {
|
||||
periodCompletions = periodCompletions.filter(
|
||||
(c: any) => c.assignedChoreId === cfg.targetChoreId
|
||||
);
|
||||
}
|
||||
|
||||
const progressRows: any[] = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user