fix bonus completeions
This commit is contained in:
@@ -252,8 +252,20 @@ export async function evaluateFam(pb: any, famId: string) {
|
||||
}
|
||||
|
||||
if (cfg.occurrence === 'once' && (existingRewards.length > 0 || createdReward)) {
|
||||
// Status write via superuser: evaluate often runs as a child token
|
||||
// (fire-and-forget after a chore toggle) and bonus_configs updates
|
||||
// are parent-only — the user-token write 403s and the config stays
|
||||
// `active` forever. Stamp who earned it + when.
|
||||
const earner =
|
||||
existingRewards.find((r: any) => r.memberId)?.memberId ||
|
||||
allMembers[0]?.id ||
|
||||
'auto';
|
||||
try {
|
||||
await pb.collection('bonus_configs').update(cfg.id, { status: 'completed' });
|
||||
await pbAdmin.update('bonus_configs', cfg.id, {
|
||||
status: 'completed',
|
||||
completedAt: new Date().toISOString().slice(0, 10),
|
||||
completedBy: earner
|
||||
});
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user