added pocketmoney default droplet
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user