more simpler + torty sectino

This commit is contained in:
bronkuu 2026-06-15 20:30:15 +02:00
parent a74c276cd3
commit 3b184c7c6f
10 changed files with 375 additions and 152 deletions

View file

@ -6,8 +6,8 @@ import (
"git.bronku.xyz/bronku/cake-order-tracker/models"
)
templ OrdersPage(first, last, today, tomorrow, special string, counts models.OrderCounts, cakeCounts []models.CakeCount, orders []models.Order) {
@Layout("Panel główny", OrdersMain(counts, cakeCounts, orders, first, last, special, today, tomorrow))
templ OrdersPage(first, last, today, tomorrow, special string, counts models.OrderCounts, cakeCounts []models.CakeCount, specialCakes []models.SpecialCakeWithOrder, orders []models.Order) {
@Layout("Panel główny", OrdersMain(counts, cakeCounts, orders, specialCakes, first, last, special, today, tomorrow))
}
templ DateForm(first, last, today, tomorrow, special string) {
@ -27,7 +27,7 @@ templ DateForm(first, last, today, tomorrow, special string) {
</div>
}
templ OrdersMain(counts models.OrderCounts, cakeCounts []models.CakeCount, orders []models.Order, first, last, special, today, tomorrow string) {
templ OrdersMain(counts models.OrderCounts, cakeCounts []models.CakeCount, orders []models.Order, specialCakes []models.SpecialCakeWithOrder, first, last, special, today, tomorrow string) {
@DateForm(first, last, today, tomorrow, special)
<div class="metric">
<span class="label">
@ -46,11 +46,12 @@ templ OrdersMain(counts models.OrderCounts, cakeCounts []models.CakeCount, order
<span class="change">Do zrobienia</span>
</div>
<div id="orders-results">
@OrdersContent(orders, cakeCounts, first, last, special)
@OrdersContent(orders, cakeCounts, specialCakes, first, last, special)
</div>
@SpecialCakeViewOverlay()
}
templ OrdersContent(orders []models.Order, cakeCounts []models.CakeCount, first, last, special string) {
templ OrdersContent(orders []models.Order, cakeCounts []models.CakeCount, specialCakes []models.SpecialCakeWithOrder, first, last, special string) {
<section class="card" id="orders-card">
<header>
<h2>
@ -90,6 +91,7 @@ templ OrdersContent(orders []models.Order, cakeCounts []models.CakeCount, first,
</table>
</section>
@CakeBreakdown(cakeCounts)
@SpecialCakesTable(specialCakes)
}
templ OrderRow(order models.Order) {
@ -156,6 +158,125 @@ templ OrderRow(order models.Order) {
</tr>
}
templ SpecialCakesTable(specialCakes []models.SpecialCakeWithOrder) {
<section class="card" id="special-cakes-card">
<header>
<h2>
<span class="material-symbols-outlined">cake</span>
Torty specjalne
</h2>
</header>
<table class="data-table">
<thead>
<tr>
<th>Nazwa</th>
<th>Klient</th>
<th>Data odbioru</th>
<th class="text-right">Cena</th>
<th class="text-center"></th>
</tr>
</thead>
<tbody>
for _, sc := range specialCakes {
<tr data-sc-id={ strconv.Itoa(sc.ID) }
data-sc-name={ sc.Name }
data-sc-price={ sc.Price.String() }
data-sc-size={ sc.Size }
data-sc-shape={ sc.Shape }
data-sc-flavour={ sc.Flavour }
data-sc-notes={ sc.Notes }
data-sc-tags={ tagNames(sc.Tags) }
data-sc-order-id={ strconv.Itoa(sc.OrderID) }
data-sc-client={ sc.ClientName + " " + sc.ClientSurname }
data-sc-date={ sc.OrderDate.Format("2006-01-02") }>
<td>
<button type="button" class="link-btn" onclick="viewSpecialCake(this)">{ sc.Name }</button>
</td>
<td>{ sc.ClientName } { sc.ClientSurname }</td>
<td class="text-muted">{ sc.OrderDate.Format("2006-01-02") }</td>
<td class="text-right">{ sc.Price.String() } PLN</td>
<td class="text-center">
<a href={ templ.URL("/order/" + strconv.Itoa(sc.OrderID)) } class="btn-icon" title="Zobacz zamówienie">
<span class="material-symbols-outlined">receipt_long</span>
</a>
</td>
</tr>
}
if len(specialCakes) == 0 {
<tr>
<td colspan="5" class="empty-state">Brak tortów specjalnych w tym okresie</td>
</tr>
}
</tbody>
</table>
</section>
}
templ SpecialCakeViewOverlay() {
<div id="sc-view-overlay" class="overlay">
<div class="overlay-backdrop" onclick="closeViewSpecialCake()"></div>
<div class="overlay-panel overlay-panel--view">
<header>
<h2>
<span class="material-symbols-outlined">cake</span>
<span id="sc-view-title">Tort specjalny</span>
</h2>
<button type="button" class="close-btn" onclick="closeViewSpecialCake()">
<span class="material-symbols-outlined">close</span>
</button>
</header>
<div class="overlay-body">
<div class="view-field">
<label>Nazwa</label>
<span id="sc-view-name"></span>
</div>
<div class="view-field">
<label>Cena</label>
<span id="sc-view-price"></span>
</div>
<div class="view-field">
<label>Wielkość</label>
<span id="sc-view-size"></span>
</div>
<div class="view-field">
<label>Kształt</label>
<span id="sc-view-shape"></span>
</div>
<div class="view-field">
<label>Smak</label>
<span id="sc-view-flavour"></span>
</div>
<div class="view-field">
<label>Notatki</label>
<span id="sc-view-notes"></span>
</div>
<div class="view-field" id="sc-view-tags-field">
<label>Tagi</label>
<div id="sc-view-tags"></div>
</div>
<div class="view-field">
<label>Klient</label>
<span id="sc-view-client"></span>
</div>
<div class="view-field">
<label>Data odbioru</label>
<span id="sc-view-date"></span>
</div>
</div>
<footer>
<a href="" id="sc-view-order-link" class="btn btn-outline">
<span class="material-symbols-outlined">receipt_long</span>
Zobacz zamówienie
</a>
<button type="button" class="btn btn-primary" onclick="closeViewSpecialCake()">
<span class="material-symbols-outlined">close</span>
Zamknij
</button>
</footer>
</div>
</div>
}
templ CakeBreakdown(cakeCounts []models.CakeCount) {
<section class="card" id="breakdown-card">
<header>