import { Checkbox, ComboboxData, Grid, NumberInput, Select, Text, Textarea } from '@mantine/core'; import useSWR from 'swr'; import { fetcher } from '../../http/axiosInstance'; import { BASE_URL } from '../../constants'; import { useObjectsStore } from '../../store/objects'; interface TableValueProps { name: string; value: unknown; type: 'value' | 'boolean' | 'number' | 'select' | 'string'; unit?: string | null | undefined; vtable?: string; } const TableValue = ({ name, value, type, unit, vtable }: TableValueProps) => { const { selectedDistrict } = useObjectsStore() //Get available values const { data: tcbAll, isValidating } = useSWR( type === 'select' && selectedDistrict ? `/general/params/tcb?vtable=${vtable}&id_city=${selectedDistrict}` : null, (url) => fetcher(url, BASE_URL.ems).then(res => { if (Array.isArray(res)) { return res.map((el) => ({ label: el.name || "", value: JSON.stringify(el.id) })) as ComboboxData } }), { revalidateOnFocus: false, revalidateIfStale: false } ) return ( {name as string} {type === 'boolean' ? : type === 'number' ? { }} suffix={unit ? ` ${unit}` : ''} /> : type === 'select' && !isValidating && tcbAll ?