Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Junção das função 'setYear' e 'setMonth' #57

Merged
merged 1 commit into from
Oct 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions src/containers/DateOfBirthForm/SelectDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,14 @@ export class SelectDate extends React.Component {
preeschoolCalcError: null,
ageMsg: null
};
this.setMonth = this.setMonth.bind(this)
this.setYear = this.setYear.bind(this)
this.setDateAttribute = this.setDateAttribute.bind(this);
}

setMonth = (e) => {
setDateAttribute = (attribute, value) => {
this.setState({
monthOfBirth: e.target.value
[attribute]: value
}, () => {
if (this.state.yearOfBirth !== undefined) {
this.setAge();
}
});
}

setYear = (e) => {
this.setState({
yearOfBirth: e.target.value
}, () => {
if (this.state.monthOfBirth !== undefined) {
if (this.state.yearOfBirth !== undefined && this.state.monthOfBirth !== undefined) {
this.setAge();
}
});
Expand Down Expand Up @@ -67,11 +56,20 @@ export class SelectDate extends React.Component {
const preeschoolCalcError = this.state.preeschoolCalcError;
return (
<div>
<select className="default-select" id="month-of-birth" value={this.state.monthOfBirth} onChange={this.setMonth}>
<select
className="default-select"
id="month-of-birth"
value={this.state.monthOfBirth}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Essa linha aqui é necessária? Sei que já estava ai antes desse commit, mas consegue me dizer o motivo? haha

onChange={(event) => this.setDateAttribute('monthOfBirth', event.target.value)}
>
<option value="">{STRINGS.messages.month_of_birth}</option>
{generateMonthsOptions()}
</select>
<select className="default-select" id="year-of-birth" onChange={this.setYear}>
<select
className="default-select"
id="year-of-birth"
onChange={(event) => this.setDateAttribute('yearOfBirth', event.target.value)}
>
<option value="">{STRINGS.messages.year_of_birth}</option>
{generateYearsOptions()}
</select>
Expand Down