Skip to content

Commit

Permalink
Add new way to select services on bath and grooming
Browse files Browse the repository at this point in the history
Related to issue #14

Signed-off-by: Flavio Costa <[email protected]>
Signed-off-by: Mateus Vieira <[email protected]>
Signed-off-by: Luiz Guilherme Silva <[email protected]
  • Loading branch information
mateusroriz committed Jun 4, 2017
1 parent 94bdcd5 commit 94d3314
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/Categories/BathAndGrooming/BathAndGroomingCreate.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
import React from 'react';
import {
Create,
LongTextInput,
SimpleForm,
RadioButtonGroupInput,
} from 'admin-on-rest/lib/mui';
// Global variables
import { minimumServiceLength, maximumServiceLength } from './index';

const validationIsEmpty = (values) => {
const errors = {};

if (!values.serviceBathGrooming) {
errors.serviceBathGrooming = ['Campo obrigatório'];
} else if (values.serviceBathGrooming.length < minimumServiceLength) {
errors.serviceBathGrooming = ['Campo muito pequeno'];
} else if (values.serviceBathGrooming.length > maximumServiceLength) {
errors.serviceBathGrooming = ['Campo muito longo'];
}
return errors;
};
import { required } from '../Validators' ;

export const BathAndGroomingCreate = props => (
<Create {...props} title={'Adicionar Serviço'}>
<SimpleForm validation={validationIsEmpty}>
<LongTextInput source="serviceBathGrooming" label="Serviço" />
<SimpleForm>
<RadioButtonGroupInput
source="serviceBathGrooming"
validate={required}
label="Serviço"
choices={[
{ id: "Banho", name: "Banho"},
{ id: "Banho e Tosa", name: "Banho e Tosa"},
]}
/>
</SimpleForm>
</Create>
);

0 comments on commit 94d3314

Please sign in to comment.