cake-order-tracker/server/templates/cakes.templ
2026-06-15 19:33:39 +02:00

70 lines
1.8 KiB
Text

package templates
import (
"strconv"
"git.bronku.xyz/bronku/cake-order-tracker/models"
)
templ CakesPage(cakes []models.Cake, allTags []models.Tag) {
@Layout("Katalog", templ.NopComponent, CakesMain(cakes, allTags))
}
templ CakesMain(cakes []models.Cake, allTags []models.Tag) {
<section class="card">
<header>
<h2>
<span class="material-symbols-outlined">inventory_2</span>
Zarządzanie katalogiem
</h2>
<a href="/cake" class="btn btn-primary btn-sm">
<span class="material-symbols-outlined">add</span>
Nowe ciasto
</a>
</header>
if len(allTags) > 0 {
<div class="filter-bar">
<span class="filter-label">Tagi:</span>
for _, t := range allTags {
<button type="button" class="tag-chip" data-tag={ t.Name } onclick="toggleCakeTagFilter(this)">{ t.Name }</button>
}
</div>
}
<table class="data-table" id="cakes-table">
<thead>
<tr>
<th></th>
<th>Nazwa</th>
<th>SKU</th>
<th>Tagi</th>
<th class="text-right">Cena bazowa</th>
<th class="text-center"></th>
</tr>
</thead>
<tbody>
for _, c := range cakes {
<tr data-tags={ tagNames(c.Tags) }>
<td>
<div class="icon cake">
<span class="material-symbols-outlined">cake</span>
</div>
</td>
<td class="font-medium">{ c.Name }</td>
<td class="text-muted">#{ strconv.Itoa(c.ID) }</td>
<td>
for _, t := range c.Tags {
<span class="tag-chip">{ t.Name }</span>
}
</td>
<td class="text-right">{ c.Price.String() } PLN</td>
<td class="text-center">
<a href={ templ.URL("/cake/" + strconv.Itoa(c.ID)) } class="btn-icon">
<span class="material-symbols-outlined">edit</span>
</a>
</td>
</tr>
}
</tbody>
</table>
</section>
}