diff --git a/components/form/Field.js b/components/form/Field.js index 1538d08a..f78a4c9e 100644 --- a/components/form/Field.js +++ b/components/form/Field.js @@ -78,6 +78,17 @@ class Field extends React.Component { ) } + renderLabel() { + const { properties } = this.props; + if (!properties.label) return null; + + if (typeof properties.label === 'function') { + return properties.label(); + } + + return properties.label + } + render() { const { properties, className } = this.props; const { valid, error } = this.state; @@ -94,7 +105,7 @@ class Field extends React.Component {
{properties.label && } diff --git a/components/users/new.js b/components/users/new.js index 16d0f084..6a706470 100644 --- a/components/users/new.js +++ b/components/users/new.js @@ -44,7 +44,7 @@ const UserNewForm = (props) => { return props.saveUser({ body }) .then(() => { logEvent('sign_up', { method: 'credentials' }); - if (props.onSubmit) props.onSubmit(); + if (props.onSubmit) props.onSubmit({ email: form.email }); }) } @@ -74,189 +74,168 @@ const UserNewForm = (props) => {
- {({ form, submitted }) => (<> - {!submitted && ( -
-
- {/* Permission request */} - - {RadioGroup} - - - {/* Countries */} - - {Select} - - - {/* Operators */} - {form.permissions_request === 'operator' && form.country_id && ( - o.country && o.country.id === form.country_id))} - properties={{ - name: 'operator_id', - label: intl.formatMessage({ id: 'signup.user.form.field.producer' }), - required: true, - instanceId: 'select.operator_id', - placeholder: intl.formatMessage({ id: 'select.placeholder' }) - }} - > - {Select} - - )} - - - {Input} - + {({ form }) => (<> + +
+ {/* Permission request */} + + {RadioGroup} + - - {Input} - + {/* Countries */} + + {Select} + + {/* Operators */} + {form.permissions_request === 'operator' && form.country_id && ( ({ label: l.name, value: l.code }))} + hint={registerNewProducerHint} + options={HELPERS_REGISTER.mapToSelectOptions(operators.data.filter(o => o.country && o.country.id === form.country_id))} properties={{ - name: 'locale', - label: intl.formatMessage({ id: 'signup.user.form.field.preferred_language', defaultMessage: 'Preferred Language' }), + name: 'operator_id', + label: intl.formatMessage({ id: 'signup.user.form.field.producer' }), required: true, - instanceId: 'select.locale', + instanceId: 'select.operator_id', placeholder: intl.formatMessage({ id: 'select.placeholder' }) }} > {Select} + )} - - {Input} - + + {Input} + - - {Input} - + + {Input} + - - {Checkbox} - -
+ ({ label: l.name, value: l.code }))} + properties={{ + name: 'locale', + label: intl.formatMessage({ id: 'signup.user.form.field.preferred_language', defaultMessage: 'Preferred Language' }), + required: true, + instanceId: 'select.locale', + placeholder: intl.formatMessage({ id: 'select.placeholder' }) + }} + > + {Select} + -
    -
  • - - {intl.formatMessage({ id: 'signup' })} - -
  • -
- - )} + + {Input} + - {submitted && ( -
-

- {intl.formatMessage({ id: 'thankyou' })} -

+ + {Input} + -

- {intl.formatMessage({ id: 'wait-for-approval' })} -

+ + {intl.formatMessage({ id: 'signup.user.form.field.agree' })} + {' ('} + + + {intl.formatMessage({ id: 'Read here' })} + + + {')'} + + }} + > + {Checkbox} + +
- -
- )} + + )}
diff --git a/css/components/form/field.scss b/css/components/form/field.scss index c2a06682..c658a567 100644 --- a/css/components/form/field.scss +++ b/css/components/form/field.scss @@ -12,6 +12,15 @@ color: $color-text-1; background: none; font-weight: $font-weight-default; + + a { + color: $color-text-1; + text-decoration: none; + + &:hover { + text-decoration: underline; + } + } } abbr { diff --git a/css/components/page/_static-header.scss b/css/components/page/_static-header.scss index 5e8326bc..c6387f5d 100644 --- a/css/components/page/_static-header.scss +++ b/css/components/page/_static-header.scss @@ -6,10 +6,6 @@ width: 100%; height: 220px; - @include breakpoint(medium) { - height: 250px; - } - background-size: cover; background-repeat: no-repeat; background-position: center; diff --git a/css/components/ui/_info-box.scss b/css/components/ui/_info-box.scss new file mode 100644 index 00000000..1221b6c5 --- /dev/null +++ b/css/components/ui/_info-box.scss @@ -0,0 +1,18 @@ +.c-info-box { + background: $color-gray-2; + padding: 20px; + + @include breakpoint(medium) { + padding: 30px; + } + + &.-center { + text-align: center; + } + + p { + @include breakpoint(medium) { + font-size: $font-size-big; + } + } +} diff --git a/css/index.scss b/css/index.scss index ba54556d..6c11aa54 100644 --- a/css/index.scss +++ b/css/index.scss @@ -75,6 +75,7 @@ @import 'components/ui/gallery'; @import 'components/ui/hamburger'; @import 'components/ui/icon'; +@import 'components/ui/info-box'; @import 'components/ui/intro'; @import 'components/ui/language-dropdown'; @import 'components/ui/location-search'; @@ -126,3 +127,4 @@ // html @import 'components/html/html'; + diff --git a/e2e/cypress/e2e/__image_snapshots__/Newsletter Newsletter form matches visually #0.png b/e2e/cypress/e2e/__image_snapshots__/Newsletter Newsletter form matches visually #0.png index 10486f0c..d969d80e 100644 Binary files a/e2e/cypress/e2e/__image_snapshots__/Newsletter Newsletter form matches visually #0.png and b/e2e/cypress/e2e/__image_snapshots__/Newsletter Newsletter form matches visually #0.png differ diff --git a/e2e/cypress/e2e/__image_snapshots__/Pages About page matches visually #0.png b/e2e/cypress/e2e/__image_snapshots__/Pages About page matches visually #0.png index 648591c3..49da42be 100644 Binary files a/e2e/cypress/e2e/__image_snapshots__/Pages About page matches visually #0.png and b/e2e/cypress/e2e/__image_snapshots__/Pages About page matches visually #0.png differ diff --git a/e2e/cypress/e2e/__image_snapshots__/Pages Create account page matches visually #0.png b/e2e/cypress/e2e/__image_snapshots__/Pages Create account page matches visually #0.png index f5e0cd4e..d5e7e352 100644 Binary files a/e2e/cypress/e2e/__image_snapshots__/Pages Create account page matches visually #0.png and b/e2e/cypress/e2e/__image_snapshots__/Pages Create account page matches visually #0.png differ diff --git a/e2e/cypress/e2e/__image_snapshots__/Pages Create producer page matches visually #0.png b/e2e/cypress/e2e/__image_snapshots__/Pages Create producer page matches visually #0.png index 5afc3b40..a246e23c 100644 Binary files a/e2e/cypress/e2e/__image_snapshots__/Pages Create producer page matches visually #0.png and b/e2e/cypress/e2e/__image_snapshots__/Pages Create producer page matches visually #0.png differ diff --git a/e2e/cypress/e2e/__image_snapshots__/Pages Help page when visitng overviewmain matches visually #0.png b/e2e/cypress/e2e/__image_snapshots__/Pages Help page when visitng overviewmain matches visually #0.png index 9dd8bfe3..52bb3eaf 100644 Binary files a/e2e/cypress/e2e/__image_snapshots__/Pages Help page when visitng overviewmain matches visually #0.png and b/e2e/cypress/e2e/__image_snapshots__/Pages Help page when visitng overviewmain matches visually #0.png differ diff --git a/e2e/cypress/e2e/user.cy.js b/e2e/cypress/e2e/user.cy.js index 4b59c040..7e28d542 100644 --- a/e2e/cypress/e2e/user.cy.js +++ b/e2e/cypress/e2e/user.cy.js @@ -49,7 +49,7 @@ describe('User', () => { cy.get('.rrt-text').should('have.text', 'Fill all the required fields'); cy.get('label[for=checkbox-agree-undefined]').click(); cy.get('button').contains('Sign up').click(); - cy.get('.c-form > p').should('have.text', 'Wait for approval.'); + cy.get('.c-info-box').contains('you will receive an email to testoperator@example.com once your account is approved'); }); it('can create producer', function () { diff --git a/lang/zu.json b/lang/zu.json index e9d8c204..da9a9145 100644 --- a/lang/zu.json +++ b/lang/zu.json @@ -186,6 +186,10 @@ "signup.user.form.field.password": "Password", "signup.user.form.field.password_confirmation": "Password confirmation", "signup.user.form.field.agree": "by creating your account, you agree to the terms of service", + "signup.user.header": "Creating a new account", + "signup.user.thank_you_header": "Thank you for signing up!", + "signup.user.thank_you.paragraph1": "We received your request and we will review it as soon as possible. This process might take a few days, and you will receive an email to {submittedEmail} once your account is approved. Be sure to check your spam folder.", + "signup.user.thank_you.paragraph2": "In the meantime, you can explore the platform and learn more about the data we have available.", "signup.operators.form.field.name": "Producer name", "signup.operators.form.field.details": "Producer description", "signup.operators.form.field.operator_type": "Producer type", @@ -452,6 +456,7 @@ "Cookie Preferences": "Cookie Preferences", "Privacy Policy": "Privacy Policy", "Search FMU": "Search FMU", + "Read here": "Read here", "obs_per_visit_explanation": "The observations/visit calculates the average number of observations made by independent forest monitors per visit.", "notifications.expiring_soon_note": "{company} has documents that are expiring soon that will need to be updated:", "notifications.expired_note": "{company} has documents that have expired that need to be updated:", diff --git a/pages/signup.js b/pages/signup.js index 807dfe36..cf1a4f08 100644 --- a/pages/signup.js +++ b/pages/signup.js @@ -1,5 +1,6 @@ -import React from 'react'; +import React, { useState } from 'react'; import PropTypes from 'prop-types'; +import Link from 'next/link'; // Redux import { connect } from 'react-redux'; @@ -7,50 +8,72 @@ import { connect } from 'react-redux'; import { getCountries } from 'modules/countries'; // Intl -import { injectIntl } from 'react-intl'; +import { useIntl } from 'react-intl'; // Components import Layout from 'components/layout/layout'; import StaticHeader from 'components/ui/static-header'; import UserNewForm from 'components/users/new'; -class SignUp extends React.Component { - static async getInitialProps({ url, store }) { - await store.dispatch(getCountries()); - - return { url }; - } - - render() { - const { url } = this.props; - - return ( - - - - - - ); - } +const SignUp = (props) => { + const [submittedEmail, setSubmittedEmail] = useState(null); + const { url } = props; + const intl = useIntl(); + const creatingNewAccountText = intl.formatMessage({ id: "signup.user.header", defaultMessage: "Creating a new account" }); + const title = submittedEmail + ? intl.formatMessage({ id: "signup.user.thank_you_header", defaultMessage: "Thank you for signing up!" }) + : creatingNewAccountText + + return ( + + + + {!submittedEmail && setSubmittedEmail(email)} />} + {submittedEmail && ( +
+
+
+

+ {intl.formatMessage({ id: "signup.user.thank_you.paragraph1", defaultMessage: "We received your request and we will review it as soon as possible. This process might take a few days, and you will receive an email to {submittedEmail} once your account is approved. Be sure to check your spam folder." }, { submittedEmail })} +

+ +

+ {intl.formatMessage({ id: "signup.user.thank_you.paragraph2", defaultMessage: "In the meantime, you can explore the platform and learn more about the data we have available." })} +

+ + + + {intl.formatMessage({ id: 'Back to home page' })} + + +
+
+
+ )} +
+ ); +} + +SignUp.getInitialProps = async ({ url, store }) => { + await store.dispatch(getCountries()); + + return { url }; } SignUp.propTypes = { - url: PropTypes.shape({}).isRequired, - intl: PropTypes.object.isRequired, + url: PropTypes.shape({}).isRequired }; -export default injectIntl( - connect( - (state) => ({ - countries: state.countries, - }), - { getCountries } - )(SignUp) -); +export default connect( + (state) => ({ + countries: state.countries, + }), + { getCountries } +)(SignUp);