Add FamDone Brand component and add rewards count system

This commit is contained in:
JCEEE
2026-09-02 13:32:11 +01:00
parent eaa5104817
commit 1360799b60
11 changed files with 123 additions and 54 deletions
+4 -5
View File
@@ -3,11 +3,11 @@
</script>
<svelte:element this={tag} class="fam-done">
FamDone<svg
Fam<span class="text-green-500">Done</span><svg
class="fam-done-check"
xmlns="http://www.w3.org/2000/svg"
width="14"
height="14"
width="1em"
height="1em"
viewBox="0 0 24 24"
fill="none"
stroke="#10b981"
@@ -24,10 +24,9 @@
color: inherit;
}
.fam-done-check {
font-size: x-small;
vertical-align: super;
position: relative;
top: -0.3em;
margin-left: 1px;
display: inline-block;
}
</style>
+4
View File
@@ -513,6 +513,10 @@ async function ensureBonusFields(): Promise<void> {
changed = true;
}
}
if (name === 'bonus_configs' && !has('targetChoreId')) {
fields.push({ name: 'targetChoreId', type: 'text', required: false });
changed = true;
}
// rewardValue must be optional so an unset pocket-money droplet can exist.
const rv = fields.find((f: any) => f.name === 'rewardValue');
if (rv && rv.required) {
+18 -2
View File
@@ -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[] = [];
+1
View File
@@ -137,6 +137,7 @@ export interface BonusConfig {
criteriaValue?: number;
period?: BonusPeriod;
status: BonusStatus;
targetChoreId?: string;
isPocketMoney?: boolean;
completeBy?: 'unlimited' | 'week' | 'custom';
startDate?: string;