Webatrice: Account Registration form (pt2) (#4454)
Co-authored-by: ParkTandem <93353951+ParkTandem@users.noreply.github.com>
This commit is contained in:
parent
ac300b0b6d
commit
a87c66885c
5 changed files with 128 additions and 68 deletions
|
@ -0,0 +1,5 @@
|
||||||
|
.dialog-title {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
import React from "react";
|
||||||
|
import Dialog from '@material-ui/core/Dialog';
|
||||||
|
import DialogContent from '@material-ui/core/DialogContent';
|
||||||
|
import DialogTitle from '@material-ui/core/DialogTitle';
|
||||||
|
import IconButton from '@material-ui/core/IconButton';
|
||||||
|
import CloseIcon from '@material-ui/icons/Close';
|
||||||
|
import Typography from '@material-ui/core/Typography';
|
||||||
|
|
||||||
|
import { RegisterForm } from 'forms';
|
||||||
|
|
||||||
|
import './RegistrationDialog.css';
|
||||||
|
|
||||||
|
const RegistrationDialog = ({ classes, handleClose, isOpen }: any) => {
|
||||||
|
const handleOnClose = () => {
|
||||||
|
handleClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog onClose={handleOnClose} open={isOpen}>
|
||||||
|
<DialogTitle disableTypography className="dialog-title">
|
||||||
|
<Typography variant="h6">Create New Account</Typography>
|
||||||
|
|
||||||
|
{handleOnClose ? (
|
||||||
|
<IconButton onClick={handleOnClose}>
|
||||||
|
<CloseIcon />
|
||||||
|
</IconButton>
|
||||||
|
) : null}
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<RegisterForm onSubmit={handleOnClose}></RegisterForm>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default RegistrationDialog;
|
|
@ -12,6 +12,7 @@ export { default as ThreePaneLayout } from './ThreePaneLayout/ThreePaneLayout';
|
||||||
export { default as CheckboxField } from './CheckboxField/CheckboxField';
|
export { default as CheckboxField } from './CheckboxField/CheckboxField';
|
||||||
export { default as SelectField } from './SelectField/SelectField';
|
export { default as SelectField } from './SelectField/SelectField';
|
||||||
export { default as ScrollToBottomOnChanges } from './ScrollToBottomOnChanges/ScrollToBottomOnChanges';
|
export { default as ScrollToBottomOnChanges } from './ScrollToBottomOnChanges/ScrollToBottomOnChanges';
|
||||||
|
export { default as RegistrationDialog } from './RegistrationDialog/RegistrationDialog';
|
||||||
|
|
||||||
// Guards
|
// Guards
|
||||||
export { default as AuthGuard } from './Guard/AuthGuard';
|
export { default as AuthGuard } from './Guard/AuthGuard';
|
||||||
|
|
|
@ -1,14 +1,21 @@
|
||||||
.registerForm {
|
.registerForm {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 20px;
|
}
|
||||||
}
|
|
||||||
|
.registerForm-submit {
|
||||||
.registerForm-item {
|
width: 100%;
|
||||||
display: flex;
|
/*padding is off, something in material-theme is causing it*/
|
||||||
flex-direction: column;
|
}
|
||||||
}
|
|
||||||
|
.row {
|
||||||
.registerForm-submit.MuiButton-root {
|
display: flex;
|
||||||
display: block;
|
flex-direction: row;
|
||||||
margin: 20px auto 0;
|
width: 100%;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.column {
|
||||||
|
width: 48%;
|
||||||
|
flex: 0 1 auto;
|
||||||
|
align-self: auto;
|
||||||
}
|
}
|
|
@ -1,55 +1,66 @@
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { Form, Field, reduxForm } from 'redux-form'
|
import { Form, Field, reduxForm, change } from 'redux-form'
|
||||||
|
|
||||||
import Button from '@material-ui/core/Button';
|
import Button from '@material-ui/core/Button';
|
||||||
|
|
||||||
import { InputField } from 'components';
|
import { InputField, KnownHosts } from 'components';
|
||||||
import { FormKey } from 'types';
|
import { FormKey } from 'types';
|
||||||
|
|
||||||
import './RegisterForm.css';
|
import './RegisterForm.css';
|
||||||
|
|
||||||
const RegisterForm = ({ handleSubmit }) => (
|
const RegisterForm = (props) => {
|
||||||
<Form className="registerForm" onSubmit={handleSubmit} autoComplete="off">
|
const { dispatch, handleSubmit } = props;
|
||||||
<div className="registerForm-item">
|
|
||||||
<Field label="Host" name="host" component={InputField} />
|
const onHostChange = ({ host, port }) => {
|
||||||
</div>
|
dispatch(change(FormKey.REGISTER, 'host', host));
|
||||||
<div className="registerForm-item">
|
dispatch(change(FormKey.REGISTER, 'port', port));
|
||||||
<Field label="Port" name="port" component={InputField} />
|
}
|
||||||
</div>
|
return (
|
||||||
<div className="registerForm-item">
|
<Form className="registerForm row" onSubmit={handleSubmit} autoComplete="off">
|
||||||
<Field label="Player Name" name="user" component={InputField} />
|
<div className="leftRegisterForm column" >
|
||||||
</div>
|
<div className="registerForm-item">
|
||||||
<div className="registerForm-item">
|
<KnownHosts onChange={onHostChange} />
|
||||||
<Field label="Password" name="pass" type="password" component={InputField} />
|
{ /* Padding is off */ }
|
||||||
</div>
|
</div>
|
||||||
<div className="registerForm-item">
|
<div className="registerForm-item">
|
||||||
<Field label="Password (again)" name="passwordConfirm" type="password" component={InputField} />
|
<Field label="Country" name="country" component={InputField} />
|
||||||
</div>
|
</div>
|
||||||
<div className="registerForm-item">
|
<div className="registerForm-item">
|
||||||
<Field label="Email" name="email" type="email" component={InputField} />
|
<Field label="Real Name" name="realName" component={InputField} />
|
||||||
</div>
|
</div>
|
||||||
<div className="registerForm-item">
|
<div className="registerForm-item">
|
||||||
<Field label="Email (again)" name="emailConfirm" type="email" component={InputField} />
|
<Field label="Email" name="email" type="email" component={InputField} />
|
||||||
</div>
|
</div>
|
||||||
<div className="registerForm-item">
|
</div>
|
||||||
<Field label="Real Name" name="realName" component={InputField} />
|
<div className="rightRegisterForm column">
|
||||||
</div>
|
<div className="registerForm-item">
|
||||||
<Button className="registerForm-submit" color="primary" variant="contained" type="submit">
|
<Field label="Player Name" name="user" component={InputField} />
|
||||||
Register
|
</div>
|
||||||
</Button>
|
<div className="registerForm-item">
|
||||||
</Form>
|
<Field label="Password" name="pass" type="password" component={InputField} />
|
||||||
);
|
</div>
|
||||||
|
<div className="registerForm-item">
|
||||||
const propsMap = {
|
<Field label="Password (again)" name="passwordConfirm" type="password" component={InputField} />
|
||||||
form: FormKey.REGISTER,
|
</div>
|
||||||
};
|
<Button className="registerForm-submit tall" color="primary" variant="contained" type="submit">
|
||||||
|
Register
|
||||||
const mapStateToProps = () => ({
|
</Button>
|
||||||
initialValues: {
|
</div>
|
||||||
|
|
||||||
}
|
</Form >
|
||||||
});
|
);
|
||||||
|
}
|
||||||
export default connect(mapStateToProps)(reduxForm(propsMap)(RegisterForm));
|
|
||||||
|
const propsMap = {
|
||||||
|
form: FormKey.REGISTER,
|
||||||
|
};
|
||||||
|
|
||||||
|
const mapStateToProps = () => ({
|
||||||
|
initialValues: {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps)(reduxForm(propsMap)(RegisterForm));
|
||||||
|
|
Loading…
Reference in a new issue