Browse Source

Refactoring

pull/3077/head
Thomas Kaul 2 years ago
parent
commit
abf870050c
  1. 8
      libs/common/src/lib/helper.ts
  2. 5
      libs/ui/src/lib/benchmark/benchmark.component.html
  3. 2
      libs/ui/src/lib/benchmark/benchmark.component.ts

8
libs/common/src/lib/helper.ts

@ -1,5 +1,3 @@
import { translate } from '@ghostfolio/ui/i18n';
import * as currencies from '@dinero.js/currencies'; import * as currencies from '@dinero.js/currencies';
import { NumberParser } from '@internationalized/number'; import { NumberParser } from '@internationalized/number';
import { DataSource, MarketData } from '@prisma/client'; import { DataSource, MarketData } from '@prisma/client';
@ -391,10 +389,10 @@ export function resolveMarketCondition(
aMarketCondition: Benchmark['marketCondition'] aMarketCondition: Benchmark['marketCondition']
) { ) {
if (aMarketCondition === 'ALL_TIME_HIGH') { if (aMarketCondition === 'ALL_TIME_HIGH') {
return { emoji: '🎉', label: translate(aMarketCondition) }; return { emoji: '🎉' };
} else if (aMarketCondition === 'BEAR_MARKET') { } else if (aMarketCondition === 'BEAR_MARKET') {
return { emoji: '🐻', label: translate(aMarketCondition) }; return { emoji: '🐻' };
} else { } else {
return { emoji: undefined, label: undefined }; return { emoji: undefined };
} }
} }

5
libs/ui/src/lib/benchmark/benchmark.component.html

@ -102,10 +102,7 @@
<th *matHeaderCellDef mat-header-cell></th> <th *matHeaderCellDef mat-header-cell></th>
<td *matCellDef="let element" class="px-0" mat-cell> <td *matCellDef="let element" class="px-0" mat-cell>
@if (element?.marketCondition) { @if (element?.marketCondition) {
<div <div class="text-center" [title]="translate(element.marketCondition)">
class="text-center"
[title]="resolveMarketCondition(element.marketCondition).label"
>
{{ resolveMarketCondition(element.marketCondition).emoji }} {{ resolveMarketCondition(element.marketCondition).emoji }}
</div> </div>
} }

2
libs/ui/src/lib/benchmark/benchmark.component.ts

@ -1,5 +1,6 @@
import { getLocale, resolveMarketCondition } from '@ghostfolio/common/helper'; import { getLocale, resolveMarketCondition } from '@ghostfolio/common/helper';
import { Benchmark, User } from '@ghostfolio/common/interfaces'; import { Benchmark, User } from '@ghostfolio/common/interfaces';
import { translate } from '@ghostfolio/ui/i18n';
import { import {
ChangeDetectionStrategy, ChangeDetectionStrategy,
@ -21,6 +22,7 @@ export class BenchmarkComponent implements OnChanges {
public displayedColumns = ['name', 'date', 'change', 'marketCondition']; public displayedColumns = ['name', 'date', 'change', 'marketCondition'];
public resolveMarketCondition = resolveMarketCondition; public resolveMarketCondition = resolveMarketCondition;
public translate = translate;
public constructor() {} public constructor() {}

Loading…
Cancel
Save