Fix payment display and dashboard refresh functionality
Some checks failed
CI / update (push) Failing after 4s

- Fix 'paid in full for others' payments showing CHF 0.00 instead of actual amount
- Add time-based sorting to payments (date + createdAt) for proper chronological order
- Redirect to dashboard after adding payment instead of payments list
- Implement complete dashboard refresh after payment deletion via modal
- Fix dashboard component reactivity for single debtor view updates

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-12 14:54:15 +02:00
parent 6ab395e98a
commit 6d46369eec
14 changed files with 410 additions and 68 deletions

View File

@@ -43,6 +43,11 @@
currency: 'CHF'
}).format(amount);
}
// Export refresh method for parent components to call
export async function refresh() {
await fetchDebtBreakdown();
}
</script>
{#if !shouldHide}

View File

@@ -43,7 +43,8 @@
}
$: {
// Recalculate when debtData changes
// Recalculate when debtData changes - trigger on the arrays specifically
const totalUsers = debtData.whoOwesMe.length + debtData.whoIOwe.length;
singleDebtUser = getSingleDebtUser();
shouldShowIntegratedView = singleDebtUser !== null;
}
@@ -67,7 +68,12 @@
if (!response.ok) {
throw new Error('Failed to fetch balance');
}
balance = await response.json();
const newBalance = await response.json();
// Force reactivity by creating new object with spread arrays
balance = {
netBalance: newBalance.netBalance || 0,
recentSplits: [...(newBalance.recentSplits || [])]
};
} catch (err) {
error = err.message;
}
@@ -79,7 +85,14 @@
if (!response.ok) {
throw new Error('Failed to fetch debt breakdown');
}
debtData = await response.json();
const newDebtData = await response.json();
// Force reactivity by creating new object with spread arrays
debtData = {
whoOwesMe: [...(newDebtData.whoOwesMe || [])],
whoIOwe: [...(newDebtData.whoIOwe || [])],
totalOwedToMe: newDebtData.totalOwedToMe || 0,
totalIOwe: newDebtData.totalIOwe || 0
};
} catch (err) {
error = err.message;
} finally {
@@ -94,6 +107,12 @@
}).format(Math.abs(amount));
}
// Export refresh method for parent components to call
export async function refresh() {
loading = true;
await Promise.all([fetchBalance(), fetchDebtBreakdown()]);
}
</script>
<div class="balance-cards">