Skip to content

Commit 7fb209d

Browse files
authored
Fix login bug
1 parent bb28324 commit 7fb209d

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

  • src/client/app/routes/LandingPage

src/client/app/routes/LandingPage/index.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @desc this is the admin component of the application.
33
* @author gaurav sharma
44
*/
5-
import React, { useEffect } from 'react';
5+
import React, { useEffect, useState } from 'react';
66
import {
77
Container,
88
Row,
@@ -47,12 +47,10 @@ const LandingPage = (props) => {
4747
loginContainer.style.marginTop = '10px';
4848
}
4949
}
50-
5150
const onLogin = (e) => {
5251
e.preventDefault();
5352
const { triggerLoginUser } = props;
54-
55-
triggerLoginUser(userUname.value, userPass.value);
53+
triggerLoginUser(user, password);
5654
}
5755

5856
/**
@@ -72,6 +70,11 @@ const LandingPage = (props) => {
7270
toast.error("Failed authentication.");
7371
}
7472
}
73+
74+
75+
const onFormValid = () => {
76+
return user && password
77+
}
7578

7679

7780
const { fetching, login } = props;
@@ -93,14 +96,14 @@ const LandingPage = (props) => {
9396
<Form>
9497
<FormGroup>
9598
<Label for="username">Username</Label><br />
96-
<input ref={userUname => userUname = userUname} className='custom-field login-field' placeholder='Username for user' />
99+
<input onChange={e => setUser(e.target.value)} className='custom-field login-field' placeholder='Username for user' />
97100
</FormGroup>
98101
<FormGroup>
99102
<Label for="username">Password</Label><br />
100-
<input ref={userPass => userPass = userPass} type='password' className='custom-field login-field' placeholder='Password for user' />
103+
<input onChange={e => setPassword(e.target.value)} type='password' className='custom-field login-field' placeholder='Password for user' />
101104
</FormGroup>
102105
<p className='text-center'>
103-
<button className="litnite-btn" onClick={onLogin}>LOGIN&nbsp;&nbsp;&nbsp;<FontAwesome name="chevron-right" /></button>
106+
<button className="litnite-btn" onClick={onLogin} disabled={!onFormValid()}>LOGIN&nbsp;&nbsp;&nbsp;<FontAwesome name="chevron-right" /></button>
104107
</p>
105108
</Form>
106109
<br /><br /><br />

0 commit comments

Comments
 (0)