Add children to BannerTopBar component

This commit is contained in:
Barry Low committed 2018-11-12 22:35:18 -08:00
1 parent d5c5969f8c
commit 00ff3f2664
4 files changed
+47 -27

No files matched your search

@@ -6,17 +6,20 @@ 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]),
@@ -25,35 +25,41 @@ export class SignupForm extends Component {
this.state = {
email: '',
emailError: ''
emailError: '',
success: false
}
}
render () {
const { classes, width } = this.props
const {
classes,
width,
alignCenter,
displayTitle,
displayIntro
} = this.props
return (
<Mutation
mutation={NEWSLETTER_SIGNUP}
>
{(NewsletterSignup, { loading, error, data }) => {
let successMessage = false
if (data.NewsletterSignup === 'SUCESS') {
successMessage = true
}
return (
<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>
<Grid container className={classes.signupRight} direction='column' justify={alignCenter ? 'center' : ''}>
{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='body2'
variant='subtitle1'
className={classes.textSuccess}
gutterBottom
style={successMessage ? 'display: block' : 'display: none'}
style={{
display: this.state.success ? 'block' : 'none',
textAlign: alignCenter ? 'center' : 'inherit'
}}
>
Thank you for your interest! We'll keep you informed
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' ? 'center' : 'flex-start'}>
<Grid container className={classes.signupContainer} justify={(width === 'xs' || alignCenter) ? 'center' : 'flex-start'}>
<InputBase
id='email'
placeholder='Enter your email'
@@ -62,12 +68,13 @@ export class SignupForm extends Component {
input: classes.signupInput
}}
onChange={this.handleChange}
value={this.state.email}
/>
<Button
id='email-submit'
className={classes.signupInputSubmit}
onClick={e => {
this.handleSubmit(e, NewsletterSignup, this.state.email)
this.handleSubmit(e, NewsletterSignup)
}}
>
Submit
@@ -103,23 +110,27 @@ export class SignupForm extends Component {
switch (id) {
case 'email':
if (!isEmpty(error)) this.setState({ emailError: error })
this.setState({ emaail: value })
this.setState({ email: value })
break
default:
}
}
async handleSubmit (e, NewsletterSignup, email) {
async handleSubmit (e, NewsletterSignup) {
e.preventDefault()
const signupResponse = await NewsletterSignup({ variables: { email } })
console.log('NewsletterSignup handleSubmit: ', this.state.email)
const signupResponse = await NewsletterSignup({ variables: { email: this.state.email } })
console.log('NewsletterSignup: ', signupResponse)
this.setState({ email: '' })
if (signupResponse.data.master_NewsletterSignup === 'SUCCESS') this.setState({ email: '', success: true })
}
}
SignupForm.propTypes = {
classes: PropTypes.object,
width: PropTypes.string
width: PropTypes.string,
alignCenter: PropTypes.bool,
displayTitle: PropTypes.bool,
displayIntro: PropTypes.bool
}
const SignupFormWithStyles = withStyles(styles)(SignupForm)
@@ -19,12 +19,15 @@ export class SignupVerifyResponse extends React.Component {
if (error) {
if (error.message === 'GraphQL error: Error: Token Expired. Please resubmit email address.') {
BannerText = [
'Newsletter Signup Error: Verification Token Expired',
<strong key='EmailSignupConfirm-error-b1'>
Newsletter Signup Error: Verification Token Expired
</strong>,
<br key='EmailSignupConfirm-error-br' />,
'Please try signing up again! We apologize for the inconvenience,',
'Please resubmit your email address and a new token will be emailed to you.',
<br key='EmailSignupConfirm-error-br2' />,
'but we highly value your seurity and privacy.'
' 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]
}
@@ -41,8 +44,9 @@ export class SignupVerifyResponse extends React.Component {
title={BannerTitle}
text={BannerText}
backgroundUrl='https://aacorporatesitedevelop.azurewebsites.net/img/photos/superalgos-platform.jpg'
/>
{displayForm && <SignupForm />}
>
{displayForm && <SignupForm alignCenter />}
</BannerTopBar>
</React.Fragment>
)
} else {
+4 -2
View File
@@ -15,11 +15,13 @@ if (dev){
export default {
async master_NewsletterSignup(parent, { email }, ctx, info) {
logger.info('master_NewsletterSignup params email:')
logger.info(email)
const token = jwt.sign({ email: email }, API_KEY, { expiresIn: '1d' })
let origin = 'https://advancedalgos.net'
const params = '/email-verification?token='
if (dev){
origin = 'http://localhost:4100'
origin = 'http://localhost:3100'
}
const headers = {
@@ -82,7 +84,7 @@ export default {
async master_NewsletterSignupVerify(parent, { token }, ctx, info){
let origin = 'https://app.advancedalgos.net'
if (dev){
origin = 'http://localhost:4100'
origin = 'http://localhost:3100'
}
const headers = {
'Content-Type': 'application/json',