From 785ed3c54bb574e97256bfe67654ac8547f42f9f Mon Sep 17 00:00:00 2001 From: Basimohd Date: Wed, 18 Oct 2023 21:26:30 +0530 Subject: [PATCH] Fixed the comments and formatted --- .../account-detail-dialog.component.scss | 6 +- .../account-detail-dialog.component.ts | 61 ++++++++----------- .../account-detail-dialog.html | 4 +- 3 files changed, 31 insertions(+), 40 deletions(-) diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.scss b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.scss index 1774486ca..8831fb01d 100644 --- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.scss +++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.scss @@ -3,9 +3,9 @@ .mat-mdc-dialog-content { max-height: unset; - } - .chart-container { - aspect-ratio: 16 / 9; + .chart-container { + aspect-ratio: 16 / 9; + } } } diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts index 5c4822140..df929b672 100644 --- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts +++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.component.ts @@ -38,7 +38,7 @@ export class AccountDetailDialog implements OnDestroy, OnInit { public isLoadingBenchmarkComparator: boolean; public name: string; public orders: OrderWithAccount[]; - public performanceDataItems: HistoricalDataItem[]; + public historicalDataItems: HistoricalDataItem[]; public platformName: string; public transactionCount: number; public user: User; @@ -60,8 +60,6 @@ export class AccountDetailDialog implements OnDestroy, OnInit { if (state?.user) { this.user = state.user; - this.update(); - this.changeDetectorRef.markForCheck(); } }); @@ -114,6 +112,32 @@ export class AccountDetailDialog implements OnDestroy, OnInit { .subscribe(({ activities }) => { this.orders = activities; + this.changeDetectorRef.markForCheck(); + }); + + this.dataService + .fetchPortfolioPerformance({ + filters: [ + { + id: this.data.accountId, + type: 'ACCOUNT' + } + ], + range: 'max' + }) + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe(({ chart, firstOrderDate }) => { + this.daysInMarket = differenceInDays(new Date(), firstOrderDate); + + this.historicalDataItems = []; + + chart.forEach(({ date, value, valueInPercentage }) => { + this.historicalDataItems.push({ + date, + value: this.hasImpersonationId ? valueInPercentage : value + }); + }); + this.changeDetectorRef.markForCheck(); }); } @@ -148,35 +172,4 @@ export class AccountDetailDialog implements OnDestroy, OnInit { this.unsubscribeSubject.next(); this.unsubscribeSubject.complete(); } - - private update() { - this.isLoadingBenchmarkComparator = false; - - this.dataService - .fetchPortfolioPerformance({ - range: this.user?.settings?.dateRange - }) - .pipe(takeUntil(this.unsubscribeSubject)) - .subscribe(({ chart, firstOrderDate }) => { - this.daysInMarket = differenceInDays(new Date(), firstOrderDate); - - this.performanceDataItems = []; - - for (const [ - index, - { date, value, valueInPercentage } - ] of chart.entries()) { - if (index > 0 || this.user?.settings?.dateRange === 'max') { - // Ignore first item where value is 0 - this.performanceDataItems.push({ - date, - value: isNumber(value) ? value : valueInPercentage - }); - } - } - this.changeDetectorRef.markForCheck(); - }); - - this.changeDetectorRef.markForCheck(); - } } diff --git a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html index bc580121f..a3cabdb10 100644 --- a/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html +++ b/apps/client/src/app/components/account-detail-dialog/account-detail-dialog.html @@ -24,12 +24,10 @@