Skip to content

Commit

Permalink
Change UserCreate style and add required validation
Browse files Browse the repository at this point in the history
Related to issue #9

Signed-off-by: Luiz Guilherme Silva <[email protected]>
Signed-off-by: Marcelo Oliveira <[email protected]>
  • Loading branch information
luizguilherme5 committed Apr 23, 2017
1 parent 0c06286 commit cdbd99d
Showing 1 changed file with 45 additions and 11 deletions.
56 changes: 45 additions & 11 deletions src/Categories/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ const UserFilter = props => (
</Filter>
);

const TextInputValidation = (value) => {
if (!value) {
return ['Campo obrigatório'];
}
return [];
};

export const UserList = props => (
<List {...props} filters={<UserFilter />} title={'Lista de Usuários'}>
<Responsive
Expand All @@ -35,26 +42,53 @@ export const UserList = props => (

const UserName = ({ record }) => {
return <span>Usuário {record ? `"${record.userName}"` : ''}</span>;
export const UserCreate = props => (
<Create {...props}>
<SimpleForm>
<TextInput
source="userFullName"
label="Nome Completo"
validation="{TextInputValidation}"
/>
<TextInput
source="userName"
label="Nome de Usuário"
validation="{TextInputValidation}"
/>
<TextInput
type="password"
source="userPassword"
label="Senha"
validation="{TextInputValidation}"
/>
</SimpleForm>
</Create>
);

const UserName = ({ user }) => {
return <span>Usuário {user ? `"${user.userName}"` : ''}</span>;
};

export const UserEdit = props => (
<Edit title={<UserName />} {...props}>
<SimpleForm>
<TextInput source="userFullName" label="Nome Completo" />
<TextInput source="userName" label="Nome de Usuário" />
<TextInput type="password" source="userPassword" label="Senha" />
<TextInput
source="userFullName"
label="Nome Completo"
/>
<TextInput
source="userName"
label="Nome de Usuário"
/>
<TextInput
type="password"
source="userPassword"
label="Senha"
/>
</SimpleForm>
</Edit>
);

export const UserCreate = props => (
<Create {...props}>
<SimpleForm>
<TextInput source="userFullName" label="Nome Completo" />
<TextInput source="userName" label="Nome de Usuário" />
<TextInput type="password" source="userPassword" label="Senha" />
</SimpleForm>
</Create>
export const UserShow = props => (
<Show title={<UserName />} {...props}>
<SimpleShowLayout>
Expand Down

0 comments on commit cdbd99d

Please sign in to comment.