Skip to content

Commit

Permalink
Merge pull request #146 from fga-gpp-mds/devel
Browse files Browse the repository at this point in the history
T07 - Refatorar Código
  • Loading branch information
LucasPenido authored Dec 11, 2017
2 parents 0defc83 + a4ff554 commit 638e69f
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 37 deletions.
75 changes: 50 additions & 25 deletions __tests__/screens/__snapshots__/RegisterScreen.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,8 @@ exports[`Testing RegisterScreen renders as expected 1`] = `
</Text>
<DropdownComponent
callback={[Function]}
picker={
pickerBody={
Array [
<PickerItem
color="#95a5a6"
label="Escolha seu cargo"
value=""
/>,
<PickerItem
label="Presidente"
value={true}
Expand All @@ -148,6 +143,15 @@ exports[`Testing RegisterScreen renders as expected 1`] = `
/>,
]
}
pickerTitle={
Array [
<PickerItem
color="#95a5a6"
label="Escolha seu cargo"
value=""
/>,
]
}
selectedValue=""
/>
<Text
Expand All @@ -160,13 +164,8 @@ exports[`Testing RegisterScreen renders as expected 1`] = `
</Text>
<DropdownComponent
callback={[Function]}
picker={
pickerBody={
Array [
<PickerItem
color="#95a5a6"
label="Escolha seu cargo"
value=""
/>,
<PickerItem
label="Titular"
value="Titular"
Expand All @@ -177,6 +176,15 @@ exports[`Testing RegisterScreen renders as expected 1`] = `
/>,
]
}
pickerTitle={
Array [
<PickerItem
color="#95a5a6"
label="Escolha seu cargo"
value=""
/>,
]
}
selectedValue=""
/>
<Text
Expand All @@ -189,13 +197,8 @@ exports[`Testing RegisterScreen renders as expected 1`] = `
</Text>
<DropdownComponent
callback={[Function]}
picker={
pickerBody={
Array [
<PickerItem
color="#95a5a6"
label="Escolha seu segmento"
value=""
/>,
<PickerItem
label="Poder executivo"
value="Poder executivo"
Expand All @@ -214,6 +217,15 @@ exports[`Testing RegisterScreen renders as expected 1`] = `
/>,
]
}
pickerTitle={
Array [
<PickerItem
color="#95a5a6"
label="Escolha seu segmento"
value=""
/>,
]
}
selectedValue=""
/>
<Text
Expand All @@ -226,13 +238,8 @@ exports[`Testing RegisterScreen renders as expected 1`] = `
</Text>
<DropdownComponent
callback={[Function]}
picker={
pickerBody={
Array [
<PickerItem
color="#95a5a6"
label="Escolha o Tipo do seu CAE"
value=""
/>,
<PickerItem
label="Municipal"
value="Municipal"
Expand All @@ -243,6 +250,15 @@ exports[`Testing RegisterScreen renders as expected 1`] = `
/>,
]
}
pickerTitle={
Array [
<PickerItem
color="#95a5a6"
label="Escolha o Tipo do seu CAE"
value=""
/>,
]
}
selectedValue=""
/>
<Text
Expand All @@ -255,7 +271,7 @@ exports[`Testing RegisterScreen renders as expected 1`] = `
</Text>
<DropdownComponent
callback={[Function]}
picker={
pickerBody={
Array [
<PickerItem
color="#000000"
Expand Down Expand Up @@ -394,6 +410,15 @@ exports[`Testing RegisterScreen renders as expected 1`] = `
/>,
]
}
pickerTitle={
Array [
<PickerItem
color="#95a5a6"
label="Escolha a UF do seu CAE"
value=""
/>,
]
}
selectedValue=""
/>
<Text
Expand Down
6 changes: 4 additions & 2 deletions src/components/DropdownComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const DropdownComponent = props => (
onValueChange={checkedAttribute => props.callback(checkedAttribute)}
selectedValue={props.selectedValue}
>
{props.picker}
{props.pickerTitle}
{props.pickerBody}

</Picker>
</View>
Expand All @@ -20,7 +21,8 @@ const DropdownComponent = props => (
DropdownComponent.propTypes = {
selectedValue: PropTypes.string.isRequired,
callback: PropTypes.func.isRequired,
picker: PropTypes.element.isRequired,
pickerTitle: PropTypes.element.isRequired,
pickerBody: PropTypes.element.isRequired,
};

export default DropdownComponent;
10 changes: 6 additions & 4 deletions src/components/MunicipalDistrict.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import DropdownComponent from './DropdownComponent';

const MunicipalDistrict = props => (
<View key="municipalDistrict" >
<Text>Municipio do CAE</Text>
<Text>Município do CAE</Text>

<DropdownComponent
selectedValue={props.selectedValue}
callback={checkedValue => props.callback(checkedValue)}
picker={[
<Picker.Item value="" label="Escolha o Municipio do seu CAE" color="#95a5a6" />,
] && municipalDistricts[props.UfInitials].cidades.map(item =>
pickerTitle={[
<Picker.Item value="" label="Escolha o Município do seu CAE" color="#95a5a6" />,
]}
pickerBody={
municipalDistricts[props.UfInitials].cidades.map(item =>
(<Picker.Item label={item} value={`${item} -`} color="#000000" />))}
/>

Expand Down
23 changes: 17 additions & 6 deletions src/screens/RegisterScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,10 @@ export default class RegisterScreen extends React.Component {
this.setState(
{ profile: { ...this.state.profile, isPresident: isPresidentChecked } },
)}
picker={[
pickerTitle={[
<Picker.Item value="" label="Escolha seu cargo" color="#95a5a6" />,
]}
pickerBody={[
<Picker.Item value label={PRESIDENT_COUNSELOR} />,
<Picker.Item value={false} label={COMMON_COUNSELOR} />,
]}
Expand All @@ -310,8 +312,11 @@ export default class RegisterScreen extends React.Component {
callback={counselorTypeChecked => this.setState(
{ profile: { ...this.state.profile, counselorType: counselorTypeChecked } },
)}
picker={[
pickerTitle={[
<Picker.Item value="" label="Escolha seu cargo" color="#95a5a6" />,
]}
pickerBody={[

<Picker.Item value={TITULAR_COUNSELOR} label={TITULAR_COUNSELOR} />,
<Picker.Item value={SURROGATE_COUNSELOR} label={SURROGATE_COUNSELOR} />,
]}
Expand All @@ -326,8 +331,10 @@ export default class RegisterScreen extends React.Component {
segment: segmentChecked,
},
})}
picker={[
pickerTitle={[
<Picker.Item value="" label="Escolha seu segmento" color="#95a5a6" />,
]}
pickerBody={[
<Picker.Item value={EXECUTIVE_POWER} label={EXECUTIVE_POWER} />,
<Picker.Item value={EDUCATION_WORKERS} label={EDUCATION_WORKERS} />,
<Picker.Item value={STUDENT_PARENTS} label={STUDENT_PARENTS} />,
Expand Down Expand Up @@ -357,8 +364,10 @@ export default class RegisterScreen extends React.Component {
},
})
)}
picker={[
pickerTitle={[
<Picker.Item value="" label="Escolha o Tipo do seu CAE" color="#95a5a6" />,
]}
pickerBody={[
<Picker.Item value={MUNICIPAL_COUNSELOR_CAE} label={MUNICIPAL_COUNSELOR_CAE} />,
<Picker.Item value={STATE_COUNSELOR_CAE} label={STATE_COUNSELOR_CAE} />,
]}
Expand All @@ -371,12 +380,14 @@ export default class RegisterScreen extends React.Component {
profile: {
...this.state.profile,
CAE_UF: checkedUf,
CAE_municipalDistrict: '',
CAE: `${this.state.profile.CAE_municipalDistrict} ${checkedUf.substr(0, 2)}`.trim(),
},
})}
picker={[
pickerTitle={[
<Picker.Item value="" label="Escolha a UF do seu CAE" color="#95a5a6" />,
] &&
]}
pickerBody={
brazilianStates.estados.map(
item => (<Picker.Item label={item} value={item} color="#000000" />))}
/>
Expand Down

0 comments on commit 638e69f

Please sign in to comment.