mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 07:41:14 +00:00
Don't use API to update amount after a refilling query
This commit is contained in:
parent
379527cd58
commit
66e5ef64fd
@ -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();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user