Don't use API to update amount after a refilling query

This commit is contained in:
Antoine Bartuccio 2024-12-17 00:45:51 +01:00
parent 379527cd58
commit 66e5ef64fd
2 changed files with 8 additions and 15 deletions

View File

@ -1,5 +1,4 @@
import { exportToHtml } from "#core:utils/globals"; import { exportToHtml } from "#core:utils/globals";
import { customerGetCustomer } from "#openapi";
interface CounterConfig { interface CounterConfig {
csrfToken: string; csrfToken: string;
@ -33,19 +32,13 @@ exportToHtml("loadCounter", (config: CounterConfig) => {
return total / 100; return total / 100;
}, },
async updateBalance() { onRefillingSuccess(event: CustomEvent) {
this.customerBalance = ( if (event.type !== "htmx:after-request" || event.detail.failed) {
await customerGetCustomer({ return;
path: { }
// biome-ignore lint/style/useNamingConvention: api is in snake_case this.customerBalance += Number.parseFloat(
customer_id: config.customerId, (event.detail.target.querySelector("#id_amount") as HTMLInputElement).value,
}, );
})
).data.amount;
},
async onRefillingSuccess() {
await this.updateBalance();
document.getElementById("selling-accordion").click(); document.getElementById("selling-accordion").click();
}, },

View File

@ -103,7 +103,7 @@
{% if refilling_fragment %} {% if refilling_fragment %}
<h5>{% trans %}Refilling{% endtrans %}</h5> <h5>{% trans %}Refilling{% endtrans %}</h5>
<div <div
@htmx:after-request="onRefillingSuccess()" @htmx:after-request="onRefillingSuccess"
> >
{{ refilling_fragment }} {{ refilling_fragment }}
</div> </div>