From c1857a1666635fc6e7b8d047159061099f1fb336 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 2 Aug 2025 10:12:10 +0200 Subject: [PATCH] Clean up --- .../accounts-table.component.stories.ts | 189 ++++++------------ .../accounts-table.component.ts | 10 +- .../tags-selector.component.stories.ts | 2 +- 3 files changed, 65 insertions(+), 136 deletions(-) diff --git a/libs/ui/src/lib/accounts-table/accounts-table.component.stories.ts b/libs/ui/src/lib/accounts-table/accounts-table.component.stories.ts index 44bd3eb08..e13df2222 100644 --- a/libs/ui/src/lib/accounts-table/accounts-table.component.stories.ts +++ b/libs/ui/src/lib/accounts-table/accounts-table.component.stories.ts @@ -14,86 +14,72 @@ import { GfEntityLogoComponent } from '../entity-logo'; import { GfValueComponent } from '../value'; import { GfAccountsTableComponent } from './accounts-table.component'; -const mockAccounts = [ +const accounts = [ { - id: '1', - name: 'Checking Account', + allocationInPercentage: null, + balance: 278, + balanceInBaseCurrency: 278, + comment: null, + createdAt: new Date('2025-06-01T06:52:49.063Z'), currency: 'USD', - balance: 15000, - value: 15000, - valueInBaseCurrency: 15000, - transactionCount: 25, - allocationInPercentage: 0.15, + id: '460d7401-ca43-4ed4-b08e-349f1822e9db', isExcluded: false, - comment: 'Primary checking account', + name: 'Coinbase Account', platform: { - name: 'Bank of America', - url: 'https://www.bankofamerica.com' + id: '8dc24b88-bb92-4152-af25-fe6a31643e26', + name: 'Coinbase', + url: 'https://www.coinbase.com' }, - createdAt: new Date(), - updatedAt: new Date(), - platformId: 'bofa', - userId: 'user1' + platformId: '8dc24b88-bb92-4152-af25-fe6a31643e26', + transactionCount: 0, + updatedAt: new Date('2025-06-01T06:52:49.063Z'), + userId: '081aa387-487d-4438-83a4-3060eb2a016e', + value: 278, + valueInBaseCurrency: 278 }, { - id: '2', - name: 'Trading Account', - currency: 'USD', - balance: 5000, - value: 125000, - valueInBaseCurrency: 125000, - transactionCount: 127, - allocationInPercentage: 0.65, - isExcluded: false, + allocationInPercentage: null, + balance: 12000, + balanceInBaseCurrency: 12000, comment: null, - platform: { - name: 'Interactive Brokers', - url: 'https://www.interactivebrokers.com' - }, - createdAt: new Date(), - updatedAt: new Date(), - platformId: 'ibkr', - userId: 'user1' - }, - { - id: '3', - name: 'Savings Account', - currency: 'EUR', - balance: 20000, - value: 20000, - valueInBaseCurrency: 21600, - transactionCount: 8, - allocationInPercentage: 0.2, + createdAt: new Date('2025-06-01T06:48:53.055Z'), + currency: 'USD', + id: '6d773e31-0583-4c85-a247-e69870b4f1ee', isExcluded: false, - comment: 'Emergency fund', + name: 'Private Banking Account', platform: { - name: 'Deutsche Bank', - url: 'https://www.deutsche-bank.de' + id: '43e8fcd1-5b79-4100-b678-d2229bd1660d', + name: 'J.P. Morgan', + url: 'https://www.jpmorgan.com' }, - createdAt: new Date(), - updatedAt: new Date(), - platformId: 'db', - userId: 'user1' + platformId: '43e8fcd1-5b79-4100-b678-d2229bd1660d', + transactionCount: 0, + updatedAt: new Date('2025-06-01T06:48:53.055Z'), + userId: '081aa387-487d-4438-83a4-3060eb2a016e', + value: 12000, + valueInBaseCurrency: 12000 }, { - id: '4', - name: 'Excluded Account', - currency: 'USD', - balance: 1000, - value: 1000, - valueInBaseCurrency: 1000, - transactionCount: 3, - allocationInPercentage: 0, - isExcluded: true, + allocationInPercentage: null, + balance: 150.2, + balanceInBaseCurrency: 150.2, comment: null, + createdAt: new Date('2025-05-31T13:00:13.940Z'), + currency: 'USD', + id: '776bd1e9-b2f6-4f7e-933d-18756c2f0625', + isExcluded: false, + name: 'Trading Account', platform: { - name: 'Local Credit Union', - url: null + id: '9da3a8a7-4795-43e3-a6db-ccb914189737', + name: 'Interactive Brokers', + url: 'https://interactivebrokers.com' }, - createdAt: new Date(), - updatedAt: new Date(), - platformId: 'lcu', - userId: 'user1' + platformId: '9da3a8a7-4795-43e3-a6db-ccb914189737', + transactionCount: 12, + valueInBaseCurrency: 95693.70321466809, + updatedAt: new Date('2025-06-01T06:53:10.569Z'), + userId: '081aa387-487d-4438-83a4-3060eb2a016e', + value: 95693.70321466809 } ]; @@ -121,28 +107,9 @@ export default { type Story = StoryObj; -export const Loading: Story = { - args: { - accounts: [], - baseCurrency: 'USD', - deviceType: 'desktop', - locale: 'en-US', - showActions: false, - showAllocationInPercentage: false, - showBalance: true, - showFooter: true, - showTransactions: true, - showValue: true, - showValueInBaseCurrency: true, - totalBalanceInBaseCurrency: 0, - totalValueInBaseCurrency: 0, - transactionCount: 0 - } -}; - export const Default: Story = { args: { - accounts: mockAccounts, + accounts, baseCurrency: 'USD', deviceType: 'desktop', locale: 'en-US', @@ -153,65 +120,27 @@ export const Default: Story = { showTransactions: true, showValue: true, showValueInBaseCurrency: true, - totalBalanceInBaseCurrency: 56600, - totalValueInBaseCurrency: 161600, - transactionCount: 163 - } -}; - -export const WithActions: Story = { - args: { - accounts: mockAccounts, - baseCurrency: 'USD', - deviceType: 'desktop', - locale: 'en-US', - showActions: true, - showAllocationInPercentage: true, - showBalance: true, - showFooter: true, - showTransactions: true, - showValue: true, - showValueInBaseCurrency: true, - totalBalanceInBaseCurrency: 56600, - totalValueInBaseCurrency: 161600, - transactionCount: 163 - } -}; - -export const MobileView: Story = { - args: { - accounts: mockAccounts, - baseCurrency: 'USD', - deviceType: 'mobile', - locale: 'en-US', - showActions: false, - showAllocationInPercentage: false, - showBalance: false, - showFooter: false, - showTransactions: true, - showValue: false, - showValueInBaseCurrency: true, - totalBalanceInBaseCurrency: 56600, - totalValueInBaseCurrency: 161600, - transactionCount: 163 + totalBalanceInBaseCurrency: 12428.2, + totalValueInBaseCurrency: 107971.70321466809, + transactionCount: 12 } }; export const WithoutFooter: Story = { args: { - accounts: mockAccounts, + accounts, baseCurrency: 'USD', deviceType: 'desktop', locale: 'en-US', showActions: false, - showAllocationInPercentage: true, + showAllocationInPercentage: false, showBalance: true, showFooter: false, showTransactions: true, showValue: true, showValueInBaseCurrency: true, - totalBalanceInBaseCurrency: 56600, - totalValueInBaseCurrency: 161600, - transactionCount: 163 + totalBalanceInBaseCurrency: 12428.2, + totalValueInBaseCurrency: 107971.70321466809, + transactionCount: 12 } }; diff --git a/libs/ui/src/lib/accounts-table/accounts-table.component.ts b/libs/ui/src/lib/accounts-table/accounts-table.component.ts index a7ce6e488..607fa67dc 100644 --- a/libs/ui/src/lib/accounts-table/accounts-table.component.ts +++ b/libs/ui/src/lib/accounts-table/accounts-table.component.ts @@ -21,7 +21,7 @@ import { MatSort, MatSortModule } from '@angular/material/sort'; import { MatTableDataSource, MatTableModule } from '@angular/material/table'; import { Router, RouterModule } from '@angular/router'; import { IonIcon } from '@ionic/angular/standalone'; -import { Account as AccountModel } from '@prisma/client'; +import { Account } from '@prisma/client'; import { addIcons } from 'ionicons'; import { arrowRedoOutline, @@ -54,7 +54,7 @@ import { Subject, Subscription } from 'rxjs'; templateUrl: './accounts-table.component.html' }) export class GfAccountsTableComponent implements OnChanges, OnDestroy { - @Input() accounts: AccountModel[]; + @Input() accounts: Account[]; @Input() baseCurrency: string; @Input() deviceType: string; @Input() hasPermissionToOpenDetails = true; @@ -71,12 +71,12 @@ export class GfAccountsTableComponent implements OnChanges, OnDestroy { @Input() transactionCount: number; @Output() accountDeleted = new EventEmitter(); - @Output() accountToUpdate = new EventEmitter(); + @Output() accountToUpdate = new EventEmitter(); @Output() transferBalance = new EventEmitter(); @ViewChild(MatSort) sort: MatSort; - public dataSource = new MatTableDataSource(); + public dataSource = new MatTableDataSource(); public displayedColumns = []; public isLoading = true; public routeQueryParams: Subscription; @@ -167,7 +167,7 @@ export class GfAccountsTableComponent implements OnChanges, OnDestroy { this.transferBalance.emit(); } - public onUpdateAccount(aAccount: AccountModel) { + public onUpdateAccount(aAccount: Account) { this.accountToUpdate.emit(aAccount); } diff --git a/libs/ui/src/lib/tags-selector/tags-selector.component.stories.ts b/libs/ui/src/lib/tags-selector/tags-selector.component.stories.ts index 42fb68876..d11175fd1 100644 --- a/libs/ui/src/lib/tags-selector/tags-selector.component.stories.ts +++ b/libs/ui/src/lib/tags-selector/tags-selector.component.stories.ts @@ -21,7 +21,7 @@ const OPTIONS = [ { id: '3ef7e6d9-4598-4eb2-b0e8-00e61cfc0ea6', name: 'Gambling', - userId: 'c6a71541-d0e3-4e22-ae83-b5e5611b6695' + userId: '081aa387-487d-4438-83a4-3060eb2a016e' }, { id: 'EMERGENCY_FUND',