mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 08:14:47 -07:00
new login design (#4442)
* new login design * remove effects file (wrong direction) * add Known Hosts dropdown component Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
This commit is contained in:
parent
6f360374cc
commit
d684a9c5fc
25 changed files with 675 additions and 212 deletions
73
webclient/src/forms/LoginForm/LoginForm.tsx
Normal file
73
webclient/src/forms/LoginForm/LoginForm.tsx
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
// eslint-disable-next-line
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { Form, Field, reduxForm, change } from "redux-form"
|
||||
|
||||
import Button from "@material-ui/core/Button";
|
||||
|
||||
import { InputField, KnownHosts } from "components";
|
||||
// import { ServerDispatch } from "store";
|
||||
import { FormKey } from 'types';
|
||||
|
||||
import "./LoginForm.css";
|
||||
|
||||
const LoginForm = (props) => {
|
||||
const { dispatch, handleSubmit } = props;
|
||||
|
||||
const forgotPassword = () => {
|
||||
console.log('LoginForm.forgotPassword->openForgotPasswordDialog');
|
||||
};
|
||||
|
||||
const onHostChange = ({ host, port }) => {
|
||||
dispatch(change(FormKey.LOGIN, 'host', host));
|
||||
dispatch(change(FormKey.LOGIN, 'port', port));
|
||||
}
|
||||
|
||||
return (
|
||||
<Form className="loginForm" onSubmit={handleSubmit}>
|
||||
<div className="loginForm-items">
|
||||
<div className="loginForm-item">
|
||||
<Field label="User" name="user" component={InputField} autoComplete="username" />
|
||||
</div>
|
||||
<div className="loginForm-item">
|
||||
<Field label="Pass" name="pass" type="password" component={InputField} autoComplete="current-password" />
|
||||
</div>
|
||||
<div className="loginForm-actions">
|
||||
<span>Auto Connect</span>
|
||||
<Button color="primary" onClick={forgotPassword}>Forgot Password</Button>
|
||||
</div>
|
||||
<div className="loginForm-item">
|
||||
<KnownHosts onChange={onHostChange} />
|
||||
</div>
|
||||
</div>
|
||||
<Button className="loginForm-submit rounded tall" color="primary" variant="contained" type="submit">
|
||||
Login
|
||||
</Button>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
|
||||
const propsMap = {
|
||||
form: FormKey.LOGIN,
|
||||
validate: values => {
|
||||
const errors: any = {};
|
||||
|
||||
if (!values.user) errors.user = 'Required';
|
||||
if (!values.pass) errors.pass = 'Required';
|
||||
if (!values.host) errors.host = 'Required';
|
||||
if (!values.port) errors.port = 'Required';
|
||||
|
||||
return errors;
|
||||
}
|
||||
};
|
||||
|
||||
const mapStateToProps = () => ({
|
||||
initialValues: {
|
||||
// host: "mtg.tetrarch.co/servatrice",
|
||||
// port: "443"
|
||||
// host: "server.cockatrice.us",
|
||||
// port: "4748"
|
||||
}
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps)(reduxForm(propsMap)(LoginForm));
|
||||
Loading…
Add table
Add a link
Reference in a new issue