Skip to content

Commit 99ff114

Browse files
committed
edicoes de campos funcionais
1 parent 1c15acc commit 99ff114

File tree

6 files changed

+52
-62
lines changed

6 files changed

+52
-62
lines changed

src/views/editViews/EditCaracScreen.jsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ class EditCarac extends Component {
1919

2020
editCaracteristica = async () => {
2121
const item = {
22-
id: this.props.actualIdenty.id,
23-
name: this.props.actualIdenty.name,
24-
pronome: this.props.actualIdenty.pronome,
25-
genero: this.props.actualIdenty.genero,
26-
idade: this.props.actualIdenty.idade,
27-
caracteristica: this.state.caracteristica,
28-
descricao: this.props.actualIdenty.descricao,
29-
photo: this.props.actualIdenty.photo,
22+
id: this.props.id,
23+
identy: {
24+
...this.props.actualIdenty,
25+
caracteristica: this.state.caracteristica,
26+
},
3027
};
3128
this.props.onEdit(item);
3229
this.props.navigation.goBack();
@@ -104,8 +101,8 @@ const mapStateToProps = ({ user, actualIdenty }) => {
104101
const mapDispatchToProps = dispatch => {
105102
return {
106103
onEdit: identy => {
107-
dispatch(editIdenty({ id: this.props.id, identy: identy }));
108-
dispatch(changeActualIdenty(identy));
104+
dispatch(editIdenty(identy));
105+
dispatch(changeActualIdenty(identy.identy));
109106
},
110107
};
111108
};

src/views/editViews/EditDescripScreen.jsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@ class EditDescrip extends Component {
1414

1515
editDescrip = async () => {
1616
const item = {
17-
id: this.props.actualIdenty.id,
18-
name: this.props.actualIdenty.name,
19-
pronome: this.props.actualIdenty.pronome,
20-
genero: this.props.actualIdenty.genero,
21-
idade: this.props.actualIdenty.idade,
22-
caracteristica: this.props.actualIdenty.caracteristica,
23-
descricao: this.state.descrip,
24-
photo: this.props.actualIdenty.photo,
17+
id: this.props.id,
18+
identy: {
19+
...this.props.actualIdenty,
20+
descricao: this.state.descrip,
21+
},
2522
};
2623
this.props.onEdit(item);
2724
this.props.navigation.goBack();
@@ -111,8 +108,8 @@ const mapStateToProps = ({ user, actualIdenty }) => {
111108
const mapDispatchToProps = dispatch => {
112109
return {
113110
onEdit: identy => {
114-
dispatch(editIdenty({ id: this.props.id, identy: identy }));
115-
dispatch(changeActualIdenty(identy));
111+
dispatch(editIdenty(identy));
112+
dispatch(changeActualIdenty(identy.identy));
116113
},
117114
};
118115
};

src/views/editViews/EditGeneroScreen.jsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@ class EditGenero extends Component {
1414

1515
editGenero = async () => {
1616
const item = {
17-
id: this.props.actualIdenty.id,
18-
name: this.props.actualIdenty.name,
19-
pronome: this.props.actualIdenty.pronome,
20-
genero: this.state.gender,
21-
idade: this.props.actualIdenty.idade,
22-
caracteristica: this.props.actualIdenty.caracteristica,
23-
descricao: this.props.actualIdenty.descricao,
24-
photo: this.props.actualIdenty.photo,
17+
id: this.props.id,
18+
identy: {
19+
...this.props.actualIdenty,
20+
genero: this.state.gender ? this.state.gender : '',
21+
},
2522
};
2623
this.props.onEdit(item);
2724
this.props.navigation.goBack();
@@ -111,8 +108,8 @@ const mapStateToProps = ({ user, actualIdenty }) => {
111108
const mapDispatchToProps = dispatch => {
112109
return {
113110
onEdit: identy => {
114-
dispatch(editIdenty({ id: this.props.id, identy: identy }));
115-
dispatch(changeActualIdenty(identy));
111+
dispatch(editIdenty(identy));
112+
dispatch(changeActualIdenty(identy.identy));
116113
},
117114
};
118115
};

src/views/editViews/EditIdadeScreen.jsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@ import { changeActualIdenty } from '../../store/actions/viewIdenty';
99

1010
class EditIdade extends Component {
1111
state = {
12-
idade: this.props.actualIdenty.idade.toString(),
12+
idade: this.props.actualIdenty.idade !== -1 ? this.props.actualIdenty.idade.toString() : '',
1313
};
1414

1515
editIdade = async () => {
1616
const item = {
17-
id: this.props.actualIdenty.id,
18-
name: this.props.actualIdenty.name,
19-
pronome: this.props.actualIdenty.pronome,
20-
genero: this.props.actualIdenty.genero,
21-
idade: parseInt(this.state.idade, 10),
22-
caracteristica: this.props.actualIdenty.caracteristica,
23-
descricao: this.props.actualIdenty.descricao,
24-
photo: this.props.actualIdenty.photo,
17+
id: this.props.id,
18+
identy: {
19+
...this.props.actualIdenty,
20+
idade: this.state.idade ? parseInt(this.state.idade, 10) : -1,
21+
},
2522
};
2623
this.props.onEdit(item);
2724
this.props.navigation.goBack();
@@ -111,8 +108,8 @@ const mapStateToProps = ({ user, actualIdenty }) => {
111108
const mapDispatchToProps = dispatch => {
112109
return {
113110
onEdit: identy => {
114-
dispatch(editIdenty({ id: this.props.id, identy: identy }));
115-
dispatch(changeActualIdenty(identy));
111+
dispatch(editIdenty(identy));
112+
dispatch(changeActualIdenty(identy.identy));
116113
},
117114
};
118115
};

src/views/editViews/EditNameSreen.jsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ class EditNameSreen extends Component {
1414

1515
editName = async () => {
1616
const item = {
17-
id: this.props.actualIdenty.id,
18-
name: this.state.name,
19-
pronome: this.props.actualIdenty.pronome,
20-
genero: this.props.actualIdenty.genero,
21-
idade: this.props.actualIdenty.idade,
22-
caracteristica: this.props.actualIdenty.caracteristica,
23-
descricao: this.props.actualIdenty.descricao,
24-
photo: this.props.actualIdenty.photo,
17+
id: this.props.id,
18+
identy: {
19+
id: this.props.actualIdenty.id,
20+
name: this.state.name,
21+
pronome: this.props.actualIdenty.pronome,
22+
genero: this.props.actualIdenty.genero,
23+
idade: this.props.actualIdenty.idade,
24+
caracteristica: this.props.actualIdenty.caracteristica,
25+
descricao: this.props.actualIdenty.descricao,
26+
photo: this.props.actualIdenty.photo,
27+
},
2528
};
2629
this.props.onEdit(item);
2730
this.props.navigation.goBack();
@@ -109,8 +112,8 @@ const mapStateToProps = ({ user, actualIdenty }) => {
109112
const mapDispatchToProps = dispatch => {
110113
return {
111114
onEdit: identy => {
112-
dispatch(editIdenty({ id: this.props.id, identy: identy }));
113-
dispatch(changeActualIdenty(identy));
115+
dispatch(editIdenty(identy));
116+
dispatch(changeActualIdenty(identy.identy));
114117
},
115118
};
116119
};

src/views/editViews/EditPronomeScreen.jsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import { changeActualIdenty } from '../../store/actions/viewIdenty';
1515

1616
class EditPronomeScreen extends Component {
1717
state = {
18-
pronome: this.props.actualIdenty.pronome !== '' ? this.props.actualIdenty.pronome.split(', ') : [],
18+
pronome: this.props.actualIdenty.pronome !== '' ? this.props.actualIdenty.pronome.includes(', ') ? this.props.actualIdenty.pronome.split(', ') : [this.props.actualIdenty.pronome] : [],
19+
// pronome: [],
1920
open: false,
2021
};
2122

@@ -43,20 +44,18 @@ class EditPronomeScreen extends Component {
4344

4445
editPronome = async () => {
4546
const item = {
46-
id: this.props.actualIdenty.id,
47-
name: this.props.actualIdenty.name,
48-
pronome: this.formatPronome(),
49-
genero: this.props.actualIdenty.genero,
50-
idade: this.props.actualIdenty.idade,
51-
caracteristica: this.props.actualIdenty.caracteristica,
52-
descricao: this.props.actualIdenty.descricao,
53-
photo: this.props.actualIdenty.photo,
47+
id: this.props.id,
48+
identy: {
49+
...this.props.actualIdenty,
50+
pronome: this.formatPronome(),
51+
},
5452
};
5553
this.props.onEdit(item);
5654
this.props.navigation.goBack();
5755
};
5856

5957
render() {
58+
console.log(this.props.actualIdenty.pronome)
6059
return (
6160
<View style={style.container}>
6261
<View style={style.header}>
@@ -174,8 +173,8 @@ const mapStateToProps = ({ user, actualIdenty }) => {
174173
const mapDispatchToProps = dispatch => {
175174
return {
176175
onEdit: identy => {
177-
dispatch(editIdenty({ id: this.props.id, identy: identy }));
178-
dispatch(changeActualIdenty(identy));
176+
dispatch(editIdenty(identy));
177+
dispatch(changeActualIdenty(identy.identy));
179178
},
180179
};
181180
};

0 commit comments

Comments
 (0)