feat(weeztix): add button to refresh coupon list from API
Made-with: Cursor
This commit is contained in:
@@ -779,6 +779,7 @@ document.addEventListener('alpine:init', () => {
|
|||||||
couponName: '',
|
couponName: '',
|
||||||
codePrefix: 'PREREG',
|
codePrefix: 'PREREG',
|
||||||
usageCount: 1,
|
usageCount: 1,
|
||||||
|
couponsRefreshing: false,
|
||||||
strings: cfg.strings || {},
|
strings: cfg.strings || {},
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
@@ -853,6 +854,18 @@ document.addEventListener('alpine:init', () => {
|
|||||||
this.ensureSelectedCouponInList();
|
this.ensureSelectedCouponInList();
|
||||||
this.syncCouponName();
|
this.syncCouponName();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async refreshCoupons() {
|
||||||
|
if (!this.isConnected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.couponsRefreshing = true;
|
||||||
|
try {
|
||||||
|
await this.loadCoupons();
|
||||||
|
} finally {
|
||||||
|
this.couponsRefreshing = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,9 @@
|
|||||||
'strings' => [
|
'strings' => [
|
||||||
'genericError' => __('Er ging iets mis. Probeer het opnieuw.'),
|
'genericError' => __('Er ging iets mis. Probeer het opnieuw.'),
|
||||||
'loadCouponsError' => __('Kon kortingsbonnen niet laden.'),
|
'loadCouponsError' => __('Kon kortingsbonnen niet laden.'),
|
||||||
|
'refreshCoupons' => __('Vernieuwen'),
|
||||||
|
'refreshCouponsBusy' => __('Bezig…'),
|
||||||
|
'refreshCouponsTitle' => __('Couponlijst opnieuw ophalen van Weeztix'),
|
||||||
],
|
],
|
||||||
]))"
|
]))"
|
||||||
>
|
>
|
||||||
@@ -165,7 +168,22 @@
|
|||||||
@method('PUT')
|
@method('PUT')
|
||||||
|
|
||||||
<div>
|
<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
|
<select
|
||||||
id="weeztix_coupon"
|
id="weeztix_coupon"
|
||||||
name="coupon_guid"
|
name="coupon_guid"
|
||||||
|
|||||||
Reference in New Issue
Block a user