added pocketmoney default droplet

This commit is contained in:
JCEEE
2026-08-25 14:30:26 +01:00
parent e904bb8210
commit 5302f86f3c
10 changed files with 423 additions and 83 deletions
+29
View File
@@ -55,6 +55,35 @@ export async function createChild(opts: {
}
if (!user) throw new Error('Failed to create child');
// Auto-create the child's pocket-money droplet. The amount (rewardValue)
// starts empty — the parent sets it on the Bonuses page. This keeps pocket
// money a first-class, always-present feature without a separate field.
const pm = await pb
.collection('bonus_configs')
.getFirstListItem(`famId='${opts.famId}' && memberId='${user.id}' && isPocketMoney=true`)
.catch(() => null);
if (!pm) {
await pb
.collection('bonus_configs')
.create({
famId: opts.famId,
name: 'Pocket Money',
target: 'individual',
type: 'threshold',
thresholdType: 'percent',
occurrence: 'recurring',
rewardType: 'cash',
rewardValue: '',
criteriaValue: 50,
memberId: user.id,
period: 'weekly',
status: 'active',
isPocketMoney: true
})
.catch(() => null);
}
return user;
}