init /article route

This commit is contained in:
maxim
2025-02-04 14:44:56 +03:00
parent b3863e5aef
commit b1c7fb5582
6 changed files with 183 additions and 2 deletions

View File

@ -0,0 +1,49 @@
import {Box, TextField} from '@mui/material'
import {Create} from '@refinedev/mui'
import {useForm} from '@refinedev/react-hook-form'
export const ArticleCreate = () => {
const {
saveButtonProps,
refineCore: {formLoading},
register,
formState: {errors},
} = useForm({
refineCoreProps: {
resource: 'article/',
},
})
return (
<Create isLoading={formLoading} saveButtonProps={saveButtonProps}>
<Box component="form" sx={{display: 'flex', flexDirection: 'column'}} autoComplete="off">
<TextField
{...register('heading', {
required: 'This field is required',
})}
error={!!(errors as any)?.title}
helperText={(errors as any)?.title?.message}
margin="normal"
fullWidth
InputLabelProps={{shrink: true}}
type="text"
label={'Heading'}
name="heading"
/>
<TextField
{...register('body', {
required: 'This field is required',
})}
error={!!(errors as any)?.title}
helperText={(errors as any)?.title?.message}
margin="normal"
fullWidth
InputLabelProps={{shrink: true}}
type="text"
label={'Body'}
name="body"
/>
</Box>
</Create>
)
}