Browse Source

fix(client): resolve errors in holding detail dialog

pull/7050/head
KenTandrian 3 months ago
parent
commit
6da5120798
  1. 22
      apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts

22
apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts

@ -16,6 +16,7 @@ import {
EnhancedSymbolProfile, EnhancedSymbolProfile,
Filter, Filter,
LineChartItem, LineChartItem,
NullableLineChartItem,
User User
} from '@ghostfolio/common/interfaces'; } from '@ghostfolio/common/interfaces';
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { hasPermission, permissions } from '@ghostfolio/common/permissions';
@ -71,6 +72,7 @@ import {
swapVerticalOutline, swapVerticalOutline,
walletOutline walletOutline
} from 'ionicons/icons'; } from 'ionicons/icons';
import { isNumber } from 'lodash';
import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { switchMap } from 'rxjs/operators'; import { switchMap } from 'rxjs/operators';
@ -112,7 +114,7 @@ export class GfHoldingDetailDialogComponent implements OnInit {
public assetSubClass: string; public assetSubClass: string;
public averagePrice: number; public averagePrice: number;
public averagePricePrecision = 2; public averagePricePrecision = 2;
public benchmarkDataItems: LineChartItem[]; public benchmarkDataItems: NullableLineChartItem[];
public benchmarkLabel = $localize`Average Unit Price`; public benchmarkLabel = $localize`Average Unit Price`;
public countries: { public countries: {
[code: string]: { name: string; value: number }; [code: string]: { name: string; value: number };
@ -195,7 +197,7 @@ export class GfHoldingDetailDialogComponent implements OnInit {
this.holdingForm this.holdingForm
.get('tags') .get('tags')
.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)) ?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((tags: Tag[]) => { .subscribe((tags: Tag[]) => {
const newTag = tags.find(({ id }) => { const newTag = tags.find(({ id }) => {
return id === undefined; return id === undefined;
@ -318,12 +320,12 @@ export class GfHoldingDetailDialogComponent implements OnInit {
({ averagePrice, date, marketPrice }) => { ({ averagePrice, date, marketPrice }) => {
this.benchmarkDataItems.push({ this.benchmarkDataItems.push({
date, date,
value: averagePrice value: isNumber(averagePrice) ? averagePrice : null
}); });
return { return {
date, date,
value: marketPrice value: marketPrice ?? 0
}; };
} }
); );
@ -526,7 +528,7 @@ export class GfHoldingDetailDialogComponent implements OnInit {
this.hasPermissionToCreateOwnTag = this.hasPermissionToCreateOwnTag =
hasPermission(this.user.permissions, permissions.createOwnTag) && hasPermission(this.user.permissions, permissions.createOwnTag) &&
this.user?.settings?.isExperimentalFeatures; (this.user?.settings?.isExperimentalFeatures ?? false);
this.tagsAvailable = this.tagsAvailable =
this.user?.tags?.map((tag) => { this.user?.tags?.map((tag) => {
@ -566,14 +568,14 @@ export class GfHoldingDetailDialogComponent implements OnInit {
const today = new Date(); const today = new Date();
const activity: CreateOrderDto = { const activity: CreateOrderDto = {
accountId: this.accounts.length === 1 ? this.accounts[0].id : null, accountId: this.accounts.length === 1 ? this.accounts[0].id : undefined,
comment: null, comment: undefined,
currency: this.SymbolProfile.currency, currency: this.SymbolProfile?.currency ?? '',
dataSource: this.SymbolProfile.dataSource, dataSource: this.SymbolProfile?.dataSource,
date: today.toISOString(), date: today.toISOString(),
fee: 0, fee: 0,
quantity: this.quantity, quantity: this.quantity,
symbol: this.SymbolProfile.symbol, symbol: this.SymbolProfile?.symbol ?? '',
tags: this.tags.map(({ id }) => { tags: this.tags.map(({ id }) => {
return id; return id;
}), }),

Loading…
Cancel
Save