Better map
This commit is contained in:
51
client/src/components/map/ObjectParameter.tsx
Normal file
51
client/src/components/map/ObjectParameter.tsx
Normal file
@ -0,0 +1,51 @@
|
||||
import React from 'react'
|
||||
import useSWR from 'swr'
|
||||
import { fetcher } from '../../http/axiosInstance'
|
||||
import { BASE_URL } from '../../constants'
|
||||
import { Checkbox, Flex, Grid } from '@mantine/core'
|
||||
import { IObjectParam, IParam } from '../../interfaces/objects'
|
||||
|
||||
const ObjectParameter = ({
|
||||
id_param,
|
||||
value
|
||||
}: IObjectParam) => {
|
||||
const { data: paramData } = useSWR(
|
||||
`/general/params/all?param_id=${id_param}`,
|
||||
(url) => fetcher(url, BASE_URL.ems).then(res => res[0] as IParam),
|
||||
{
|
||||
revalidateOnFocus: false
|
||||
}
|
||||
)
|
||||
|
||||
const Parameter = (type: string, name: string, value: unknown) => {
|
||||
switch (type) {
|
||||
case 'bit':
|
||||
return (
|
||||
<Grid align='center' gutter='xl'>
|
||||
<Grid.Col span={1}>
|
||||
<Checkbox defaultChecked={value as boolean} />
|
||||
</Grid.Col>
|
||||
<Grid.Col span={'auto'}>
|
||||
<p>{name}</p>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
)
|
||||
default:
|
||||
return (
|
||||
<div>
|
||||
Неподдерживаемый параметр
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{paramData &&
|
||||
Parameter(paramData.format, paramData.name, value)
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ObjectParameter
|
Reference in New Issue
Block a user