varierty of implementstions based on platform droplet issuance

This commit is contained in:
JCEEE
2026-08-26 10:17:32 +01:00
parent 7ebabc6e62
commit 8fea21704a
16 changed files with 1118 additions and 452 deletions
@@ -53,15 +53,33 @@ export async function toggle(pb: any, famId: string, memberId: string, body: { a
.getFullList({ filter });
if (existing?.length > 0) {
await pb.collection('completions').delete(existing[0].id);
// Un-completing a cash todo removes its one-time reward.
if (isTodo && existing[0].rewardId) {
await pb.collection('rewards').delete(existing[0].rewardId).catch(() => {});
}
evaluateFam(pb, famId).catch(() => {});
return { completed: false };
}
let rewardId: string | undefined;
if (isTodo && chore?.type === 'money' && Number(chore.value) > 0) {
const reward = await pb.collection('rewards').create({
famId,
memberId,
label: chore.customName || 'Cash todo',
value: Number(chore.value),
rewardType: 'cash',
status: 'unclaimed',
date
});
rewardId = reward.id;
}
const record = await pb.collection('completions').create({
famId,
memberId,
assignedChoreId,
date,
completedAt: new Date().toISOString()
completedAt: new Date().toISOString(),
...(rewardId ? { rewardId } : {})
});
evaluateFam(pb, famId).catch(() => {});
return { completed: true, record };
+2 -2
View File
@@ -6,10 +6,10 @@ const RESOURCES: Record<
string,
{ col: string; listFilter: (famId: string) => string; bonus?: 'config' | 'template' }
> = {
'chore-templates': { col: 'chore_templates', listFilter: (f) => `famId = '${f}'` },
'chore-templates': { col: 'chore_templates', listFilter: (f) => `(famId = '${f}' || global = true)` },
members: { col: 'users', listFilter: (f) => `famId = '${f}' && role = 'child'` },
'assigned-chores': { col: 'assigned_chores', listFilter: (f) => `famId = '${f}'` },
'bonus-templates': { col: 'bonus_templates', listFilter: (f) => `famId = '${f}'`, bonus: 'template' },
'bonus-templates': { col: 'bonus_templates', listFilter: (f) => `(famId = '${f}' || global = true)`, bonus: 'template' },
'bonus-configs': { col: 'bonus_configs', listFilter: (f) => `famId = '${f}'`, bonus: 'config' },
completions: { col: 'completions', listFilter: (f) => `famId = '${f}'` },
rewards: { col: 'rewards', listFilter: (f) => `famId = '${f}'` },