All files / features / bot-accounts BotAccountsListTab.tsx

78.12% Statements 25/32
55% Branches 11/20
83.33% Functions 10/12
80.76% Lines 21/26

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 56 57        47x     24x               96x           24x             96x 24x           96x 96x     6x                 24x               24x
import { Outlet } from 'react-router-dom'
import { DataTable, Crud } from '@/layers/L2R'
import type { ListConfig, CrudConfig } from '@/layers/interfaces'
import { formatRelativeTime } from '@/shared/utils/format'
import { BOT_ACCOUNT_FIELD_SET, BOT_ACCOUNT_FIELD_TYPES } from './botAccountsCrudConfig'
 
export function BotAccountsListTab() {
  const listConfig: ListConfig = {
    entityPath: 'bot-accounts',
    prefix: 'botacct',
    columns: [
      {
        field: 'name',
        label: 'Name',
        sortable: true,
        render: (row) => <a href={`#/repositories/bot-accounts/${row.id}`}>{row.name as string}</a>,
      },
      {
        field: 'description',
        label: 'Description',
        sortable: true,
        render: (row) => (row.description ? String(row.description) : '\u2014'),
      },
      {
        field: 'created_at',
        label: 'Created',
        sortable: true,
        render: (row) => {
          const val = row.created_at as string | null | undefined
          return val ? formatRelativeTime(val) : 'Never'
        },
      },
    ],
    sort: { field: 'name', order: 'asc' },
    createTarget: '/repositories/bot-accounts/add',
    createLabel: '+ New Bot Account',
    rowTarget: '/repositories/bot-accounts/:id',
  }
 
  const crudConfig: CrudConfig = {
    entityPath: 'bot-accounts',
    fieldSet: BOT_ACCOUNT_FIELD_SET,
    fieldTypes: BOT_ACCOUNT_FIELD_TYPES,
    successTarget: '/repositories/bot-accounts/:id',
    cancelTarget: '/repositories/bot-accounts',
    title: 'Add New Bot Account',
  }
 
  return (
    <>
      <DataTable config={listConfig} />
      <Crud config={crudConfig} />
      <Outlet />
    </>
  )
}