All files / features / llm-configs LlmConfigDetailPage.tsx

78.12% Statements 25/32
56.52% Branches 13/23
87.5% Functions 7/8
86.2% Lines 25/29

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          51x   51x   18x 18x 18x 18x                           18x                                     20x   20x 20x       18x        
import { Outlet, useParams } from 'react-router-dom'
import { Page, EntityDetail, Crud } from '@/layers/L2R'
import type { PageConfig, DetailConfig, CrudConfig } from '@/layers/interfaces'
import { useEntityDetail } from '@/layers/L1/entityResolver'
import { formatDateTime } from '@/shared/utils/format'
import { LLM_CONFIG_FIELD_SET, LLM_CONFIG_FIELD_TYPES } from './llmConfigsCrudConfig'
 
export function LlmConfigDetailPage() {
  const { id } = useParams<{ id: string }>()
  const { data: config } = useEntityDetail('llm-configs', id ?? '')
 
  const pageConfig: PageConfig = {
    title: config?.name ?? 'LLM Config',
    breadcrumbs: [
      { label: 'Dashboard', href: '/' },
      { label: 'LLM Configs', href: '/llm-configs' },
      { label: config?.name ?? id ?? '' },
    ],
  }
 
  const detailConfig: DetailConfig = {
    entityPath: 'llm-configs',
    title: 'LLM Provider',
    actionTargets: { edit: '/llm-configs/:id/edit', delete: true },
    readGrouping: [
      {
        label: 'Details',
        fields: ['name', 'model', 'base_url', 'default_temperature', 'created_at', 'created_by'],
      },
    ],
    fieldFormatters: {
      created_at: (value: unknown) => formatDateTime(value as string | null | undefined),
      default_temperature: (value: unknown) => {
        if (value === undefined || value === null) return '\u2014'
        return String(value)
      },
    },
  }
 
  const crudConfig: CrudConfig = {
    entityPath: 'llm-configs',
    fieldSet: LLM_CONFIG_FIELD_SET,
    fieldTypes: LLM_CONFIG_FIELD_TYPES,
    successTarget: '/llm-configs/:id',
    cancelTarget: '/llm-configs/:id',
    title: 'Edit LLM Provider',
  }
I
  return (
    <Page config={pageConfig}>
      <EntityDetail config={detailConfig} />
      <Crud config={crudConfig} />
      <Outlet />
    </Page>
  )
}