From 23e2fe956ff6e8a850a27421ab2ec1f6a75664e8 Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Mon, 26 Feb 2024 16:00:29 +0100 Subject: [PATCH] Add a warning on the booking page when payment is using test environment Apparently, the bank has to validate the fucking thing on the actual domain, because of reasons, so we have to replace the current web in production with this version in test mode, meaning that users **will** believe they have paid, when in fact they have not. The warning is for these few people that actually read such notices. --- pkg/booking/public.go | 8 ++++---- po/ca.po | 6 +++++- po/es.po | 6 +++++- po/fr.po | 6 +++++- web/static/public.css | 17 ++++++++++++++--- web/templates/public/booking/page.gohtml | 5 +++++ 6 files changed, 38 insertions(+), 10 deletions(-) diff --git a/pkg/booking/public.go b/pkg/booking/public.go index a563f12..be029fd 100644 --- a/pkg/booking/public.go +++ b/pkg/booking/public.go @@ -56,8 +56,9 @@ func (h *PublicHandler) Handler(user *auth.User, company *auth.Company, conn *da type publicPage struct { *template.PublicPage - Form *bookingForm - HasErrors bool + Form *bookingForm + HasErrors bool + Environment string } func newPublicPage(r *http.Request, company *auth.Company, conn *database.Conn, l *locale.Locale) (*publicPage, error) { @@ -77,8 +78,7 @@ func newPublicPageWithForm(form *bookingForm) *publicPage { func (p *publicPage) MustRender(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn) { p.Setup(r, user, company, conn) - var err error - if err != nil { + if err := conn.QueryRow(r.Context(), "select environment from redsys where company_id = $1", company.ID).Scan(&p.Environment); err != nil && !database.ErrorIsNotFound(err) { panic(err) } if httplib.IsHTMxRequest(r) { diff --git a/po/ca.po b/po/ca.po index 58da615..9f4bf30 100644 --- a/po/ca.po +++ b/po/ca.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: camper\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n" -"POT-Creation-Date: 2024-02-24 19:56+0100\n" +"POT-Creation-Date: 2024-02-26 15:55+0100\n" "PO-Revision-Date: 2024-02-06 10:04+0100\n" "Last-Translator: jordi fita mas \n" "Language-Team: Catalan \n" @@ -649,6 +649,10 @@ msgstr "Núm. \n" "Language-Team: Spanish \n" @@ -649,6 +649,10 @@ msgstr " \n" "Language-Team: French \n" @@ -649,6 +649,10 @@ msgstr "# RTC %s" msgid "Sorry, there was a problem. You’ll find more details highlighted below." msgstr "Il y avait un problème. Vous trouverez plus de détails ci-dessous." +#: web/templates/public/booking/page.gohtml:20 +msgid "Payment is in test mode. You can make the booking regardless, but no money will be charged. We will send you an additional email with instructions on how to perform the payment." +msgstr "Le paiement est en mode test. Malgré tout, vous pouvez effectuer la réservation, mais aucun argent ne sera facturé. Nous vous enverrons un e-mail supplémentaire avec des instructions sur la manière d’effectuer le paiement." + #: web/templates/public/booking/fields.gohtml:14 #: web/templates/admin/payment/details.gohtml:44 msgctxt "title" diff --git a/web/static/public.css b/web/static/public.css index cb44be0..47b968d 100644 --- a/web/static/public.css +++ b/web/static/public.css @@ -103,7 +103,7 @@ html { --accent: #00aa7d; --accent-2: #FFE37F; --accent-3: #9adff4; - --error: #871d1f; + --error: #876e1d; --clar-rgb: 239, 237, 236; --clar: rgb(var(--clar-rgb)); } @@ -1296,16 +1296,27 @@ button[disabled] { color: var(--error); } +.warning { + color: var(--error); +} + input[aria-invalid="true"] { border-color: var(--error); } -.error[role="alert"] { - background-color: #fae0e3; +div[role="alert"] { padding: 1em; margin: 1em 0 2em; } +.error[role="alert"] { + background-color: #fae0e3; +} + +.warning[role="alert"] { + background-color: #faf4e0; +} + /* radio buttins + checkbox */ /* Context for relative positioning */ diff --git a/web/templates/public/booking/page.gohtml b/web/templates/public/booking/page.gohtml index f95526d..4577f67 100644 --- a/web/templates/public/booking/page.gohtml +++ b/web/templates/public/booking/page.gohtml @@ -15,6 +15,11 @@

{{( gettext "Sorry, there was a problem. You’ll find more details highlighted below." )}}

{{- end }} + {{ if eq .Environment "test" }} + + {{- end }}