package pages import ( "fmt" "tankstopp/internal/models" "tankstopp/internal/views/components" ) templ DashboardPage(user *models.User, username string, stops []models.FuelStop, vehicles []models.Vehicle, totalStops int, totalCost float64, avgConsumption float64, lastFillUp *models.FuelStop) { @components.BaseLayout("Dashboard", user, username) { @components.PageHeader("Overview", "Dashboard")
| Date | Vehicle | Location | Fuel Type | Amount | Price/L | Total | Trip Length | Consumption | Odometer | Actions |
|---|---|---|---|---|---|---|---|---|---|---|
|
{ stop.Date.Format("Jan 2, 2006") }
{ stop.Date.Format("15:04") }
|
{ stop.Vehicle.Name }
if stop.Vehicle.LicensePlate != "" {
{ stop.Vehicle.LicensePlate }
}
|
@components.Icon("location", 24)
{ stop.Location }
|
{ stop.FuelType } |
{ fmt.Sprintf("%.2f L", stop.Liters) }
|
{ fmt.Sprintf("%.3f %s", stop.PricePerL, currency) }
|
{ fmt.Sprintf("%.2f %s", stop.TotalPrice, currency) }
|
if stop.TripLength > 0 {
{ fmt.Sprintf("%.1f km", stop.TripLength) }
} else {
Not recorded
}
|
if stop.TripLength > 0 {
{ fmt.Sprintf("%.1f L/100km", (stop.Liters/stop.TripLength)*100) }
} else {
N/A
}
|
if stop.Odometer > 0 {
{ fmt.Sprintf("%d km", stop.Odometer) }
} else {
Not recorded
}
|
@components.ButtonGroup() { @components.EditButton(fmt.Sprintf("/edit/%d", stop.ID)) @components.DeleteButton(fmt.Sprintf("/delete/%d", stop.ID), fmt.Sprintf("fuel stop from %s", stop.Date.Format("Jan 2, 2006"))) } |