i think form might be ready
This commit is contained in:
parent
7299fe7890
commit
3d817ef503
5 changed files with 24 additions and 15 deletions
|
|
@ -178,7 +178,7 @@
|
|||
background-color: transparent;
|
||||
border: none;
|
||||
text-align: center;
|
||||
width: 2rem;
|
||||
width: 3rem;
|
||||
appearance: textfield;
|
||||
-moz-appearance: textfield;
|
||||
&::-webkit-inner-spin-button,
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ package data
|
|||
import "piekarnikgosipl/types"
|
||||
|
||||
var Swieta = []types.Product{
|
||||
{Name: "Malinowa Chmurka", Image: "", Price: "150", Description: "", Id: "001"},
|
||||
{Name: "Makosernik", Image: "", Price: "150", Description: "", Id: "002"},
|
||||
{Name: "Rolada Makowa", Image: "", Price: "100", Description: "", Id: "003"},
|
||||
{Name: "Wieniec Bezowy", Image: "", Price: "150", Description: "⌀ 25cm", Id: "004"},
|
||||
{Name: "Torcik Piernikowy z kremem Cynamonowym", Image: "", Price: "120", Description: "⌀ 18cm", Id: "005"},
|
||||
{Name: "Sernik Ulubiony", Image: "", Price: "75", Description: "⌀ 21cm", Id: "006"},
|
||||
{Name: "Sernik Lotus", Image: "", Price: "100", Description: "⌀ 22cm", Id: "007"},
|
||||
{Name: "Sernik Mango-Jogurt", Image: "", Price: "120", Description: "⌀ 22cm", Id: "008"},
|
||||
{Name: "Malinowa Chmurka", Image: "", Price: "150", Description: "", Id: "001", Halveable: true},
|
||||
{Name: "Makosernik", Image: "", Price: "150", Description: "", Id: "002", Halveable: true},
|
||||
{Name: "Rolada Makowa", Image: "", Price: "100", Description: "", Id: "003", Halveable: true},
|
||||
{Name: "Wieniec Bezowy", Image: "", Price: "150", Description: "⌀ 25cm", Id: "004", Halveable: true},
|
||||
{Name: "Torcik Piernikowy z kremem Cynamonowym", Image: "", Price: "120", Description: "⌀ 18cm", Id: "005", Halveable: true},
|
||||
{Name: "Sernik Ulubiony", Image: "", Price: "75", Description: "⌀ 21cm", Id: "006", Halveable: true},
|
||||
{Name: "Sernik Lotus", Image: "", Price: "100", Description: "⌀ 22cm", Id: "007", Halveable: true},
|
||||
{Name: "Sernik Mango-Jogurt", Image: "", Price: "120", Description: "⌀ 22cm", Id: "008", Halveable: true},
|
||||
{Name: "Mini Pavlova", Image: "", Price: "12", Description: "", Id: "009"},
|
||||
{Name: "Box Świąteczny", Image: "", Price: "150", Description: "¼ Sernik Cynamonowy\n¼ Sernik Nowojorski\n¼ Kostka Piernikowa z kremem Malaga i Powidłami\n¼ Kostka Świętego Mikołaja", Id: "010"},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ function min(a, b) {
|
|||
}
|
||||
function increase(id) {
|
||||
input = document.getElementById(id)
|
||||
input.value= min(parseInt(input.value)+1, 0)
|
||||
step = parseFloat(input.step)
|
||||
input.value= min(parseFloat(input.value)+step, 0)
|
||||
}
|
||||
function decrease(id) {
|
||||
input = document.getElementById(id)
|
||||
input.value= min(parseInt(input.value)-1, 0)
|
||||
step = parseFloat(input.step)
|
||||
input.value= min(parseFloat(input.value)-step, 0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,4 +6,5 @@ type Product struct {
|
|||
Price string
|
||||
Description string
|
||||
Id string
|
||||
Halveable bool
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue