64 lines
1.6 KiB
Text
64 lines
1.6 KiB
Text
package templates
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"git.bronku.xyz/bronku/cake-order-tracker/models"
|
|
)
|
|
|
|
templ CakesPage(cakes []models.Cake, allTags []models.Tag) {
|
|
@Layout("Katalog", CakesMain(cakes, allTags))
|
|
}
|
|
|
|
templ CakesMain(cakes []models.Cake, allTags []models.Tag) {
|
|
<section class="card" id="cakes-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">
|
|
<thead>
|
|
<tr>
|
|
<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 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>
|
|
}
|