From 759588aef1cd9215a536da39c174374d4afeaffd Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 20 Jul 2026 19:50:34 +0200 Subject: [PATCH] Bugfix/copy coupon code to clipboard (#7386) Improve copy coupon code to clipboard --- .../admin-overview.component.ts | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/apps/client/src/app/components/admin-overview/admin-overview.component.ts b/apps/client/src/app/components/admin-overview/admin-overview.component.ts index 62bc78df1..0bed8111f 100644 --- a/apps/client/src/app/components/admin-overview/admin-overview.component.ts +++ b/apps/client/src/app/components/admin-overview/admin-overview.component.ts @@ -213,9 +213,16 @@ export class GfAdminOverviewComponent implements OnInit { duration: this.couponDuration }; + const hasCopiedCouponCode = this.clipboard.copy(newCoupon.code); + const coupons = [...this.couponsDataSource.data, newCoupon]; - this.saveCoupons({ coupons, codeToCopy: newCoupon.code }); + this.saveCoupons({ + coupons, + snackBarMessage: hasCopiedCouponCode + ? '✅ ' + $localize`${newCoupon.code} has been copied to the clipboard` + : '✅ ' + $localize`Coupon ${newCoupon.code} has been created` + }); } protected onChangeCouponDuration(aCouponDuration: StringValue) { @@ -374,11 +381,11 @@ export class GfAdminOverviewComponent implements OnInit { } private saveCoupons({ - codeToCopy, - coupons + coupons, + snackBarMessage }: { - codeToCopy?: string; coupons: Coupon[]; + snackBarMessage?: string; }) { this.dataService .putAdminSetting(PROPERTY_COUPONS, { @@ -388,14 +395,10 @@ export class GfAdminOverviewComponent implements OnInit { .subscribe(() => { this.couponsDataSource.data = coupons; - if (codeToCopy) { - this.clipboard.copy(codeToCopy); - - this.snackBar.open( - '✅ ' + $localize`${codeToCopy} has been copied to the clipboard`, - undefined, - { duration: ms('3 seconds') } - ); + if (snackBarMessage) { + this.snackBar.open(snackBarMessage, undefined, { + duration: ms('3 seconds') + }); } this.changeDetectorRef.markForCheck();