Skip to content

Commit

Permalink
pass the table number to the parent component
Browse files Browse the repository at this point in the history
Relates #38
  • Loading branch information
alaa-yasin committed Oct 1, 2019
1 parent b91dad4 commit d27a81c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions client/src/components/utils/Login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import './style.css';

export default class Login extends React.Component {
state = {
tableNumber: '',
tableNumber: null,
secret: '',
err: null,
};
Expand All @@ -24,7 +24,7 @@ export default class Login extends React.Component {
handleSubmit = e => {
e.preventDefault();
const { tableNumber, secret } = this.state;
const { history } = this.props;
const { history, updateTableNumber } = this.props;
logInSchema
.validateAsync({ tableNumber, secret })
.then(() => {
Expand All @@ -39,7 +39,7 @@ export default class Login extends React.Component {
})
.then(res => {
if (res.status === 200) {
res.json();
updateTableNumber(tableNumber);
history.push('/');
}
return this.setState({ err: 'Incorrect Table Number or Secret' });
Expand Down Expand Up @@ -95,5 +95,6 @@ export default class Login extends React.Component {
}

Login.propTypes = {
history: propTypes.string.isRequired,
history: propTypes.isRequired,
updateTableNumber: propTypes.func.isRequired,
};

0 comments on commit d27a81c

Please sign in to comment.