forked from VinokurovVE/tests
Cleanup, shared create modal
This commit is contained in:
@ -2,13 +2,20 @@ import { useState } from 'react'
|
||||
import { Box, Button, CircularProgress } from '@mui/material'
|
||||
import { DataGrid, GridColDef } from '@mui/x-data-grid'
|
||||
import { useRoles } from '../hooks/swrHooks'
|
||||
import CreateRoleModal from '../components/modals/CreateRoleModal'
|
||||
import { CreateField } from '../interfaces/create'
|
||||
import ModalCreate from '../components/modals/ModalCreate'
|
||||
import RoleService from '../services/RoleService'
|
||||
|
||||
export default function Roles() {
|
||||
const { roles, isError, isLoading } = useRoles()
|
||||
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
const createFields: CreateField[] = [
|
||||
{ key: 'name', headerName: 'Название', type: 'string', required: true, defaultValue: '' },
|
||||
{ key: 'description', headerName: 'Описание', type: 'string', required: false, defaultValue: '' },
|
||||
]
|
||||
|
||||
const columns: GridColDef[] = [
|
||||
{ field: 'id', headerName: 'ID', type: "number", width: 70 },
|
||||
{ field: 'name', headerName: 'Название', width: 90, editable: true },
|
||||
@ -30,9 +37,12 @@ export default function Roles() {
|
||||
Добавить роль
|
||||
</Button>
|
||||
|
||||
<CreateRoleModal
|
||||
<ModalCreate
|
||||
open={open}
|
||||
setOpen={setOpen}
|
||||
fields={createFields}
|
||||
submitHandler={RoleService.createRole}
|
||||
title="Создание роли"
|
||||
/>
|
||||
|
||||
<DataGrid
|
||||
|
Reference in New Issue
Block a user