diff --git a/frontend/src/component/user/DemoAuth/DemoAuth.jsx b/frontend/src/component/user/DemoAuth/DemoAuth.jsx new file mode 100644 index 0000000000..b3b6170b55 --- /dev/null +++ b/frontend/src/component/user/DemoAuth/DemoAuth.jsx @@ -0,0 +1,84 @@ +import React, { useState } from 'react'; +import PropTypes from 'prop-types'; +import { Button, TextField } from '@material-ui/core'; + +import styles from './DemoAuth.module.scss'; + +const DemoAuth = ({ + demoLogin, + loadInitialData, + history, + authDetails, +}) => { + const [email, setEmail] = useState(''); + + const handleSubmit = evt => { + evt.preventDefault(); + const user = { email }; + const path = evt.target.action; + + demoLogin(path, user) + .then(loadInitialData) + .then(() => history.push(`/`)); + }; + + const handleChange = e => { + const value = e.target.value; + setEmail(value); + }; + + return ( +
+ ); +}; + +DemoAuth.propTypes = { + authDetails: PropTypes.object.isRequired, + demoLogin: PropTypes.func.isRequired, + loadInitialData: PropTypes.func.isRequired, + history: PropTypes.object.isRequired, +}; + +export default DemoAuth; diff --git a/frontend/src/component/user/DemoAuth/DemoAuth.module.scss b/frontend/src/component/user/DemoAuth/DemoAuth.module.scss new file mode 100644 index 0000000000..aac57bdd4a --- /dev/null +++ b/frontend/src/component/user/DemoAuth/DemoAuth.module.scss @@ -0,0 +1,11 @@ +.container > * { + margin: 0.6rem 0; +} + +.button { + min-width: 150px; +} + +.form { + margin: 4em 1em +} diff --git a/frontend/src/component/user/DemoAuth/index.jsx b/frontend/src/component/user/DemoAuth/index.jsx new file mode 100644 index 0000000000..4985c198a9 --- /dev/null +++ b/frontend/src/component/user/DemoAuth/index.jsx @@ -0,0 +1,3 @@ +import DemoAuth from './DemoAuth'; + +export default DemoAuth; diff --git a/frontend/src/component/user/Login/Login.styles.js b/frontend/src/component/user/Login/Login.styles.js index 39068eb550..d107c058c8 100644 --- a/frontend/src/component/user/Login/Login.styles.js +++ b/frontend/src/component/user/Login/Login.styles.js @@ -38,7 +38,7 @@ export const useStyles = makeStyles(theme => ({ fontSize: '1.25rem', }, loginFormContainer: { - maxWidth: '300px', + maxWidth: '500px', }, imageContainer: { display: 'flex', diff --git a/frontend/src/component/user/authentication-component.jsx b/frontend/src/component/user/authentication-component.jsx index 0d9d59d7cb..0235155b8c 100644 --- a/frontend/src/component/user/authentication-component.jsx +++ b/frontend/src/component/user/authentication-component.jsx @@ -3,13 +3,16 @@ import PropTypes from 'prop-types'; import SimpleAuth from './SimpleAuth/SimpleAuth'; import AuthenticationCustomComponent from './authentication-custom-component'; import PasswordAuth from './PasswordAuth/PasswordAuth'; +import DemoAuth from './DemoAuth'; const SIMPLE_TYPE = 'unsecure'; +const DEMO_TYPE = 'demo'; const PASSWORD_TYPE = 'password'; class AuthComponent extends React.Component { static propTypes = { user: PropTypes.object.isRequired, + demoLogin: PropTypes.func.isRequired, insecureLogin: PropTypes.func.isRequired, passwordLogin: PropTypes.func.isRequired, loadInitialData: PropTypes.func.isRequired, @@ -39,6 +42,15 @@ class AuthComponent extends React.Component { history={this.props.history} /> ); + } else if (authDetails.type === DEMO_TYPE) { + content = ( +