Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Unknown committed 2018-11-13 11:40:38 +01:00
commit 86afad925c
19 files changed
+427 -77

No files matched your search

+8 -1
View File
@@ -12,7 +12,7 @@ import './styles/styles.scss'
import { client } from './graphql/apollo'
import Auth from './auth'
import { Layout, Home, Charts, Callback } from './views'
import { Layout, Home, Charts, Callback, EmailSignupConfirm } from './views'
import Users from '@advancedalgos/users-client'
import Teams from '@advancedalgos/teams-client'
@@ -39,6 +39,13 @@ export const MasterApp = (props) => (
return <Callback {...props} />
}}
/>
<Route
path='/email-verification'
render={props => {
console.log(props.location)
return <EmailSignupConfirm {...props} tokenParam={props.location.search} />
}}
/>
<Route
path='/charts'
render={props => <Charts {...props} auth={auth} />}
+7 -2
View File
@@ -1,7 +1,12 @@
import React from 'react'
import { MessageCard } from '@advancedalgos/web-components'
import { BannerTopBar } from '../common'
const Callback = () => <MessageCard message='Authenticating...' />
const Callback = () => <BannerTopBar
size='big'
title=''
text='Authenticating...'
backgroundUrl='https://aacorporatesitedevelop.azurewebsites.net/img/photos/superalgos-platform.jpg'
/>
export default Callback
+1 -1
View File
@@ -2,7 +2,7 @@ import React, { Component } from 'react'
import { withStyles } from '@material-ui/core/styles'
import { connect } from 'react-redux'
import BannerTopBar from '../BannerTopBar'
import { BannerTopBar } from '../common'
const styles = theme => ({
'@global': {
@@ -1,18 +1,29 @@
import React from 'react'
import PropTypes from 'prop-types'
import Typography from '@material-ui/core/Typography'
const BannerTopBar = ({
size,
backgroundUrl,
title,
text
text,
children
}) => (
<div className={`bannerTopBar ${size}`} style={backgroundUrl ? { backgroundImage: `url(${backgroundUrl})` } : {}}>
<div className='caption'>
<Typography className='title' variant='h1' align='center'>{title}</Typography>
<Typography className='text' variant='h2' align='center'>{text}</Typography>
{children}
</div>
</div>
)
BannerTopBar.propTypes = {
children: PropTypes.node,
backgroundUrl: PropTypes.string,
size: PropTypes.string,
title: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
text: PropTypes.oneOfType([PropTypes.string, PropTypes.array])
}
export default BannerTopBar
+3
View File
@@ -0,0 +1,3 @@
import BannerTopBar from './components/BannerTopBar'
export { BannerTopBar }
@@ -0,0 +1,138 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { withStyles } from '@material-ui/core/styles'
import withWidth from '@material-ui/core/withWidth'
import { Mutation } from 'react-apollo'
import Typography from '@material-ui/core/Typography'
import Grid from '@material-ui/core/Grid'
import Button from '@material-ui/core/Button'
import InputBase from '@material-ui/core/InputBase'
import styles from './styles'
import NEWSLETTER_SIGNUP from '../graphql/NewsletterSignup'
import { isEmpty } from '../../../utils/js-helpers'
export class SignupForm extends Component {
constructor (props) {
super(props)
this.handleChange = this.handleChange.bind(this)
this.handleSubmit = this.handleSubmit.bind(this)
this.validate = this.validate.bind(this)
this.state = {
email: '',
emailError: '',
success: false
}
}
render () {
const {
classes,
width,
alignCenter,
displayTitle,
displayIntro
} = this.props
return (
<Mutation
mutation={NEWSLETTER_SIGNUP}
>
{(NewsletterSignup, { loading, error, data }) => {
return (
<Grid container className={classes.signupRight} direction='column' justify={alignCenter ? 'center' : 'flex-start'}>
{displayTitle && <Typography variant='h4' className={classes.textWhite} gutterBottom>Stay in touch!</Typography>}
{displayIntro && <Typography variant='subtitle1' className={classes.textWhite} gutterBottom>Opt-in our mailing list to stay up to date with the Advanced Algos Project.</Typography>}
<form id='email-signup' action='#' className='form-inline' autoComplete='off'>
<Typography
variant='subtitle1'
className={classes.textSuccess}
gutterBottom
style={{
display: this.state.success ? 'block' : 'none',
textAlign: alignCenter ? 'center' : 'inherit'
}}
>
Thank you for signing up! Please check your email and click on the confirmation link to complete the signup process.
</Typography>
<Grid container className={classes.signupContainer} justify={(width === 'xs' || alignCenter) ? 'center' : 'flex-start'}>
<InputBase
id='email'
placeholder='Enter your email'
classes={{
root: classes.signupInputRoot,
input: classes.signupInput
}}
onChange={this.handleChange}
value={this.state.email}
/>
<Button
id='email-submit'
className={classes.signupInputSubmit}
onClick={e => {
this.handleSubmit(e, NewsletterSignup)
}}
>
Submit
</Button>
</Grid>
</form>
</Grid>
)
}}
</Mutation>
)
}
validate (data) {
const errors = {}
switch (data.id) {
case 'email':
if (data.value === '') {
this.setState({ emailError: 'Please enter an email address' })
} else {
this.setState({ emailError: '' })
}
break
default:
}
return errors
}
handleChange (e) {
let id = e.target.id
let value = e.target.value
let error = this.validate({ id, value })
switch (id) {
case 'email':
if (!isEmpty(error)) this.setState({ emailError: error })
this.setState({ email: value })
break
default:
}
}
async handleSubmit (e, NewsletterSignup) {
e.preventDefault()
console.log('NewsletterSignup handleSubmit: ', this.state.email)
const signupResponse = await NewsletterSignup({ variables: { email: this.state.email } })
console.log('NewsletterSignup: ', signupResponse)
if (signupResponse.data.master_NewsletterSignup === 'SUCCESS') this.setState({ email: '', success: true })
}
}
SignupForm.propTypes = {
classes: PropTypes.object,
width: PropTypes.string,
alignCenter: PropTypes.bool,
displayTitle: PropTypes.bool,
displayIntro: PropTypes.bool
}
const SignupFormWithStyles = withStyles(styles)(SignupForm)
export default withWidth()(SignupFormWithStyles)
@@ -0,0 +1,82 @@
import React from 'react'
import PropTypes from 'prop-types'
import { BannerTopBar } from '../../common'
import SignupForm from './SignupForm'
export class SignupVerifyResponse extends React.Component {
componentDidMount () {
const { mutate } = this.props
mutate()
};
render () {
const { loading, error, data } = this.props
let BannerTitle = ''
let BannerText = ''
let displayForm = false
console.log('SignupVerifyResponse:', loading, error, data)
if (error) {
if (error.message === 'GraphQL error: Error: Token Expired. Please resubmit email address.') {
BannerText = [
<strong key='EmailSignupConfirm-error-b1'>
Newsletter Signup Error: Verification Token Expired
</strong>,
<br key='EmailSignupConfirm-error-br' />,
'Please resubmit your email address and a new token will be emailed to you.',
<br key='EmailSignupConfirm-error-br2' />,
' We apologize for the inconvenience, but we highly value your seurity and privacy.'
]
displayForm = true
} else {
BannerText = ['Newsletter Signup Error: ', <br key='EmailSignupConfirm-error-br' />, error.message]
}
return (
<BannerTopBar
size='big'
title={BannerTitle}
text={BannerText}
backgroundUrl='https://aacorporatesitedevelop.azurewebsites.net/img/photos/superalgos-platform.jpg'
/>
)
}
if (loading && !error) {
BannerText = ['Processing newsletter sign-up...', <br key='EmailSignupConfirm-br' />, 'Thank you for opting-in to recieve updates about the Advanced Algos project!']
}
if (data !== undefined && data !== null) {
console.log(data)
if (data.master_NewsletterSignupVerify === 'SUCCESS') {
return (
<React.Fragment>
<BannerTopBar
size='big'
title='Mailing Sign-Up Complete!'
text='We look forward to keeping you up-to-date on the Advanced Algos project.'
backgroundUrl='https://aacorporatesitedevelop.azurewebsites.net/img/photos/superalgos-platform.jpg'
>
{displayForm && <SignupForm alignCenter />}
</BannerTopBar>
</React.Fragment>
)
}
} else {
return (
<BannerTopBar
size='big'
title=''
text='Newsletter Signup Error'
backgroundUrl='https://aacorporatesitedevelop.azurewebsites.net/img/photos/superalgos-platform.jpg'
/>
)
}
}
}
SignupVerifyResponse.propTypes = {
mutate: PropTypes.function,
loading: PropTypes.bool,
error: PropTypes.object,
data: PropTypes.object
}
export default SignupVerifyResponse
@@ -0,0 +1,65 @@
import lightGreen from '@material-ui/core/colors/lightGreen'
const styles = theme => ({
textLight: {
color: theme.palette.primary.light
},
textWhite: {
color: theme.palette.common.white
},
textSuccess: {
color: lightGreen[400]
},
copyright: {
paddingTop: theme.spacing.unit * 3
},
linkLight: {
color: theme.palette.secondary.main,
textDecoration: 'none'
},
signupRight: {
marginTop: theme.spacing.unit * 2,
[theme.breakpoints.down('xs')]: {
textAlign: 'center'
}
},
signupContainer: {
marginBottom: theme.spacing.unit * 2,
[theme.breakpoints.down('xs')]: {
textAlign: 'center'
}
},
signupInput: {
borderRadius: 4,
backgroundColor: theme.palette.common.white,
border: '1px solid #ced4da',
fontSize: 16,
padding: '10px 12px',
transition: theme.transitions.create(['border-color', 'box-shadow']),
marginRight: theme.spacing.unit * 1
},
signupInputSubmit: {
boxShadow: 'none',
textTransform: 'none',
fontSize: 16,
lineHeight: '1.1875em',
color: theme.palette.common.white,
padding: '10px 12px',
backgroundColor: '#5bc0de',
borderColor: '#46b8da',
'&:hover': {
backgroundColor: '#31b0d5',
borderColor: '#269abc'
},
'&:active': {
boxShadow: 'none',
backgroundColor: '#0062cc',
borderColor: '#005cbf'
},
'&:focus': {
boxShadow: '0 0 0 0.2rem rgba(0,123,255,.5)'
}
}
})
export default styles
@@ -0,0 +1,10 @@
/* eslint-disable no-unused-vars */
import gql from 'graphql-tag'
const NEWSLETTER_SIGNUP = gql`
mutation NewsletterSignup($email: String!) {
master_NewsletterSignup(email: $email)
}
`
export default NEWSLETTER_SIGNUP
@@ -0,0 +1,10 @@
/* eslint-disable no-unused-vars */
import gql from 'graphql-tag'
const NEWSLETTER_SIGNUP_VERIFY = gql`
mutation NewsletterSignupVerify($token: String!) {
master_NewsletterSignupVerify(token: $token)
}
`
export default NEWSLETTER_SIGNUP_VERIFY
@@ -0,0 +1,59 @@
import React from 'react'
import PropTypes from 'prop-types'
import queryString from 'query-string'
import { Mutation } from 'react-apollo'
import { BannerTopBar } from '../common'
import SignupVerifyResponse from './components/SignupVerifyResponse'
import NEWSLETTER_SIGNUP_VERIFY from './graphql/NewsletterSignupVerify'
export const EmailSignupConfirm = ({ tokenParam }) => {
let token
let BannerText = ''
if (tokenParam !== '' && tokenParam !== null) {
const values = queryString.parse(tokenParam)
token = values.token
} else {
BannerText = [
'Newsletter Signup Error: Invalid Token',
<br key='EmailSignupConfirm-error-br' />,
'Please try signing up again! We apologize for the inconvenience,',
<br key='EmailSignupConfirm-error-br2' />,
'but we highly value your seurity and privacy.'
]
return (
<BannerTopBar
size='big'
title=''
text={BannerText}
backgroundUrl='https://aacorporatesitedevelop.azurewebsites.net/img/photos/superalgos-platform.jpg'
/>
)
}
console.log(token)
return (
<Mutation
mutation={NEWSLETTER_SIGNUP_VERIFY}
variables={{ token: token }}
>
{(NewsletterSignupVerify, { loading, error, data }) => {
return (
<SignupVerifyResponse
mutate={NewsletterSignupVerify}
loading={loading}
error={error}
data={data}
/>
)
}
}
</Mutation>
)
}
EmailSignupConfirm.propTypes = {
tokenParam: PropTypes.string
}
export default EmailSignupConfirm
+1 -1
View File
@@ -1,5 +1,5 @@
import React, { Component } from 'react'
import BannerTopBar from '../BannerTopBar'
import { BannerTopBar } from '../common'
import { Typography } from '@material-ui/core'
class Home extends Component {
+2 -1
View File
@@ -2,5 +2,6 @@ import Home from './home'
import Charts from './charts'
import Callback from './callback'
import Layout from './layout'
import EmailSignupConfirm from './email-verification'
export { Layout, Home, Charts, Callback }
export { Layout, Home, Charts, Callback, EmailSignupConfirm }
+3 -20
View File
@@ -9,12 +9,12 @@ import { connect } from 'react-redux'
import Typography from '@material-ui/core/Typography'
import Grid from '@material-ui/core/Grid'
import Button from '@material-ui/core/Button'
import InputBase from '@material-ui/core/InputBase'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faFacebookF, faTelegramPlane, faTwitter } from '@fortawesome/free-brands-svg-icons'
import styles from './styles'
import SignupForm from '../../email-verification/components/SignupForm'
import aalogo from '../../../assets/advanced-algos/aa-logo-horiz-dark.svg'
class Footer extends Component {
@@ -48,24 +48,7 @@ class Footer extends Component {
</Grid>
<Grid item xs={12} sm={1} md={1} />
<Grid item xs={12} sm={7} md={6}>
<Grid container className={classes.signupRight} direction='column'>
<Typography variant='h4' className={classes.textWhite} gutterBottom>Stay in touch!</Typography>
<Typography variant='subtitle1' className={classes.textWhite} gutterBottom>Opt-in our mailing list to stay up to date with the Advanced Algos Project.</Typography>
<form id='email-signup' action='#' className='form-inline' autoComplete='off'>
<Typography variant='body2' className={classes.textSuccess} gutterBottom>Thank you for your interest! We'll keep you informed</Typography>
<Grid container className={classes.signupContainer} justify={width === 'xs' ? 'center' : 'flex-start'}>
<InputBase
id='footer-input'
placeholder='Enter your email'
classes={{
root: classes.footerInputRoot,
input: classes.footerInput
}}
/>
<Button id='email-submit' className={classes.footerInputSubmit}>Submit</Button>
</Grid>
</form>
</Grid>
<SignupForm displayTitle displayIntro />
<Typography variant='subtitle1' className={classes.textWhite} style={{ textAlign: width === 'xs' ? 'center' : '' }}>Meet us on Social Networks:</Typography>
<Grid container justify={width === 'xs' ? 'center' : 'flex-start'}>
<Link to='https://t.me/advancedalgoscommunity' title='Join us on Telgram' className={classes.linkLight}>
+1 -1
View File
@@ -30,7 +30,7 @@ const teamsMenus = {
to: '/teams',
icon: Home,
submenus: [
{ title: 'All teams', to: '/teams', icon: Search },
{ title: 'Explore teams', to: '/teams/explore', icon: Search },
{ title: 'Your teams', to: '/teams/manage-teams', icon: Group, authenticated: true },
{ title: 'Team members', to: '/teams/team-members', icon: People, authenticated: true },
{ title: 'Financial beings', to: '/teams/financial-beings', icon: Adb, authenticated: true },