fix payday
This commit is contained in:
@@ -158,7 +158,10 @@ export async function evaluateFam(pb: any, famId: string) {
|
||||
const memberReward = existingRewards.find((r: any) => r.memberId === m.id);
|
||||
|
||||
if (memberReward && !achieved) {
|
||||
if (memberReward.status !== 'claimed') {
|
||||
// Payday-gated (e.g. pocket money) and member-requested rewards
|
||||
// persist across week rollover until the parent issues them —
|
||||
// deleting them here gave parents only a payday-day window.
|
||||
if (memberReward.status !== 'claimed' && memberReward.status !== 'requested' && memberReward.claimable !== 'payday') {
|
||||
try {
|
||||
await pb.collection('rewards').delete(memberReward.id);
|
||||
} catch {}
|
||||
@@ -197,12 +200,11 @@ export async function evaluateFam(pb: any, famId: string) {
|
||||
|
||||
if (!achieved && existingRewards.length > 0) {
|
||||
for (const r of existingRewards) {
|
||||
if (r.status !== 'claimed') {
|
||||
if (r.status === 'claimed' || r.status === 'requested' || r.claimable === 'payday') continue;
|
||||
try {
|
||||
await pb.collection('rewards').delete(r.id);
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -245,7 +247,7 @@ export async function evaluateFam(pb: any, famId: string) {
|
||||
if (existingRewards.length > 0) {
|
||||
const existing = existingRewards[0];
|
||||
const stillValid = winner && existing.memberId === winner.memberId && winner.current > 0;
|
||||
if (!stillValid && existing.status !== 'claimed') {
|
||||
if (!stillValid && existing.status !== 'claimed' && existing.status !== 'requested' && existing.claimable !== 'payday') {
|
||||
try {
|
||||
await pb.collection('rewards').delete(existing.id);
|
||||
} catch {}
|
||||
|
||||
Reference in New Issue
Block a user