-
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 all commits
bec1f8e
e6b0b09
47dc562
e649599
57575aa
07a5d24
e9cb545
87cd510
5b65e81
180b22e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,5 +129,4 @@ yarn-debug.log* | |
| yarn-error.log* | ||
| node_modules | ||
| frontend/node_modules | ||
|
|
||
| www | ||
| www/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,7 +50,6 @@ | |
| "DB_PASSWORD", | ||
| "MAIL_PASSWORD", | ||
| "APP_URL", | ||
| "REACT_APP_API_URL", | ||
| ] | ||
|
|
||
| for item in REQUIRED_ENV_VARS: | ||
|
|
||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import React from 'react'; | ||
|
|
||
| const onChange = (setValue) => e => { | ||
| setValue(e.nativeEvent.target.value) | ||
| } | ||
|
|
||
| const Input = ({placeholder = '', outerStyle = {}, innerStyle = {}, OuterClass = '', InnerClass = '', icon, type = 'text', value, setValue}) => ( | ||
| <div className={`field ${OuterClass}`} style={outerStyle}> | ||
| { !!icon ? | ||
| <p className='control has-icons-left'> | ||
| <input className={`input ${InnerClass}`} type={type} placeholder={placeholder} style={innerStyle} value={value} onChange={onChange(setValue)} /> | ||
| <span className='icon is-small is-left'> | ||
| <i className={icon} /> | ||
| </span> | ||
| </p> : | ||
| <input className={`input ${InnerClass}`} type={type} placeholder={placeholder} style={innerStyle} /> | ||
|
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. |
||
| } | ||
| </div> | ||
| ) | ||
|
|
||
| export default Input | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import React from 'react'; | ||
|
|
||
| const Loading = ({ style = {} }) => ( | ||
| <div style={{ transform: "translateY(-50%) translateX(-50%)", ...style}}> | ||
| <div className="lds-heart"><div></div></div> | ||
| </div> | ||
| ) | ||
|
|
||
| export default Loading; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import React, { useState } from 'react'; | ||
| import { effectDuration, discard, apiCall } from '../utils'; | ||
| import Loading from '../components/loadings'; | ||
| import Input from './input'; | ||
|
|
||
| const logMe = (history, setState, username, password, from) => async () => { | ||
| setState('loading'); | ||
| let ret = await apiCall({uri: '/auth/login', method: 'POST', body: {username, password}}) | ||
| if (!!ret.is_error) { | ||
| setState(ret.error.message) | ||
| } else { | ||
| const token = ret.access_token; | ||
| sessionStorage.setItem("token", token); | ||
| history.push('/'); | ||
| } | ||
| // API call /auth/login | ||
| // sessionStorage.setItem('token', 'api call result'); | ||
| } | ||
|
|
||
| const usernameInput = (value, setValue, state) => ({ | ||
| placeholder: 'Username', | ||
| outerStyle: state === 'loading' ? discard('left') : {}, | ||
| innerStyle: { backgroundColor: 'deepskyblue' }, | ||
| InnerClass: 'is-info', | ||
| icon: 'fas fa-user', | ||
| value, | ||
| setValue | ||
| }) | ||
|
|
||
| const passwordInput = (value, setValue, state) => ({ | ||
| placeholder: 'password', | ||
| outerStyle: state === 'loading' ? discard('right') : {}, | ||
| innerStyle: { backgroundColor: 'deepskyblue' }, | ||
| InnerClass: 'is-info', | ||
| icon: 'fas fa-lock', | ||
| type: 'password', | ||
| value, | ||
| setValue | ||
| }) | ||
|
|
||
| const LoginCard = ({ history, from }) => { | ||
| const [state, setState] = useState('default'); | ||
| const [username, setUsername] = 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 {...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. 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(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. |
||
| <div className='field' style={state === 'loading' ? discard('left') : {}}> | ||
| <button className='button is-info is-light is-rounded' onClick={logMe(history, setState, username, password, from)} {...(!!username && !!password ? {} : { disabled: true })}> Log in </button> | ||
| </div> | ||
| <div className='field' style={state === 'loading' ? discard('right') : {}}> | ||
| <button className='button is-outlined is-warning is-rounded' > mot de passe oublier </button> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default LoginCard; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import React, { useState } from 'react'; | ||
| import { effectDuration, discard, apiCall, sleep } from '../utils'; | ||
| import Loading from '../components/loadings'; | ||
| import Input from './input'; | ||
|
|
||
| const logMe = (history, setState, email, username, password, from) => async () => { | ||
| setState('loading'); | ||
| let ret = {} | ||
| ret = await apiCall({uri: '/auth/register', method: 'POST', body: {email, password, username}}) | ||
| if (!!ret.error) { | ||
| setState(ret.error.message); | ||
| } else { | ||
| setState('ok') | ||
| } | ||
| } | ||
|
|
||
| const emailInput = (value, setValue, state) => ({ | ||
| placeholder: 'email', | ||
| outerStyle: { ...(state === 'loading' ? discard('left') : {}), marginTop: '1em' }, | ||
| innerStyle: { backgroundColor: 'greenyellow' }, | ||
| InnerClass: 'is-success', | ||
| icon: 'fas fa-envelope', | ||
| value, | ||
| setValue | ||
| }) | ||
|
|
||
| const usernameInput = (value, setValue, state) => ({ | ||
| placeholder: 'username', | ||
| outerStyle: state === 'loading' ? discard('right') : {}, | ||
| innerStyle: { backgroundColor: 'greenyellow' }, | ||
| InnerClass: 'is-success', | ||
| icon: 'fas fa-user', | ||
| value, | ||
| setValue | ||
| }) | ||
|
|
||
| const passwordInput = (value, setValue) => ({ | ||
| innerStyle: { backgroundColor: 'greenyellow'}, | ||
| InnerClass: 'is-success', | ||
| icon: 'fas fa-lock', | ||
| type: 'password', | ||
| value, | ||
| 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(''); | ||
| const [username, setUsername] = useState(''); | ||
| const [password1, setPassword1] = useState(''); | ||
| const [password2, setPassword2] = useState(''); | ||
| const password_ok = !!password1 && password1 === password2; | ||
|
|
||
| if (state === 'ok') return <p>You will soon receive an confimration email</p> | ||
| return ( | ||
| <div style={{ height: '100%', display: 'flex', flexDirection: 'column' }}> | ||
| { 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. |
||
| <span style={ !password_ok && !!email ? {boxShadow: "red 0px 0px 1px 1px"} : {}}> | ||
| <Input {...passwordInput(password2, setPassword2, state)} placeholder="Password verification" outerStyle={state === 'loading' ? discard('right') : {}} /> | ||
|
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. |
||
| </span> | ||
| <div className='field' style={{ ...(state === 'loading' ? discard('bottom') : {}), marginTop: '2em' }}> | ||
| <button {...registerButton({history, password_ok, password1, email, setState, from, username})}> Register </button> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
| export default RegisterCard; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import React from 'react'; | ||
| import { getToken } from '../utils'; | ||
| import { useHistory } from 'react-router-dom'; | ||
| import LoginCard from '../components/login_card'; | ||
| import RegisterCard from '../components/register_card'; | ||
|
|
||
| // If oldPath is set, maybe a blur effect | ||
| const Landing = ({ from }) => { | ||
| const history = useHistory(); | ||
| if (!!getToken()) | ||
| history.push('/'); | ||
| return ( | ||
| <div className='container' style={{ textAlign: 'center', padding: '1.5em' }}> | ||
| <p className='title is-1' style={{ margin: '1em' }} >Matcha</p> | ||
| <div className='tile is-ancestor'> | ||
| <div className='tile is-vertical is-8'> | ||
| <div className='tile'> | ||
| <div className='tile is-parent is-vertical'> | ||
| <article className='tile is-child notification is-primary'> | ||
| <p className='subtitle'>Guilhem 22 ans j'ai trouver l'ame soeur grace a ce site</p> | ||
| </article> | ||
| <article className='tile is-child notification is-warning'> | ||
| <p className='subtitle'>Lea 34 ans, apres ma rupture avec mon copain matcha m'a redonne espoir</p> | ||
| </article> | ||
| </div> | ||
| <div className='tile is-parent' style={{overflow: 'hidden'}}> | ||
| <article className='tile is-child notification is-info'> | ||
| <LoginCard history={history} from={from} /> | ||
| </article> | ||
| </div> | ||
| </div> | ||
| <div className='tile is-parent'> | ||
| <article className='tile is-child notification is-danger'> | ||
| <p className='subtitle'>Matcha est plus qu'une page web c'est un lieu de magie, de rencontre, grace a nos algorythme pas du tout intrusif nous vous faisons rencontrer la personne dont vous revez la nuit</p> | ||
| <div className='content'> | ||
| </div> | ||
| </article> | ||
| </div> | ||
| </div> | ||
| <div className='tile is-parent' style={{overflow: 'hidden'}}> | ||
| <article className='tile is-child notification is-success'> | ||
| <RegisterCard history={history} from={from} /> | ||
| </article> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default Landing; |
This file was deleted.
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.