Skip to content
This repository has been archived by the owner on Sep 11, 2021. It is now read-only.

Commit

Permalink
conditionally display login screen or main panel
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Helin committed Jan 8, 2019
1 parent 174a895 commit 9f9104f
Showing 1 changed file with 57 additions and 50 deletions.
107 changes: 57 additions & 50 deletions TgimbaNetCoreWebReactJs/ClientApp/src/components/Login.js
Expand Up @@ -17,60 +17,67 @@ class Login extends React.Component {
}
}

render() {
let { username, password } = this.state;

const processLogin = _ => {
this.props.login(username, password);
}

const navigateRegistration = _ => {
var utils = Object.create(utilsRef.Utilities);
render() {
var utils = Object.create(utilsRef.Utilities);
if (utils.IsLoggedIn()) {
var host = utils.GetHost();
window.location = host + '/register';
window.location = host + '/main';
}
else {
let { username, password } = this.state;

var tableStyle = {
"width": "100%",
"text-align": "center",
"vertical-align":" middle"
};
const processLogin = _ => {
this.props.login(username, password);
}

return (
<div>
<h1>React JS - Login</h1>
<table style={tableStyle}>
<tr>
<td>
<label>Username:</label>
<input
id="USER_CONTROL_LOGIN_USERNAME"
type="text"
value={username}
onChange={event => this.setState({ username: event.target.value })}
/>
</td>
</tr>
<tr>
<td>
<label>Password:</label>
<input
id="USER_CONTROL_LOGIN_PASSWORD"
type="password"
value={password}
onChange={event => this.setState({ password: event.target.value })}
/>
</td>
</tr>
<tr>
<td>
<Button onPress={processLogin} id="hvJsLoginBtn">Login</Button>
<Button onPress={navigateRegistration} id="hvJsRegisterPanelBtn">Register</Button>
</td>
</tr>
</table>
</div>
);
const navigateRegistration = _ => {
var utils = Object.create(utilsRef.Utilities);
var host = utils.GetHost();
window.location = host + '/register';
}

var tableStyle = {
"width": "100%",
"text-align": "center",
"vertical-align": " middle"
};

return (
<div>
<h1>React JS - Login</h1>
<table style={tableStyle}>
<tr>
<td>
<label>Username:</label>
<input
id="USER_CONTROL_LOGIN_USERNAME"
type="text"
value={username}
onChange={event => this.setState({ username: event.target.value })}
/>
</td>
</tr>
<tr>
<td>
<label>Password:</label>
<input
id="USER_CONTROL_LOGIN_PASSWORD"
type="password"
value={password}
onChange={event => this.setState({ password: event.target.value })}
/>
</td>
</tr>
<tr>
<td>
<Button onPress={processLogin} id="hvJsLoginBtn">Login</Button>
<Button onPress={navigateRegistration} id="hvJsRegisterPanelBtn">Register</Button>
</td>
</tr>
</table>
</div>
);
}
};
}

Expand Down

0 comments on commit 9f9104f

Please sign in to comment.