From 6c8e82a57bab5507f46072bcb2692b760337abb3 Mon Sep 17 00:00:00 2001 From: Attila Cseh Date: Thu, 25 Sep 2025 08:47:17 +0200 Subject: [PATCH] code review fixes --- CHANGELOG.md | 5 +++- ...ate-or-update-activity-dialog.component.ts | 25 ++++++------------- .../types/activity-type.type.ts | 8 ++++++ libs/ui/src/lib/i18n.ts | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/types/activity-type.type.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a2aebfd5..cd8075ce0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added `settings` to the `Access` model +### Changed + +- Changed the deprecated `ITEM` activity type to `VALUABLE` in the create or update activity dialog + ## 2.201.0 - 2025-09-24 ### Added @@ -27,7 +31,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Refreshed the cryptocurrencies list - Improved the language localization for German (`de`) - Upgraded `countup.js` from version `2.8.2` to `2.9.0` -- Deprecated _ITEM_ activity type removed from the create or update activity dialog ### Fixed diff --git a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts index d8b77524b..32904377b 100644 --- a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts +++ b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/create-or-update-activity-dialog.component.ts @@ -51,18 +51,7 @@ import { catchError, delay, takeUntil } from 'rxjs/operators'; import { DataService } from '../../../../services/data.service'; import { validateObjectForForm } from '../../../../util/form.util'; import { CreateOrUpdateActivityDialogParams } from './interfaces/interfaces'; - -const DisplayedActivityType = { - BUY: Type.BUY, - DIVIDEND: Type.DIVIDEND, - FEE: Type.FEE, - INTEREST: Type.INTEREST, - LIABILITY: Type.LIABILITY, - SELL: Type.SELL, - VALUABLE: 'VALUABLE' as const -}; -type DisplayedActivityType = - (typeof DisplayedActivityType)[keyof typeof DisplayedActivityType]; +import { ActivityType } from './types/activity-type.type'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, @@ -190,9 +179,9 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy { }; }) ?? []; - Object.keys(DisplayedActivityType).forEach((type) => { - this.typesTranslationMap[DisplayedActivityType[type]] = translate( - DisplayedActivityType[type] + Object.keys(ActivityType).forEach((type) => { + this.typesTranslationMap[ActivityType[type]] = translate( + ActivityType[type] ); }); @@ -277,7 +266,7 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy { this.activityForm.get('accountId').valueChanges.subscribe((accountId) => { const type = this.activityForm.get('type').value; - if (['FEE', 'INTEREST', 'VALUABLE', 'LIABILITY'].includes(type)) { + if (['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes(type)) { const currency = this.data.accounts.find(({ id }) => { return id === accountId; @@ -373,7 +362,7 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy { this.activityForm .get('type') .valueChanges.pipe(takeUntil(this.unsubscribeSubject)) - .subscribe((type: DisplayedActivityType) => { + .subscribe((type: ActivityType) => { if ( type === 'VALUABLE' || (this.activityForm.get('dataSource').value === 'MANUAL' && @@ -536,7 +525,7 @@ export class GfCreateOrUpdateActivityDialog implements OnDestroy { fee: this.activityForm.get('fee').value, quantity: this.activityForm.get('quantity').value, symbol: - (['FEE', 'INTEREST', 'VALUABLE', 'LIABILITY'].includes( + (['FEE', 'INTEREST', 'LIABILITY', 'VALUABLE'].includes( this.activityForm.get('type').value ) ? undefined diff --git a/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/types/activity-type.type.ts b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/types/activity-type.type.ts new file mode 100644 index 000000000..6c3f32f28 --- /dev/null +++ b/apps/client/src/app/pages/portfolio/activities/create-or-update-activity-dialog/types/activity-type.type.ts @@ -0,0 +1,8 @@ +import { Type } from '@prisma/client'; + +export const ActivityType = { + ...Type, + VALUABLE: 'VALUABLE' +} as const; + +export type ActivityType = (typeof ActivityType)[keyof typeof ActivityType]; diff --git a/libs/ui/src/lib/i18n.ts b/libs/ui/src/lib/i18n.ts index b5dbdcad2..4d494a43a 100644 --- a/libs/ui/src/lib/i18n.ts +++ b/libs/ui/src/lib/i18n.ts @@ -38,9 +38,9 @@ const locales = { DIVIDEND: $localize`Dividend`, FEE: $localize`Fee`, INTEREST: $localize`Interest`, - VALUABLE: $localize`Valuable`, LIABILITY: $localize`Liability`, SELL: $localize`Sell`, + VALUABLE: $localize`Valuable`, // AssetClass (enum) ALTERNATIVE_INVESTMENT: $localize`Alternative Investment`,