All files / features / projects ProjectsPage.tsx

60.71% Statements 17/28
43.75% Branches 7/16
62.5% Functions 5/8
68% Lines 17/25

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      73x     22x 22x           22x             80x                             22x        
import { Outlet } from 'react-router-dom'
import { Page, DataTable, Crud } from '@/layers/L2R'
import type { PageConfig, ListConfig, CrudConfig } from '@/layers/interfaces'
import { PROJECT_FIELD_SET, PROJECT_FIELD_TYPES } from './projectsCrudConfig'
 
export function ProjectsPage() {
  const pageConfig: PageConfig = { title: 'Projects' }
 
  const listConfig: ListConfig = {
    entityPath: 'projects',
    prefix: 'projs',
    columns: [
      { field: 'name', label: 'Name', sortable: true },
      { field: 'description', label: 'Description', sortable: true, render: (row) => (row.description ? String(row.description) : '\u2014') },
      { field: 'pipeline_count', label: 'Pipelines' },
    ],
    sort: { field: 'name', order: 'asc' },
    createTarget: '/projects/add',
    createLabel: '+ New Project',
    rowTarget: '/projects/:id',
  }
 
  const crudConfig: CrudConfig = {
    entityPath: 'projects',
    fieldSet: PROJECT_FIELD_SET,
    fieldTypes: PROJECT_FIELD_TYPES,
    successTarget: '/projects/:id',
    cancelTarget: '/projects',
    title: 'Add New Project',
  }
 
  return (
    <Page config={pageConfig}>
      <DataTable config={listConfig} />
      <Crud config={crudConfig} />
      <Outlet />
    </Page>
  )
}