feat(weeztix): add button to refresh coupon list from API

Made-with: Cursor
This commit is contained in:
2026-04-05 10:59:46 +02:00
parent 6561bda30d
commit 55434ce086
2 changed files with 32 additions and 1 deletions

View File

@@ -779,6 +779,7 @@ document.addEventListener('alpine:init', () => {
couponName: '',
codePrefix: 'PREREG',
usageCount: 1,
couponsRefreshing: false,
strings: cfg.strings || {},
async init() {
@@ -853,6 +854,18 @@ document.addEventListener('alpine:init', () => {
this.ensureSelectedCouponInList();
this.syncCouponName();
},
async refreshCoupons() {
if (!this.isConnected) {
return;
}
this.couponsRefreshing = true;
try {
await this.loadCoupons();
} finally {
this.couponsRefreshing = false;
}
},
}));
});

View File

@@ -31,6 +31,9 @@
'strings' => [
'genericError' => __('Er ging iets mis. Probeer het opnieuw.'),
'loadCouponsError' => __('Kon kortingsbonnen niet laden.'),
'refreshCoupons' => __('Vernieuwen'),
'refreshCouponsBusy' => __('Bezig…'),
'refreshCouponsTitle' => __('Couponlijst opnieuw ophalen van Weeztix'),
],
]))"
>
@@ -165,7 +168,22 @@
@method('PUT')
<div>
<label for="weeztix_coupon" class="block text-sm font-medium text-slate-700">{{ __('Coupon (kortingssjabloon)') }}</label>
<div class="flex flex-wrap items-end justify-between gap-2">
<label for="weeztix_coupon" class="block text-sm font-medium text-slate-700">{{ __('Coupon (kortingssjabloon)') }}</label>
<button
type="button"
x-show="isConnected"
x-cloak
@click="refreshCoupons()"
:disabled="couponsRefreshing"
:aria-busy="couponsRefreshing"
:title="strings.refreshCouponsTitle"
class="shrink-0 rounded-md border border-slate-300 bg-white px-2.5 py-1 text-xs font-medium text-slate-700 shadow-sm hover:bg-slate-50 disabled:cursor-not-allowed disabled:opacity-50"
>
<span x-show="!couponsRefreshing" x-text="strings.refreshCoupons"></span>
<span x-show="couponsRefreshing" x-cloak x-text="strings.refreshCouponsBusy"></span>
</button>
</div>
<select
id="weeztix_coupon"
name="coupon_guid"