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 { customerGetCustomer } from "#openapi";
|
||||
|
||||
interface CounterConfig {
|
||||
csrfToken: string;
|
||||
@ -33,19 +32,13 @@ exportToHtml("loadCounter", (config: CounterConfig) => {
|
||||
return total / 100;
|
||||
},
|
||||
|
||||
async updateBalance() {
|
||||
this.customerBalance = (
|
||||
await customerGetCustomer({
|
||||
path: {
|
||||
// biome-ignore lint/style/useNamingConvention: api is in snake_case
|
||||
customer_id: config.customerId,
|
||||
},
|
||||
})
|
||||
).data.amount;
|
||||
},
|
||||
|
||||
async onRefillingSuccess() {
|
||||
await this.updateBalance();
|
||||
onRefillingSuccess(event: CustomEvent) {
|
||||
if (event.type !== "htmx:after-request" || event.detail.failed) {
|
||||
return;
|
||||
}
|
||||
this.customerBalance += Number.parseFloat(
|
||||
(event.detail.target.querySelector("#id_amount") as HTMLInputElement).value,
|
||||
);
|
||||
document.getElementById("selling-accordion").click();
|
||||
},
|
||||
|
||||
|
@ -103,7 +103,7 @@
|
||||
{% if refilling_fragment %}
|
||||
<h5>{% trans %}Refilling{% endtrans %}</h5>
|
||||
<div
|
||||
@htmx:after-request="onRefillingSuccess()"
|
||||
@htmx:after-request="onRefillingSuccess"
|
||||
>
|
||||
{{ refilling_fragment }}
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user