-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new way to select services on bath and grooming
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
1 parent
94bdcd5
commit 94d3314
Showing
1 changed file
with
12 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); |