154 lines
5.5 KiB
Text
154 lines
5.5 KiB
Text
package templates
|
||
|
||
import (
|
||
"strconv"
|
||
|
||
"git.bronku.xyz/bronku/cake-order-tracker/models"
|
||
)
|
||
|
||
templ OrderPage(order models.Order, catalogue []models.Cake) {
|
||
@Layout(orderTitle(order), OrderForm(order, catalogue))
|
||
}
|
||
|
||
templ OrderForm(order models.Order, catalogue []models.Cake) {
|
||
<form method="post" class="split-pane" style="flex:1;min-height:0">
|
||
<input type="hidden" name="id" value={ strconv.Itoa(order.ID) }/>
|
||
<div style="flex:1;display:flex;flex-direction:column;gap:1rem;min-width:0">
|
||
<section class="card">
|
||
<header>
|
||
<h2>
|
||
<span class="material-symbols-outlined">person_add</span>
|
||
Dane klienta
|
||
</h2>
|
||
</header>
|
||
<div>
|
||
<div class="form-grid">
|
||
<div class="form-group">
|
||
<label>Imię *</label>
|
||
<input class="form-input" type="text" name="name" value={ order.Name } placeholder="Jan"/>
|
||
</div>
|
||
<div class="form-group">
|
||
<label>Nazwisko *</label>
|
||
<input class="form-input" type="text" name="surname" value={ order.Surname } placeholder="Kowalski"/>
|
||
</div>
|
||
<div class="form-group">
|
||
<label>Telefon</label>
|
||
<input class="form-input" type="tel" name="phone" value={ order.Phone } placeholder="+48 123 456 789"/>
|
||
</div>
|
||
<div class="form-group">
|
||
<label>Lokalizacja</label>
|
||
<select class="form-input" name="location">
|
||
<option
|
||
if order.Location == "Kartuzy" {
|
||
selected
|
||
}
|
||
value="Kartuzy"
|
||
>Kartuzy</option>
|
||
<option
|
||
if order.Location == "Somonino" {
|
||
selected
|
||
}
|
||
value="Somonino"
|
||
>Somonino</option>
|
||
</select>
|
||
</div>
|
||
<div class="form-group">
|
||
<label>Data dostawy *</label>
|
||
<input class="form-input" type="date" name="date" value={ order.Date.Format("2006-01-02") }/>
|
||
</div>
|
||
<div class="form-group">
|
||
<label>Zaliczka</label>
|
||
<input class="form-input" type="number" name="paid" min="0" step="0.01" value={ order.Paid.String() }/>
|
||
</div>
|
||
<div class="form-group" style="grid-column:span 2">
|
||
<label>Uwagi</label>
|
||
<input class="form-input" type="text" placeholder="Alergie, specjalne życzenia..."/>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
<section class="card" style="flex:1;min-height:12.5rem">
|
||
<header>
|
||
<h2>
|
||
<span class="material-symbols-outlined">inventory_2</span>
|
||
Katalog produktów
|
||
</h2>
|
||
<div style="position:relative;width:11.25rem">
|
||
<span class="material-symbols-outlined" style="position:absolute;left:0.5rem;top:50%;transform:translateY(-50%);font-size:1rem;color:var(--on-surface-variant);pointer-events:none">search</span>
|
||
<input class="form-input" style="height:1.75rem;padding-left:1.75rem;font-size:0.75rem" type="text" placeholder="Filtruj produkty..." oninput="filterCatalogue(this)"/>
|
||
</div>
|
||
</header>
|
||
<div style="overflow-y:auto;padding:1rem">
|
||
<ul id="catalogue-grid">
|
||
for _, c := range catalogue {
|
||
<li data-name={ c.Name }>
|
||
<div>
|
||
<div class="icon cake">
|
||
<span class="material-symbols-outlined" style="font-size:1rem">cake</span>
|
||
</div>
|
||
<div style="min-width:0">
|
||
<div class="name">{ c.Name }</div>
|
||
<div class="price">{ c.Price.String() } PLN</div>
|
||
</div>
|
||
</div>
|
||
<div class="actions">
|
||
<button type="button" class="qty minus" onclick={ templ.JSFuncCall("changeCake", c.ID, c.Name, c.Price, -1) }>
|
||
<span class="material-symbols-outlined">remove</span>
|
||
</button>
|
||
<span class="value" id={ "qty-" + strconv.Itoa(c.ID) }>0</span>
|
||
<button type="button" class="qty plus" onclick={ templ.JSFuncCall("changeCake", c.ID, c.Name, c.Price, 1) }>
|
||
<span class="material-symbols-outlined">add</span>
|
||
</button>
|
||
</div>
|
||
</li>
|
||
}
|
||
</ul>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
<aside style="width:20rem;flex-shrink:0;display:flex;flex-direction:column">
|
||
<section class="card" style="flex:1;display:flex;flex-direction:column">
|
||
<header>
|
||
<h2>
|
||
<span class="material-symbols-outlined">receipt_long</span>
|
||
Podsumowanie
|
||
</h2>
|
||
</header>
|
||
<ul id="basket-items">
|
||
for _, c := range order.Cakes {
|
||
<li data-cake-id={ strconv.Itoa(c.ID) }>
|
||
<div style="flex:1;min-width:0;padding-right:0.5rem">
|
||
<div class="name">{ c.Name }</div>
|
||
<div class="detail">{ c.Price.String() } PLN × <span class="qty">{ strconv.Itoa(c.Amount) }</span></div>
|
||
</div>
|
||
<div class="price">{ c.Total().String() } PLN</div>
|
||
<button type="button" class="remove" onclick="removeCake(this)">
|
||
<span class="material-symbols-outlined">close</span>
|
||
</button>
|
||
<input type="hidden" name={ "cake[" + strconv.Itoa(c.ID) + "]" } value={ strconv.Itoa(c.Amount) }/>
|
||
</li>
|
||
}
|
||
</ul>
|
||
<div class="summary-totals">
|
||
<div class="total-row">
|
||
<span>Subtotal</span>
|
||
<span id="subtotal-price">{ order.Subtotal().String() } PLN</span>
|
||
</div>
|
||
<div class="total-row">
|
||
<span>Zaliczka</span>
|
||
<span id="paid-amount">{ order.Paid.String() } PLN</span>
|
||
</div>
|
||
<div class="total-row grand">
|
||
<span>Do zapłaty</span>
|
||
<span id="total-price">{ order.Total().String() } PLN</span>
|
||
</div>
|
||
<button type="submit" class="btn-finalize">
|
||
<span class="material-symbols-outlined">check_circle</span>
|
||
Finalizuj zamówienie
|
||
</button>
|
||
</div>
|
||
</section>
|
||
</aside>
|
||
</form>
|
||
@templ.Raw(orderScript(order))
|
||
}
|