Add FamDone Brand component and add rewards count system
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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[] = [];
|
||||
|
||||
|
||||
@@ -137,6 +137,7 @@ export interface BonusConfig {
|
||||
criteriaValue?: number;
|
||||
period?: BonusPeriod;
|
||||
status: BonusStatus;
|
||||
targetChoreId?: string;
|
||||
isPocketMoney?: boolean;
|
||||
completeBy?: 'unlimited' | 'week' | 'custom';
|
||||
startDate?: string;
|
||||
|
||||
Reference in New Issue
Block a user