feat(dashboard): #82 add chart for sum of account and savings
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 5m21s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 5m33s

This commit was merged in pull request #190.
This commit is contained in:
2025-06-19 13:28:49 +02:00
parent c9bf320611
commit 3120c19669
15 changed files with 248 additions and 174 deletions

View File

@@ -1,53 +1,7 @@
package dashboard
import "spend-sparrow/internal/types"
templ Dashboard(summary *types.DashboardMonthlySummary) {
<div class="mt-10">
<form hx-get="/" hx-target="#dashboard" hx-trigger="change" hx-push-url="true">
<label for="month">Select Month:</label>
<input
name="month"
type="date"
class="input datetime"
value={ summary.Month.String() }
/>
</form>
<div id="dashboard">
@DashboardData(summary)
</div>
templ Dashboard() {
<div class="mt-10 h-full">
<div id="graph" class="h-96"></div>
</div>
}
templ DashboardData(summary *types.DashboardMonthlySummary) {
<div class="mt-10">
<section class="grid grid-cols-[auto_auto_auto_auto_1fr] gap-4">
<span>Savings</span>
<span>Income</span>
<span>Expenses</span>
<span>Total</span>
<span></span>
<span>{ types.FormatEuros(summary.Savings) }</span>
@balance(summary.Income)
@balance(summary.Expenses)
@balance(summary.Total)
</section>
<section class="grid grid-cols-[auto_auto_auto_1fr] gap-4">
<span>Total Savings</span>
<span>Total Account Balance</span>
<span>Net</span>
<span></span>
<span>{ types.FormatEuros(summary.SumOfSavings) }</span>
<span>{ types.FormatEuros(summary.SumOfAccounts) }</span>
@balance(summary.SumOfAccounts - summary.SumOfSavings)
</section>
</div>
}
templ balance(balance int64) {
if balance < 0 {
<span class="text-red-700">{ types.FormatEuros(balance) }</span>
} else {
<span class="text-green-700">{ types.FormatEuros(balance) }</span>
}
}