Skip to content

Commit

Permalink
Fix declaring const with props outside of class
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Ferreira committed Jun 5, 2017
1 parent a603329 commit 7d67658
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
32 changes: 15 additions & 17 deletions static/src/components/Modals/EditAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,31 @@ import TextField from 'material-ui/TextField';

import styles from './styles.scss';

const initialState = {
open: false,
disabled: true,
label_error_text: null,
bank_error_text: null,
iban_error_text: null,
bic_error_text: null,
id: this.props.fields.id,
labelValue: this.props.fields.label,
bankValue: this.props.fields.bank,
ibanValue: this.props.fields.iban,
bicValue: this.props.fields.bic,
projectedDateValue: this.props.fields.projected_date,
};

export default class EditAccount extends React.Component {
constructor (props){
super(props)
this.state = initialState
this.state = {
open: false,
disabled: true,
label_error_text: null,
bank_error_text: null,
iban_error_text: null,
bic_error_text: null,
id: this.props.fields.id,
labelValue: this.props.fields.label,
bankValue: this.props.fields.bank,
ibanValue: this.props.fields.iban,
bicValue: this.props.fields.bic,
projectedDateValue: this.props.fields.projected_date,
}
}

handleOpen = () => {
this.setState({open: true});
};

handleClose = () => {
this.setState(initialState);
this.setState({open: false});
};

changeValue(e, type) {
Expand Down
24 changes: 11 additions & 13 deletions static/src/components/Modals/EditTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,27 @@ import MoreHoriz from 'material-ui/svg-icons/navigation/more-horiz';

import styles from './styles.scss';

const initialState = {
open: false,
disabled: true,
label_error_text: null,
amount_error_text: null,
transaction_id: this.props.fields.transaction_id,
dateValue: this.props.fields.date,
labelValue: this.props.fields.label,
amountValue: this.props.fields.amount,
};

export default class EditTransaction extends React.Component {
constructor (props){
super(props)
this.state = initialState
this.state = {
open: false,
disabled: true,
label_error_text: null,
amount_error_text: null,
transaction_id: this.props.fields.transaction_id,
dateValue: this.props.fields.date,
labelValue: this.props.fields.label,
amountValue: this.props.fields.amount,
}
}

handleOpen = () => {
this.setState({open: true});
};

handleClose = () => {
this.setState(initialState);
this.setState({open: false});
};

changeValue(e, type) {
Expand Down

0 comments on commit 7d67658

Please sign in to comment.