mirror of
https://github.com/strapi/strapi.git
synced 2026-01-07 20:58:16 +00:00
Fix edit a role
Signed-off-by: HichamELBSI <elabbassih@gmail.com>
This commit is contained in:
parent
b68245b8b1
commit
00e6b008e7
@ -73,7 +73,7 @@ const CreatePage = () => {
|
||||
|
||||
return (
|
||||
<Formik
|
||||
initialValues={{ name: null, description: null }}
|
||||
initialValues={{ name: '', description: '' }}
|
||||
onSubmit={handleCreateRoleSubmit}
|
||||
validationSchema={schema}
|
||||
>
|
||||
|
||||
@ -7,12 +7,12 @@ import FormCard from '../FormBloc';
|
||||
import SizedInput from '../SizedInput';
|
||||
import ButtonWithNumber from './ButtonWithNumber';
|
||||
|
||||
const RoleForm = ({ usersCount, values, errors, onChange, onBlur, isLoading }) => {
|
||||
const RoleForm = ({ role, values, errors, onChange, onBlur, isLoading }) => {
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
const actions = [
|
||||
<ButtonWithNumber
|
||||
number={usersCount}
|
||||
number={role.usersCount}
|
||||
onClick={() => console.log('Open user modal')}
|
||||
key="user-button"
|
||||
>
|
||||
@ -26,12 +26,20 @@ const RoleForm = ({ usersCount, values, errors, onChange, onBlur, isLoading }) =
|
||||
<FormCard
|
||||
actions={actions}
|
||||
isLoading={isLoading}
|
||||
title={formatMessage({
|
||||
id: 'Settings.roles.form.title',
|
||||
})}
|
||||
subtitle={formatMessage({
|
||||
id: 'Settings.roles.form.description',
|
||||
})}
|
||||
title={
|
||||
role
|
||||
? role.name
|
||||
: formatMessage({
|
||||
id: 'Settings.roles.form.title',
|
||||
})
|
||||
}
|
||||
subtitle={
|
||||
role
|
||||
? role.description
|
||||
: formatMessage({
|
||||
id: 'Settings.roles.form.description',
|
||||
})
|
||||
}
|
||||
>
|
||||
<NameInput
|
||||
label={formatMessage({
|
||||
@ -63,7 +71,7 @@ const RoleForm = ({ usersCount, values, errors, onChange, onBlur, isLoading }) =
|
||||
|
||||
RoleForm.defaultProps = {
|
||||
isLoading: false,
|
||||
usersCount: 0,
|
||||
role: null,
|
||||
values: { name: '', description: '' },
|
||||
};
|
||||
RoleForm.propTypes = {
|
||||
@ -71,7 +79,7 @@ RoleForm.propTypes = {
|
||||
isLoading: PropTypes.bool,
|
||||
onBlur: PropTypes.func.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
usersCount: PropTypes.number,
|
||||
role: PropTypes.object,
|
||||
values: PropTypes.object,
|
||||
};
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@ const EditPage = () => {
|
||||
values={values}
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
usersCount={role.usersCount}
|
||||
role={role}
|
||||
/>
|
||||
{!isLayoutLoading && !isRoleLoading && (
|
||||
<Padded top size="md">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user