i think form might be ready

This commit is contained in:
bronku 2026-11-08 16:13:13 +01:00
parent 7299fe7890
commit 3d817ef503
5 changed files with 24 additions and 15 deletions

View file

@ -2,11 +2,17 @@ package html
import "piekarnikgosipl/types"
func step(in types.Product ) string {
if in.Halveable {
return "0.5"
}
return "1"
}
templ product_form(product types.Product) {
<div>
<span>{product.Name} <span> · {product.Price} zł</span></span>
<button type="button" onClick={templ.JSFuncCall("decrease", product.Id)}> - </button>
<input id={product.Id} value="0" type="number" min="0" max="100"/>
<input name={product.Id} id={product.Id} value="0" type="number" step={step(product)} min="0" max="100"/>
<button type="button" onClick={templ.JSFuncCall("increase", product.Id)}> + </button>
</div>
}
@ -47,14 +53,14 @@ templ Swieta(products []types.Product) {
<div>
<h2>Złóż zamówienie</h2>
<p>Odbiór wszystkich zamówień: <b>24 grudnia</b>. Zamówienia przyjmujemy do <b>15 grudnia</b>. Potwierdzimy zamówienie telefonicznie.</p>
<form>
<form method="post" action="/order" >
<fieldset>
for _, product := range products {
@product_form(product)
}
</fieldset>
<input type="text" required placeholder="Imie i Nazwisko"/>
<input type="tel" required placeholder="Numer Telefonu"/>
<input name="name" type="text" required placeholder="Imie i Nazwisko"/>
<input name="phone" type="tel" required placeholder="Numer Telefonu"/>
<button type="submit">Wyślij zamówienie</button>
</form>
</div>