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

53 lines
1.4 KiB
Text

package templates
import (
"strconv"
"git.bronku.xyz/bronku/cake-order-tracker/models"
)
templ CakePage(cake models.Cake, allTags []models.Tag) {
@Layout(CakeTitle(cake), templ.NopComponent, CakeForm(cake, allTags))
}
templ CakeForm(cake models.Cake, allTags []models.Tag) {
<div class="card card-sm">
<header>
<h2>
<span class="material-symbols-outlined">cake</span>
if cake.ID != 0 {
Edytuj ciasto #{ strconv.Itoa(cake.ID) }
} else {
Nowe ciasto
}
</h2>
</header>
<form method="post">
<input type="hidden" name="id" value={ strconv.Itoa(cake.ID) }/>
<label>Nazwa *</label>
<input type="text" name="name" value={ cake.Name } placeholder="Nazwa ciasta"/>
<label>Cena</label>
<input type="number" name="price" min="0" value={ cake.Price.String() }/>
<label>Tagi</label>
<div class="tag-grid">
for _, t := range allTags {
<label class="tag-chip">
<input type="checkbox" name="tag" value={ strconv.Itoa(t.ID) } class="hidden"
if cakeHasTag(cake.Tags, t.ID) { checked }/>
{ t.Name }
</label>
}
</div>
<div class="horizontal-group">
<input type="text" name="new_tag" placeholder="Nowy tag..."/>
</div>
<div class="form-actions">
<a href="/cakes" class="btn btn-outline">Anuluj</a>
<button type="submit" class="btn btn-primary">
<span class="material-symbols-outlined">save</span>
Zapisz ciasto
</button>
</div>
</form>
</div>
}