Files
universal_is/client/src/pages/Roles.tsx
cracklesparkle 0788a401ca Update
2025-01-30 12:36:39 +09:00

42 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { useRoles } from '../hooks/swrHooks'
import { CreateField } from '../interfaces/create'
import RoleService from '../services/RoleService'
import { Loader, Stack } from '@mantine/core'
import CustomTable from '../components/CustomTable'
export default function Roles() {
const { roles, isError, isLoading } = useRoles()
const createFields: CreateField[] = [
{ key: 'name', headerName: 'Название', type: 'string', required: true, defaultValue: '' },
{ key: 'description', headerName: 'Описание', type: 'string', required: false, defaultValue: '' },
]
if (isError) return <div>Произошла ошибка при получении данных.</div>
if (isLoading) return <Loader />
return (
<Stack w={'100%'} h={'100%'} p='sm'>
<CustomTable
createFields={createFields}
submitHandler={RoleService.createRole}
data={roles} columns={[
{
accessorKey: 'id',
header: 'id',
cell: (info) => info.getValue(),
},
{
accessorKey: 'name',
header: 'Название',
cell: (info) => info.getValue(),
},
{
accessorKey: 'description',
header: 'Описание',
cell: (info) => info.getValue(),
},
]} />
</Stack>
)
}