refactoring: retrieve resources fields.

fix: issue in create a new custom view.
This commit is contained in:
Ahmed Bouhuolia
2020-10-17 15:00:22 +02:00
parent 7397afe2a9
commit 27ec0e91fa
13 changed files with 228 additions and 83 deletions

View File

@@ -1,4 +1,5 @@
import { Inject, Service } from 'typedi';
import { omit } from 'lodash';
import TenancyService from 'services/Tenancy/TenancyService';
import { IAccountsTypesService, IAccountType } from 'interfaces';
@@ -12,8 +13,17 @@ export default class AccountsTypesService implements IAccountsTypesService{
* @param {number} tenantId -
* @return {Promise<IAccountType>}
*/
getAccountsTypes(tenantId: number): Promise<IAccountType> {
async getAccountsTypes(tenantId: number): Promise<IAccountType> {
const { accountTypeRepository } = this.tenancy.repositories(tenantId);
return accountTypeRepository.all();
const { AccountType } = this.tenancy.models(tenantId);
const { __ } = this.tenancy.i18n(tenantId);
const allAccountsTypes = await accountTypeRepository.all();
return allAccountsTypes.map((_accountType: IAccountType) => ({
id: _accountType.id,
label: __(AccountType.labels[_accountType.key]),
...omit(_accountType, ['id']),
}));
}
}