diff --git a/css/swieta.css b/css/swieta.css index e27f0d4..2bd879c 100644 --- a/css/swieta.css +++ b/css/swieta.css @@ -254,3 +254,8 @@ } } } + +#confirmation { + text-align: center; + min-height: calc(100vh - var(--nav-height)); +} diff --git a/html/dziekujemy.templ b/html/dziekujemy.templ index 7dba249..82c20ca 100644 --- a/html/dziekujemy.templ +++ b/html/dziekujemy.templ @@ -2,10 +2,10 @@ package html templ Dziekujemy() { @layout("Dziękujemy"){ -

Dziękujemy! Numer zamówienia: . Potwierdzimy zamówienie telefonicznie.

+

Dziękujemy! Numer zamówienia: .

+ } } diff --git a/html/swieta.templ b/html/swieta.templ index dd4f0bd..04016d8 100644 --- a/html/swieta.templ +++ b/html/swieta.templ @@ -29,7 +29,7 @@ templ Swieta(products []types.Product) {
-

Święteczne Słodkości

+

Świąteczne Słodkości

for _, product:= range products { @card(product) @@ -41,22 +41,22 @@ templ Swieta(products []types.Product) {
ODBIÓR ZAMÓWIEŃ

24 grudnia (wigilia)

-

Wszystkie zamówienia wydajemy w wigilię w Kawiarnii

+

Wszystkie zamówienia wydajemy w wigilię w Kawiarni

ZAMÓWIENIA PRZYJMUJEMY DO

15 grudnia

-

Zamówienia można złożyć telefonicznie 690 214 515
lub osobiście w kawiarnii

+

Zamówienia można złożyć telefonicznie 690 214 515
lub osobiście w kawiarni

Złóż zamówienie

Odbiór wszystkich zamówień: 24 grudnia. Zamówienia przyjmujemy do 15 grudnia. Potwierdzimy zamówienie telefonicznie.

-

Wszystkie zamówienia obejmuje zaliczka o wysokości 50zł.

+

Wszystkie zamówienia obejmuje zaliczka w wysokości 50zł niezależnie od wartości zamówienia, minimalna kwota zamówienia wynosi 50zł

- - + +
for _, product := range products { @product_form(product) diff --git a/orders/order.go b/orders/order.go index 636fba1..7744509 100644 --- a/orders/order.go +++ b/orders/order.go @@ -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...) } diff --git a/orders/phone_validation.go b/orders/phone_validation.go index ed6bbb1..df8ea3c 100644 --- a/orders/phone_validation.go +++ b/orders/phone_validation.go @@ -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