import useSWR from 'swr' import { fetcher } from '../../http/axiosInstance' import { BASE_URL } from '../../constants' import { IObjectParam, IParam } from '../../interfaces/objects' import TCBParameter from './TCBParameter' import TableValue from './TableValue' import { TableCell, TableCellLayout, TableRow } from '@fluentui/react-components' interface ObjectParameterProps { showLabel?: boolean; param: IObjectParam; map_id: string; } const ObjectParameter = ({ param, map_id }: ObjectParameterProps) => { const { data: paramData } = useSWR( `/general/params/?param_id=${param.id_param}`, (url) => fetcher(url, BASE_URL.ems).then(res => res[0] as IParam), { revalidateOnFocus: false, revalidateIfStale: false } ) const Parameter = (type: string, name: string, value: unknown, vtable: string, unit: string | null) => { switch (type) { case 'bit': return ( ) case 'int': return ( ) case 'bigint': return ( ) case 'tinyint': return ( ) // TODO: Calculate from calc procedures case 'calculate': return ( ) case 'GTCB': return ( ) case 'TCB': return ( ) case type.match(/varchar\((\d+)\)/)?.input: return ( ) case type.match(/numeric\((\d+),(\d+)\)/)?.input: return ( ) case 'year': return ( ) case 'uniqueidentifier': return ( ) default: return ( {name} {value as string} ) } } return ( <> {paramData && Parameter(paramData.format, paramData.name, param.value, paramData.vtable, paramData.unit) } ) } export default ObjectParameter