();
protected readonly couponsDisplayedColumns = [
'code',
@@ -95,6 +100,7 @@ export class GfAdminOverviewComponent implements OnInit {
'createdAt',
'actions'
];
+ protected readonly durationExtension: StringValue | undefined;
protected hasPermissionForSubscription: boolean;
protected hasPermissionForSystemMessage: boolean;
protected hasPermissionToSyncDemoUserAccount: boolean;
@@ -124,6 +130,15 @@ export class GfAdminOverviewComponent implements OnInit {
public constructor() {
this.info = this.dataService.fetchInfo();
+ this.durationExtension = this.info.subscriptionOffer?.durationExtension;
+
+ if (this.durationExtension) {
+ this.couponDurationWithExtension = ms(
+ ms('1 year') + ms(this.durationExtension),
+ { long: true }
+ ) as StringValue;
+ }
+
this.userService.stateChanged
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((state) => {
@@ -185,13 +200,17 @@ export class GfAdminOverviewComponent implements OnInit {
this.fetchAdminData();
}
- protected formatStringValue(aStringValue: StringValue) {
- return formatDistanceToNowStrict(
- addMilliseconds(new Date(), ms(aStringValue)),
- {
- locale: getDateFnsLocale(this.user?.settings?.language)
- }
- );
+ protected formatStringValue({
+ unit,
+ value
+ }: {
+ unit?: FormatDistanceStrictUnit;
+ value: StringValue;
+ }) {
+ return formatDistanceToNowStrict(addMilliseconds(new Date(), ms(value)), {
+ unit,
+ locale: getDateFnsLocale(this.user?.settings?.language)
+ });
}
protected onAddCoupon() {
diff --git a/apps/client/src/app/components/admin-overview/admin-overview.html b/apps/client/src/app/components/admin-overview/admin-overview.html
index 269fe291ac..592d135301 100644
--- a/apps/client/src/app/components/admin-overview/admin-overview.html
+++ b/apps/client/src/app/components/admin-overview/admin-overview.html
@@ -178,7 +178,7 @@
Duration
|
- {{ formatStringValue(element.duration) }}
+ {{ formatStringValue({ value: element.duration }) }}
|
@@ -263,23 +263,34 @@
(selectionChange)="onChangeCouponDuration($event.value)"
>
{{
- formatStringValue('7 days')
+ formatStringValue({ value: '7 days' })
}}
{{
- formatStringValue('14 days')
+ formatStringValue({ value: '14 days' })
}}
{{
- formatStringValue('30 days')
+ formatStringValue({ value: '30 days' })
}}
{{
- formatStringValue('90 days')
+ formatStringValue({ value: '90 days' })
}}
{{
- formatStringValue('180 days')
+ formatStringValue({ value: '180 days' })
}}
{{
- formatStringValue('1 year')
+ formatStringValue({ value: '1 year' })
}}
+ @if (durationExtension) {
+ {{ formatStringValue({ value: '1 year' }) }} +
+ {{
+ formatStringValue({
+ unit: 'day',
+ value: durationExtension
+ })
+ }}
+ }