feat(dashboard): #163 first summary
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 5m11s
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 5m6s

This commit was merged in pull request #181.
This commit is contained in:
2025-06-08 15:35:21 +02:00
parent 935019c1c4
commit 6b8059889d
15 changed files with 280 additions and 67 deletions

View File

@@ -0,0 +1,44 @@
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"
value={ summary.Month.String() }
/>
</form>
<div id="dashboard">
@DashboardData(summary)
</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>
</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>
}
}