Better map

This commit is contained in:
cracklesparkle
2024-10-29 15:08:23 +09:00
parent 115c6ec417
commit f51835584d
20 changed files with 685 additions and 444 deletions

View 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