-
Notifications
You must be signed in to change notification settings - Fork 73
/
accountsTableDataFactory.tsx
55 lines (51 loc) · 1.44 KB
/
accountsTableDataFactory.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React from 'react'
import { sortable } from '@patternfly/react-table'
import { IDeveloperAccount } from 'types'
import { TFunction } from 'i18next'
import { ActionButtonImpersonate } from 'components/pages/accounts'
const generateRows = (accounts: IDeveloperAccount[]) => {
const isMultitenant = process.env.REACT_APP_MULTITENANT
// Rows and Columns must have the same order
const mapAccountToRowCell = (account: IDeveloperAccount) => [
account.org_name,
account.admin_name,
account.created_at,
account.state,
{
title: isMultitenant ? <ActionButtonImpersonate /> : ''
}
]
return accounts.map((a) => ({
id: a.id,
cells: mapAccountToRowCell(a),
selected: false
}))
}
// Filterable columns must have an id equal to its category name
const generateColumns = (t: TFunction) => [
{
categoryName: 'group',
title: t('accountsIndex:accounts_table.group_header'),
transforms: [sortable]
},
{
categoryName: 'admin',
title: t('accountsIndex:accounts_table.admin_header'),
transforms: [sortable]
},
{
categoryName: 'signup',
title: t('accountsIndex:accounts_table.signup_header'),
transforms: [sortable]
},
{
categoryName: 'state',
title: t('accountsIndex:accounts_table.state_header'),
transforms: [sortable]
},
{
categoryName: 'actions',
title: t('shared:shared_elements.actions_header_plural')
}
]
export { generateColumns, generateRows }