-
Notifications
You must be signed in to change notification settings - Fork 4
Landing page #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Landing page #102
Changes from 1 commit
bec1f8e
e6b0b09
47dc562
e649599
57575aa
07a5d24
e9cb545
87cd510
5b65e81
180b22e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,6 @@ | |
| "DB_PASSWORD", | ||
| "MAIL_PASSWORD", | ||
| "APP_URL", | ||
| "REACT_APP_API_URL", | ||
| ] | ||
|
|
||
| for item in REQUIRED_ENV_VARS: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,16 @@ | ||
| import React, { useState } from 'react'; | ||
| import { effectDuration, discard } from '../utils'; | ||
| import { effectDuration, discard, apiCall } from '../utils'; | ||
| import Loading from '../components/loadings'; | ||
| import Input from './input'; | ||
|
|
||
| const logMe = (history, setState, email, password, from) => async () => { | ||
| setState('loading'); | ||
| let ret = await apiCall({uri: '/auth/login', method: 'POST', body: {username: email, password}}) | ||
| if (!!ret.is_error) { | ||
| setState(ret.error.message) | ||
| } else { | ||
| console.log(ret) | ||
| } | ||
| // API call /auth/login | ||
| // sessionStorage.setItem('token', 'api call result'); | ||
| } | ||
|
|
@@ -31,12 +37,15 @@ const passwordInput = (value, setValue, state) => ({ | |
| }) | ||
|
|
||
| const LoginCard = ({ history, from }) => { | ||
| const [state, setState] = useState(''); | ||
| const [state, setState] = useState('default'); | ||
| const [email, setEmail] = useState(''); | ||
| const [password, setPassword] = useState(''); | ||
|
|
||
| return ( | ||
| <div style={{ height: '100%', display: 'flex', flexDirection: 'column', overflow: 'hidden' }}> | ||
| { state != 'default' && state != 'loading' && | ||
| <div className="notification is-danger" style={{paddingTop: '0.5em', paddingBottom: '0.5em'}} > { state } </div> | ||
| } | ||
| <Loading style={{ position: 'absolute', left: '50%', top: '50%', opacity: state === 'loading' ? '1' : '0', ...effectDuration(1) }} /> | ||
| <Input {...emailInput(email, setEmail, state)} /> | ||
| <Input {...passwordInput(password, setPassword, state)} /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,13 +5,13 @@ import Input from './input'; | |
|
|
||
| const logMe = (history, setState, email, username, password, from) => async () => { | ||
| setState('loading'); | ||
| // const ret = await apiCall({uri: '/auth/register', method: 'POST', body: {email, password, username}}) | ||
| // console.log(ret) | ||
| // API call /auth/register | ||
| // sessionStorage.setItem('token', 'api call result'); | ||
| sleep(2); | ||
| setState('ok'); | ||
|
|
||
| let ret = {} | ||
| ret = await apiCall({uri: '/auth/register', method: 'POST', body: {email, password, username}}) | ||
| if (!!ret.error) { | ||
| setState(ret.error.message); | ||
| } else { | ||
| console.log(ret) | ||
| } | ||
| } | ||
|
|
||
| const emailInput = (value, setValue, state) => ({ | ||
|
|
@@ -43,6 +43,12 @@ const passwordInput = (value, setValue, state) => ({ | |
| setValue | ||
| }) | ||
|
|
||
| const registerButton = ({history, password_ok, password1, email, setState, from, username}) => ({ | ||
| className: 'button is-info is-light is-rounded', | ||
| onClick: logMe(history, setState, email, username, password1, from), | ||
| ...(!password_ok ? { disabled: true } : {}) | ||
| }) | ||
|
|
||
| const RegisterCard = ({ history, from }) => { | ||
| const [state, setState] = useState('default'); | ||
| const [email, setEmail] = useState(''); | ||
|
|
@@ -54,16 +60,18 @@ const RegisterCard = ({ history, from }) => { | |
| if (state === 'ok') return <p>You will soon receive an confimration email</p> | ||
| return ( | ||
| <div style={{ height: '100%', display: 'flex', flexDirection: 'column', overflow: 'hidden' }}> | ||
| { state != 'default' && state != 'loading' && | ||
| <div className="notification is-danger" style={{paddingTop: '0.5em', paddingBottom: '0.5em'}}> { state } </div> | ||
| } | ||
| < Loading style={{ position: 'absolute', left: '50%', top: '50%', opacity: state === 'loading' ? '1' : '0', ...effectDuration(1) }} /> | ||
| <Input {...emailInput(email, setEmail, state)} /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. |
||
| <Input {...usernameInput(username, setUsername, state)} /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. |
||
| <Input {...passwordInput(password1, setPassword1, state)} placeholder="password" outerStyle={state === 'loading' ? discard('left') : {}} /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input. |
||
| <Input {...passwordInput(password2, setPassword2, state)} placeholder="Password verification" outerStyle={state === 'loading' ? discard('right') : {}} /> | ||
|
||
| <div className='field' style={{ ...(state === 'loading' ? discard('bottom') : {}), marginTop: '2em' }}> | ||
| <button className={`button is-info ${password_ok ? 'is-light' : 'is-danger'} is-rounded`} onClick={password_ok && logMe(history, setState, email, username, password1, from)}> Register </button> | ||
| <button {...registerButton({history, password_ok, password1, email, setState, from, username})}> Register </button> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default RegisterCard; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's a label missing for this input. That makes it hard for people using screen readers or voice control to use the input.