Browse Source

Task/extend coupons with createdAt (#7257)

* Extend coupons with createdAt
pull/7260/head^2
Thomas Kaul 1 week ago
committed by GitHub
parent
commit
8aa476909b
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 8
      apps/client/src/app/components/admin-overview/admin-overview.component.ts
  2. 22
      apps/client/src/app/components/admin-overview/admin-overview.html
  3. 3
      libs/common/src/lib/interfaces/coupon.interface.ts

8
apps/client/src/app/components/admin-overview/admin-overview.component.ts

@ -90,7 +90,12 @@ export class GfAdminOverviewComponent implements OnInit {
protected activitiesCount: number; protected activitiesCount: number;
protected couponDuration: StringValue = '14 days'; protected couponDuration: StringValue = '14 days';
protected readonly couponsDataSource = new MatTableDataSource<Coupon>(); protected readonly couponsDataSource = new MatTableDataSource<Coupon>();
protected readonly couponsDisplayedColumns = ['code', 'duration', 'actions']; protected readonly couponsDisplayedColumns = [
'code',
'duration',
'createdAt',
'actions'
];
protected hasPermissionForSubscription: boolean; protected hasPermissionForSubscription: boolean;
protected hasPermissionForSystemMessage: boolean; protected hasPermissionForSystemMessage: boolean;
protected hasPermissionToSyncDemoUserAccount: boolean; protected hasPermissionToSyncDemoUserAccount: boolean;
@ -201,6 +206,7 @@ export class GfAdminOverviewComponent implements OnInit {
protected onAddCoupon() { protected onAddCoupon() {
const newCoupon: Coupon = { const newCoupon: Coupon = {
code: `${ghostfolioPrefix}${this.generateCouponCode(14)}`, code: `${ghostfolioPrefix}${this.generateCouponCode(14)}`,
createdAt: new Date().toISOString(),
duration: this.couponDuration duration: this.couponDuration
}; };

22
apps/client/src/app/components/admin-overview/admin-overview.html

@ -180,6 +180,28 @@
</td> </td>
</ng-container> </ng-container>
<ng-container matColumnDef="createdAt">
<th *matHeaderCellDef class="px-1 text-right" mat-header-cell>
<ng-container i18n>Creation</ng-container>
</th>
<td
*matCellDef="let element"
class="px-1 text-right"
mat-cell
>
@if (element.createdAt) {
<gf-value
class="d-inline-block justify-content-end"
[isDate]="true"
[locale]="user?.settings?.locale"
[value]="element.createdAt"
/>
} @else {
<span>-</span>
}
</td>
</ng-container>
<ng-container matColumnDef="actions" stickyEnd> <ng-container matColumnDef="actions" stickyEnd>
<th <th
*matHeaderCellDef *matHeaderCellDef

3
libs/common/src/lib/interfaces/coupon.interface.ts

@ -2,5 +2,6 @@ import { StringValue } from 'ms';
export interface Coupon { export interface Coupon {
code: string; code: string;
duration?: StringValue; createdAt: string;
duration: StringValue;
} }

Loading…
Cancel
Save