Browse Source

Clean up

pull/5278/head
Thomas Kaul 3 weeks ago
parent
commit
c1857a1666
  1. 189
      libs/ui/src/lib/accounts-table/accounts-table.component.stories.ts
  2. 10
      libs/ui/src/lib/accounts-table/accounts-table.component.ts
  3. 2
      libs/ui/src/lib/tags-selector/tags-selector.component.stories.ts

189
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 { GfValueComponent } from '../value';
import { GfAccountsTableComponent } from './accounts-table.component'; import { GfAccountsTableComponent } from './accounts-table.component';
const mockAccounts = [ const accounts = [
{ {
id: '1', allocationInPercentage: null,
name: 'Checking Account', balance: 278,
balanceInBaseCurrency: 278,
comment: null,
createdAt: new Date('2025-06-01T06:52:49.063Z'),
currency: 'USD', currency: 'USD',
balance: 15000, id: '460d7401-ca43-4ed4-b08e-349f1822e9db',
value: 15000,
valueInBaseCurrency: 15000,
transactionCount: 25,
allocationInPercentage: 0.15,
isExcluded: false, isExcluded: false,
comment: 'Primary checking account', name: 'Coinbase Account',
platform: { platform: {
name: 'Bank of America', id: '8dc24b88-bb92-4152-af25-fe6a31643e26',
url: 'https://www.bankofamerica.com' name: 'Coinbase',
url: 'https://www.coinbase.com'
}, },
createdAt: new Date(), platformId: '8dc24b88-bb92-4152-af25-fe6a31643e26',
updatedAt: new Date(), transactionCount: 0,
platformId: 'bofa', updatedAt: new Date('2025-06-01T06:52:49.063Z'),
userId: 'user1' userId: '081aa387-487d-4438-83a4-3060eb2a016e',
value: 278,
valueInBaseCurrency: 278
}, },
{ {
id: '2', allocationInPercentage: null,
name: 'Trading Account', balance: 12000,
currency: 'USD', balanceInBaseCurrency: 12000,
balance: 5000,
value: 125000,
valueInBaseCurrency: 125000,
transactionCount: 127,
allocationInPercentage: 0.65,
isExcluded: false,
comment: null, comment: null,
platform: { createdAt: new Date('2025-06-01T06:48:53.055Z'),
name: 'Interactive Brokers', currency: 'USD',
url: 'https://www.interactivebrokers.com' id: '6d773e31-0583-4c85-a247-e69870b4f1ee',
},
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,
isExcluded: false, isExcluded: false,
comment: 'Emergency fund', name: 'Private Banking Account',
platform: { platform: {
name: 'Deutsche Bank', id: '43e8fcd1-5b79-4100-b678-d2229bd1660d',
url: 'https://www.deutsche-bank.de' name: 'J.P. Morgan',
url: 'https://www.jpmorgan.com'
}, },
createdAt: new Date(), platformId: '43e8fcd1-5b79-4100-b678-d2229bd1660d',
updatedAt: new Date(), transactionCount: 0,
platformId: 'db', updatedAt: new Date('2025-06-01T06:48:53.055Z'),
userId: 'user1' userId: '081aa387-487d-4438-83a4-3060eb2a016e',
value: 12000,
valueInBaseCurrency: 12000
}, },
{ {
id: '4', allocationInPercentage: null,
name: 'Excluded Account', balance: 150.2,
currency: 'USD', balanceInBaseCurrency: 150.2,
balance: 1000,
value: 1000,
valueInBaseCurrency: 1000,
transactionCount: 3,
allocationInPercentage: 0,
isExcluded: true,
comment: null, 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: { platform: {
name: 'Local Credit Union', id: '9da3a8a7-4795-43e3-a6db-ccb914189737',
url: null name: 'Interactive Brokers',
url: 'https://interactivebrokers.com'
}, },
createdAt: new Date(), platformId: '9da3a8a7-4795-43e3-a6db-ccb914189737',
updatedAt: new Date(), transactionCount: 12,
platformId: 'lcu', valueInBaseCurrency: 95693.70321466809,
userId: 'user1' 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<GfAccountsTableComponent>; type Story = StoryObj<GfAccountsTableComponent>;
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 = { export const Default: Story = {
args: { args: {
accounts: mockAccounts, accounts,
baseCurrency: 'USD', baseCurrency: 'USD',
deviceType: 'desktop', deviceType: 'desktop',
locale: 'en-US', locale: 'en-US',
@ -153,65 +120,27 @@ export const Default: Story = {
showTransactions: true, showTransactions: true,
showValue: true, showValue: true,
showValueInBaseCurrency: true, showValueInBaseCurrency: true,
totalBalanceInBaseCurrency: 56600, totalBalanceInBaseCurrency: 12428.2,
totalValueInBaseCurrency: 161600, totalValueInBaseCurrency: 107971.70321466809,
transactionCount: 163 transactionCount: 12
}
};
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
} }
}; };
export const WithoutFooter: Story = { export const WithoutFooter: Story = {
args: { args: {
accounts: mockAccounts, accounts,
baseCurrency: 'USD', baseCurrency: 'USD',
deviceType: 'desktop', deviceType: 'desktop',
locale: 'en-US', locale: 'en-US',
showActions: false, showActions: false,
showAllocationInPercentage: true, showAllocationInPercentage: false,
showBalance: true, showBalance: true,
showFooter: false, showFooter: false,
showTransactions: true, showTransactions: true,
showValue: true, showValue: true,
showValueInBaseCurrency: true, showValueInBaseCurrency: true,
totalBalanceInBaseCurrency: 56600, totalBalanceInBaseCurrency: 12428.2,
totalValueInBaseCurrency: 161600, totalValueInBaseCurrency: 107971.70321466809,
transactionCount: 163 transactionCount: 12
} }
}; };

10
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 { MatTableDataSource, MatTableModule } from '@angular/material/table';
import { Router, RouterModule } from '@angular/router'; import { Router, RouterModule } from '@angular/router';
import { IonIcon } from '@ionic/angular/standalone'; import { IonIcon } from '@ionic/angular/standalone';
import { Account as AccountModel } from '@prisma/client'; import { Account } from '@prisma/client';
import { addIcons } from 'ionicons'; import { addIcons } from 'ionicons';
import { import {
arrowRedoOutline, arrowRedoOutline,
@ -54,7 +54,7 @@ import { Subject, Subscription } from 'rxjs';
templateUrl: './accounts-table.component.html' templateUrl: './accounts-table.component.html'
}) })
export class GfAccountsTableComponent implements OnChanges, OnDestroy { export class GfAccountsTableComponent implements OnChanges, OnDestroy {
@Input() accounts: AccountModel[]; @Input() accounts: Account[];
@Input() baseCurrency: string; @Input() baseCurrency: string;
@Input() deviceType: string; @Input() deviceType: string;
@Input() hasPermissionToOpenDetails = true; @Input() hasPermissionToOpenDetails = true;
@ -71,12 +71,12 @@ export class GfAccountsTableComponent implements OnChanges, OnDestroy {
@Input() transactionCount: number; @Input() transactionCount: number;
@Output() accountDeleted = new EventEmitter<string>(); @Output() accountDeleted = new EventEmitter<string>();
@Output() accountToUpdate = new EventEmitter<AccountModel>(); @Output() accountToUpdate = new EventEmitter<Account>();
@Output() transferBalance = new EventEmitter<void>(); @Output() transferBalance = new EventEmitter<void>();
@ViewChild(MatSort) sort: MatSort; @ViewChild(MatSort) sort: MatSort;
public dataSource = new MatTableDataSource<AccountModel>(); public dataSource = new MatTableDataSource<Account>();
public displayedColumns = []; public displayedColumns = [];
public isLoading = true; public isLoading = true;
public routeQueryParams: Subscription; public routeQueryParams: Subscription;
@ -167,7 +167,7 @@ export class GfAccountsTableComponent implements OnChanges, OnDestroy {
this.transferBalance.emit(); this.transferBalance.emit();
} }
public onUpdateAccount(aAccount: AccountModel) { public onUpdateAccount(aAccount: Account) {
this.accountToUpdate.emit(aAccount); this.accountToUpdate.emit(aAccount);
} }

2
libs/ui/src/lib/tags-selector/tags-selector.component.stories.ts

@ -21,7 +21,7 @@ const OPTIONS = [
{ {
id: '3ef7e6d9-4598-4eb2-b0e8-00e61cfc0ea6', id: '3ef7e6d9-4598-4eb2-b0e8-00e61cfc0ea6',
name: 'Gambling', name: 'Gambling',
userId: 'c6a71541-d0e3-4e22-ae83-b5e5611b6695' userId: '081aa387-487d-4438-83a4-3060eb2a016e'
}, },
{ {
id: 'EMERGENCY_FUND', id: 'EMERGENCY_FUND',

Loading…
Cancel
Save