forked from VinokurovVE/tests
123 lines
4.3 KiB
TypeScript
123 lines
4.3 KiB
TypeScript
import useSWR from 'swr'
|
|
import { fetcher } from '../../http/axiosInstance'
|
|
import { BASE_URL } from '../../constants'
|
|
import { Text } from '@mantine/core'
|
|
import TableValue from './TableValue'
|
|
|
|
interface ITCBParameterProps {
|
|
value: string,
|
|
vtable: string,
|
|
inactive?: boolean,
|
|
name: string
|
|
}
|
|
|
|
const TCBParameter = ({
|
|
value,
|
|
vtable,
|
|
name
|
|
}: ITCBParameterProps) => {
|
|
|
|
//Get value
|
|
const { data: tcbValue } = useSWR(
|
|
`/general/params/tcb?id=${value}&vtable=${vtable}`,
|
|
(url) => fetcher(url, BASE_URL.ems).then(res => res[0]),
|
|
{
|
|
revalidateOnFocus: false,
|
|
revalidateIfStale: false
|
|
}
|
|
)
|
|
|
|
const TCBValue = (vtable: string) => {
|
|
switch (vtable) {
|
|
case 'vStreets':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'tTypes':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vPipesGround':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vRepairEvent':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vPipesMaterial':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vBoilers':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vHotWaterTypes':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vHeatingTypes':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vColdWaterTypes':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vCanalization':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vElectroSupplyTypes':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vGasSupplyTypes':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vFoundation':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vMaterialsWall':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vCovering':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vRoof':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vTechStatus':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vPipeOutDiameters':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
case 'vPipeDiameters':
|
|
return (
|
|
<TableValue value={tcbValue?.id} name={name} type='select' vtable={vtable} />
|
|
)
|
|
default:
|
|
return (
|
|
<Text>
|
|
{JSON.stringify(name)}
|
|
{JSON.stringify(tcbValue)}
|
|
</Text>
|
|
)
|
|
}
|
|
}
|
|
|
|
return (
|
|
TCBValue(vtable)
|
|
)
|
|
}
|
|
|
|
export default TCBParameter |