Permalink
Browse files

conditionally display login screen or main panel

  • Loading branch information...
ehelin committed Jan 8, 2019
1 parent 174a895 commit 9f9104fd6519d0d93d847eaf55fe6af7b4547d5e
Showing with 57 additions and 50 deletions.
  1. +57 −50 TgimbaNetCoreWebReactJs/ClientApp/src/components/Login.js
@@ -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>
);
}
};
}

0 comments on commit 9f9104f

Please sign in to comment.