|
|
|
@ -49,7 +49,11 @@ import { MatSnackBar, MatSnackBarModule } from '@angular/material/snack-bar'; |
|
|
|
import { MatTableDataSource, MatTableModule } from '@angular/material/table'; |
|
|
|
import { RouterModule } from '@angular/router'; |
|
|
|
import { IonIcon } from '@ionic/angular/standalone'; |
|
|
|
import { addMilliseconds, formatDistanceToNowStrict } from 'date-fns'; |
|
|
|
import { |
|
|
|
addMilliseconds, |
|
|
|
FormatDistanceStrictUnit, |
|
|
|
formatDistanceToNowStrict |
|
|
|
} from 'date-fns'; |
|
|
|
import { addIcons } from 'ionicons'; |
|
|
|
import { |
|
|
|
closeCircleOutline, |
|
|
|
@ -88,6 +92,7 @@ import { catchError, finalize, of, switchMap } from 'rxjs'; |
|
|
|
export class GfAdminOverviewComponent implements OnInit { |
|
|
|
protected activitiesCount: number; |
|
|
|
protected couponDuration: StringValue = '14 days'; |
|
|
|
protected readonly couponDurationWithExtension: StringValue | undefined; |
|
|
|
protected readonly couponsDataSource = new MatTableDataSource<Coupon>(); |
|
|
|
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)), |
|
|
|
{ |
|
|
|
protected formatStringValue({ |
|
|
|
unit, |
|
|
|
value |
|
|
|
}: { |
|
|
|
unit?: FormatDistanceStrictUnit; |
|
|
|
value: StringValue; |
|
|
|
}) { |
|
|
|
return formatDistanceToNowStrict(addMilliseconds(new Date(), ms(value)), { |
|
|
|
unit, |
|
|
|
locale: getDateFnsLocale(this.user?.settings?.language) |
|
|
|
} |
|
|
|
); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
protected onAddCoupon() { |
|
|
|
|