Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
44 changes: 44 additions & 0 deletions app/components/LoginForm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import PropTypes from 'prop-types';

const LoginForm = props => {
console.log({ props });
Copy link
Member

Choose a reason for hiding this comment

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

i guess this shouldn't be here, if it's for development purpose you can use the react devtools

Copy link
Author

Choose a reason for hiding this comment

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

I removed it.

return (
<form onSubmit={props.onSubmit}>
<div className="field">
<label htmlFor="username">Username</label>
<input
type="text"
id="username"
name="username"
placeholder="Username"
value={props.username}
onChange={props.onChange}
required
/>
</div>
<div className="field">
<label htmlFor="password">Password</label>
<input
type="password"
id="password"
name="password"
placeholder="Password"
value={props.password}
onChange={props.onChange}
required
/>
</div>
<button type="submit">Login</button>
</form>
);
};

LoginForm.propTypes = {
username: PropTypes.string.isRequired,
password: PropTypes.string.isRequired,
onSubmit: PropTypes.func.isRequired,
onChange: PropTypes.func.isRequired,
};

export default LoginForm;
2 changes: 2 additions & 0 deletions app/containers/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Switch, Route } from 'react-router-dom';

import HomePage from 'containers/HomePage/Loadable';
import NotFoundPage from 'containers/NotFoundPage/Loadable';
import LoginPage from 'containers/LoginPage/Loadable';

import '../../global-styles.scss';

Expand All @@ -20,6 +21,7 @@ export default function App() {
<div>
<Switch>
<Route exact path="/" component={HomePage} />
<Route exact path="/login" component={LoginPage} />
<Route component={NotFoundPage} />
</Switch>
</div>
Expand Down
6 changes: 6 additions & 0 deletions app/containers/LoginPage/Loadable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Asynchronously loads the component for LoginPage
*/
import loadable from 'loadable-components';

export default loadable(() => import('./index'));
31 changes: 31 additions & 0 deletions app/containers/LoginPage/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import LoginForm from 'components/LoginForm';

/* eslint-disable react/prefer-stateless-function */
export default class LoginPage extends React.PureComponent {
state = {
username: '',
password: '',
};

handleSubmit = event => {
event.preventDefault();
console.log('Submitted: ', this.state);
};

handleChange = event => {
this.setState({ [event.target.name]: event.target.value });
};

render() {
const { username, password } = this.state;
return (
<LoginForm
username={username}
password={password}
onSubmit={this.handleSubmit}
onChange={this.handleChange}
/>
);
}
}