diff --git a/counter/static/bundled/counter/counter-click-index.ts b/counter/static/bundled/counter/counter-click-index.ts index e736857d..a9294660 100644 --- a/counter/static/bundled/counter/counter-click-index.ts +++ b/counter/static/bundled/counter/counter-click-index.ts @@ -6,6 +6,7 @@ interface InitialFormData { /* Used to refill the form when the backend raises an error */ id?: string; quantity?: number; + errors?: string[]; } interface CounterConfig { @@ -28,10 +29,12 @@ interface Product { class BasketItem { quantity: number; product: Product; + errors: string[]; constructor(product: Product, quantity: number) { this.quantity = quantity; this.product = product; + this.errors = []; } getBonusQuantity(): number { @@ -59,6 +62,7 @@ exportToHtml("loadCounter", (config: CounterConfig) => { for (const entry of config.formInitial) { if (entry.id !== undefined && entry.quantity !== undefined) { this.addToBasket(entry.id, entry.quantity); + this.basket[entry.id].errors = entry.errors ?? []; } } diff --git a/counter/templates/counter/counter_click.jinja b/counter/templates/counter/counter_click.jinja index 35249b33..132f395c 100644 --- a/counter/templates/counter/counter_click.jinja +++ b/counter/templates/counter/counter_click.jinja @@ -72,20 +72,24 @@ - + {% endfor %}

{% trans %}Basket: {% endtrans %}

{% csrf_token %} - {{ form.errors }} - {{ form.non_form_errors() }}
{{ form.management_form }}