fixed some typos

This commit is contained in:
bronku 2026-11-08 22:50:03 +01:00
parent ebeb36921a
commit c726cb76f7
5 changed files with 30 additions and 16 deletions

View file

@ -254,3 +254,8 @@
}
}
}
#confirmation {
text-align: center;
min-height: calc(100vh - var(--nav-height));
}

View file

@ -2,10 +2,10 @@ package html
templ Dziekujemy() {
@layout("Dziękujemy"){
<p>Dziękujemy! Numer zamówienia: <b id="order-id"></b>. Potwierdzimy zamówienie telefonicznie.</p>
<p id="confirmation">Dziękujemy! Numer zamówienia: <b id="order-id"></b>.</p>
<script>
const id = new URLSearchParams(location.search).get('order');
if (id) document.getElementById('order-id').textContent = id;
</script>
</script>
}
}

View file

@ -29,7 +29,7 @@ templ Swieta(products []types.Product) {
</div>
</header>
<section>
<h2>Święteczne Słodkości</h2>
<h2>Świąteczne Słodkości</h2>
<div id="wyroby" class="swieta">
for _, product:= range products {
@card(product)
@ -41,22 +41,22 @@ templ Swieta(products []types.Product) {
<div class="card">
<span>ODBIÓR ZAMÓWIEŃ</span>
<h3>24 grudnia (wigilia)</h3>
<p>Wszystkie zamówienia wydajemy w wigilię w Kawiarnii</p>
<p>Wszystkie zamówienia wydajemy w wigilię w Kawiarni</p>
</div>
<div class="card">
<span>ZAMÓWIENIA PRZYJMUJEMY DO</span>
<h3>15 grudnia</h3>
<p>Zamówienia można złożyć telefonicznie <a href="tel:+48690214515">690 214 515</a><br>lub osobiście w kawiarnii</p>
<p>Zamówienia można złożyć telefonicznie <a href="tel:+48690214515">690 214 515</a><br>lub osobiście w kawiarni</p>
</div>
</section>
<section id="order-form">
<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>
<p>Wszystkie zamówienia obejmuje zaliczka o wysokości <b>50zł</b>. </p>
<p>Wszystkie zamówienia obejmuje zaliczka w wysokości <b>50zł</b> niezależnie od wartości zamówienia, minimalna kwota zamówienia wynosi <b>50zł</b></p>
<form method="post" action="/order" hx-post="/order" hx-target="#form-errors" hx-swap="innerHTML" hx-disabled-elt="find button[type=submit]" >
<input name="name" type="text" required placeholder="Imie i Nazwisko"/>
<input name="phone" type="tel" required placeholder="Numer Telefonu"/>
<input name="name" type="text" required placeholder="Imię i Nazwisko"/>
<input name="phone" type="tel" required placeholder="Numer telefonu"/>
<fieldset>
for _, product := range products {
@product_form(product)

View file

@ -38,16 +38,16 @@ func InitStripe(secret string) { stripe.Key = secret }
func parseFloat(input string) (int, error) {
val, err := strconv.ParseFloat(input, 64)
if err != nil {
return 0, fmt.Errorf("Invalid float format")
return 0, fmt.Errorf("Nieprawidłowa wartość")
}
if val < 0 || val > 100 {
return 0, fmt.Errorf("Value must be between 0 and 100")
return 0, fmt.Errorf("Wartość musi być między 0 a 100")
}
doubled := val * 2
if math.Abs(doubled-math.Round(doubled)) > 1e-9 {
return 0, fmt.Errorf("Value must be a multiple of 0.5")
return 0, fmt.Errorf("Wartość musi być wielokrotnością 0,5")
}
return int(math.Round(val * 100)), nil
@ -66,23 +66,32 @@ func parseOrder(r *http.Request) (order, error) {
var errorList []error
o.name = strings.TrimSpace(r.PostFormValue("name"))
if !validName(o.name) {
errorList = append(errorList, fmt.Errorf("Invalid name"))
errorList = append(errorList, fmt.Errorf("Podaj imię i nazwisko"))
}
o.phone, err = parsePhone(r.PostFormValue("phone"))
if err != nil {
errorList = append(errorList, err)
}
total := 0
for _, item := range data.Swieta {
count, err := parseFloat(r.PostFormValue(item.Id))
if err != nil {
errorList = append(errorList, fmt.Errorf("Can't parse the count for %v: %v", item.Name, err))
errorList = append(errorList, fmt.Errorf("Nieprawidłowa ilość dla: %v", item.Name))
continue
}
if count%10 == 5 && !item.Halveable {
errorList = append(errorList, fmt.Errorf("This item can't be bought in fractions %v", item.Name))
errorList = append(errorList, fmt.Errorf("Produktu %v nie można zamówić w ułamkowej ilości", item.Name))
continue
}
o.items = append(o.items, listItem{item.Id, count})
price, err := strconv.Atoi(item.Price)
if err != nil {
continue
}
total += count * price
}
if total < 5000 {
errorList = append(errorList, fmt.Errorf("Minimalna wartość zamówienia wynosi 50zł"))
}
return o, errors.Join(errorList...)
}

View file

@ -46,11 +46,11 @@ func parsePhone(input string) (string, error) {
}
if len(cleaned) != 9 {
return "", fmt.Errorf("invalid length: expected 9 digits, got %d", len(cleaned))
return "", fmt.Errorf("Numer telefonu musi mieć 9 cyfr")
}
if !isValidPolishMobile(cleaned) {
return "", fmt.Errorf("invalid mobile prefix: %s does not match Polish mobile allocations", cleaned[:2])
return "", fmt.Errorf("Nieprawidłowy numer telefonu — podaj polski numer komórkowy")
}
return cleaned, nil