chore: Move i18nApply localization to the account transformer

This commit is contained in:
Ahmed Bouhuolia
2024-10-15 19:27:15 +02:00
parent fd4d86e797
commit c929a7cb27
2 changed files with 19 additions and 5 deletions

View File

@@ -14,6 +14,8 @@ export class AccountTransformer extends Transformer {
*/ */
public includeAttributes = (): string[] => { public includeAttributes = (): string[] => {
return [ return [
'accountTypeLabel',
'accountNormalFormatted',
'formattedAmount', 'formattedAmount',
'flattenName', 'flattenName',
'bankBalanceFormatted', 'bankBalanceFormatted',
@@ -84,6 +86,22 @@ export class AccountTransformer extends Transformer {
return account.plaidItem?.isPaused || false; return account.plaidItem?.isPaused || false;
}; };
/**
* Retrieves formatted account type label.
* @returns {string}
*/
protected accountTypeLabel = (account: any): string => {
return this.context.i18n.__(account.accountTypeLabel);
};
/**
* Retrieves formatted account normal.
* @returns {string}
*/
protected accountNormalFormatted = (account: any): string => {
return this.context.i18n.__(account.accountNormalFormatted);
};
/** /**
* Transformes the accounts collection to flat or nested array. * Transformes the accounts collection to flat or nested array.
* @param {IAccount[]} * @param {IAccount[]}

View File

@@ -51,10 +51,6 @@ export class GetAccount {
// Triggers `onAccountViewed` event. // Triggers `onAccountViewed` event.
await this.eventPublisher.emitAsync(events.accounts.onViewed, eventPayload); await this.eventPublisher.emitAsync(events.accounts.onViewed, eventPayload);
return this.i18nService.i18nApply( return transformed;
[['accountTypeLabel'], ['accountNormalFormatted']],
transformed,
tenantId
);
}; };
} }