Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Task/extend coupons with createdAt (#7257)

Thomas Kaul8aa476909bee
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 b2c9b11a30..7374fb05cb 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
@@ -90,7 +90,12 @@ export class GfAdminOverviewComponent implements OnInit {
protected activitiesCount: number;
protected couponDuration: StringValue = '14 days';
protected readonly couponsDataSource = new MatTableDataSource<Coupon>();
- protected readonly couponsDisplayedColumns = ['code', 'duration', 'actions'];
+ protected readonly couponsDisplayedColumns = [
+ 'code',
+ 'duration',
+ 'createdAt',
+ 'actions'
+ ];
protected hasPermissionForSubscription: boolean;
protected hasPermissionForSystemMessage: boolean;
protected hasPermissionToSyncDemoUserAccount: boolean;
@@ -201,6 +206,7 @@ export class GfAdminOverviewComponent implements OnInit {
protected onAddCoupon() {
const newCoupon: Coupon = {
code: `${ghostfolioPrefix}${this.generateCouponCode(14)}`,
+ createdAt: new Date().toISOString(),
duration: this.couponDuration
};
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 bccedd2513..2fde94083d 100644
--- a/apps/client/src/app/components/admin-overview/admin-overview.html
+++ b/apps/client/src/app/components/admin-overview/admin-overview.html
@@ -180,6 +180,28 @@
</td>
</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>
<th
*matHeaderCellDef
diff --git a/libs/common/src/lib/interfaces/coupon.interface.ts b/libs/common/src/lib/interfaces/coupon.interface.ts
index cbf8525a21..0ee1ddb24c 100644
--- a/libs/common/src/lib/interfaces/coupon.interface.ts
+++ b/libs/common/src/lib/interfaces/coupon.interface.ts
@@ -2,5 +2,6 @@ import { StringValue } from 'ms';
export interface Coupon {
code: string;
- duration?: StringValue;
+ createdAt: string;
+ duration: StringValue;
}