Fakultas Ilmu Komputer UI

Commit bb2114b6 authored by Zulia Putri's avatar Zulia Putri 🤤
Browse files

1606918446 223 2

parent 8669470d
...@@ -63,7 +63,9 @@ describe('LoginForm', () => { ...@@ -63,7 +63,9 @@ describe('LoginForm', () => {
<LoginForm url="" />, <LoginForm url="" />,
); );
const submitButton = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Button');
const submitButton = ReactTestUtils.findRenderedDOMComponentWithClass(formLogin, 'submit');
console.log(submitButton);
ReactTestUtils.Simulate.click(submitButton); ReactTestUtils.Simulate.click(submitButton);
const form = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Form'); const form = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Form');
...@@ -77,7 +79,7 @@ describe('LoginForm', () => { ...@@ -77,7 +79,7 @@ describe('LoginForm', () => {
<LoginForm url="" />, <LoginForm url="" />,
); );
const submitButton = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Button'); const submitButton = ReactTestUtils.findRenderedDOMComponentWithClass(formLogin, 'submit');
ReactTestUtils.Simulate.click(submitButton); ReactTestUtils.Simulate.click(submitButton);
const form = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Form'); const form = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Form');
......
...@@ -33,17 +33,25 @@ export default class LoginForm extends React.Component { ...@@ -33,17 +33,25 @@ export default class LoginForm extends React.Component {
this.state = { this.state = {
username: '', username: '',
password: '', password: '',
hide: true,
errorFlag: false, errorFlag: false,
loading: false, loading: false,
}; };
this.handleChange = this.handleChange.bind(this); this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
this.handleClick = this.handleClick.bind(this);
} }
handleChange(event, name) { handleChange(event, name) {
this.setState({ [name]: event.target.value }); this.setState({ [name]: event.target.value });
} }
handleClick(event) {
event.preventDefault();
this.setState({ hide: !this.state.hide });
}
handleSubmit(event) { handleSubmit(event) {
event.preventDefault(); event.preventDefault();
const data = { const data = {
...@@ -103,17 +111,22 @@ export default class LoginForm extends React.Component { ...@@ -103,17 +111,22 @@ export default class LoginForm extends React.Component {
<Form.Field> <Form.Field>
<label htmlFor="password"> Password </label> <label htmlFor="password"> Password </label>
<Input <Input
type="password" type={this.state.hide ? "password" : "text"}
id="password" id="password"
icon="key" icon="key"
iconPosition="left" iconPosition="left"
action={{
icon: this.state.hide ? "unhide" : "hide",
onClick: this.handleClick
}}
placeholder="password" placeholder="password"
value={this.state.password}
onChange={(e) => this.handleChange(e, 'password')} onChange={(e) => this.handleChange(e, 'password')}
required required
/> />
</Form.Field> </Form.Field>
</Form.Group> </Form.Group>
<Button type="submit" fluid color="blue"> <Button className="submit" type="submit" fluid color="blue">
Login Login
</Button> </Button>
<Message <Message
......
...@@ -14713,4 +14713,5 @@ ...@@ -14713,4 +14713,5 @@
"dev": true "dev": true
} }
} }
} }
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment