diff options
author | 2022-07-12 17:59:43 +0100 | |
---|---|---|
committer | 2022-07-12 16:59:43 +0000 | |
commit | 6415f2746e38ebe5cb328c2af94413a4d4e5da07 (patch) | |
tree | 58cdabbcc7fe9c8ceec58780b73d2528210fdaff /src/components/auth/Signup.js | |
parent | 6.0.0-nightly.98 [skip ci] (diff) | |
download | ferdium-app-6415f2746e38ebe5cb328c2af94413a4d4e5da07.tar.gz ferdium-app-6415f2746e38ebe5cb328c2af94413a4d4e5da07.tar.zst ferdium-app-6415f2746e38ebe5cb328c2af94413a4d4e5da07.zip |
Refactor the 'Welcome' screen and the 'SetupAssistant' for better UX (#472)
* Change auth styling and add back button
* Add Skip button on 'SetupAssistant'
Diffstat (limited to 'src/components/auth/Signup.js')
-rw-r--r-- | src/components/auth/Signup.js | 191 |
1 files changed, 0 insertions, 191 deletions
diff --git a/src/components/auth/Signup.js b/src/components/auth/Signup.js deleted file mode 100644 index eaa68f918..000000000 --- a/src/components/auth/Signup.js +++ /dev/null | |||
@@ -1,191 +0,0 @@ | |||
1 | /* eslint jsx-a11y/anchor-is-valid: 0 */ | ||
2 | import { Component } from 'react'; | ||
3 | import PropTypes from 'prop-types'; | ||
4 | import { observer, inject } from 'mobx-react'; | ||
5 | import { defineMessages, injectIntl } from 'react-intl'; | ||
6 | |||
7 | import Form from '../../lib/Form'; | ||
8 | import { required, email, minLength } from '../../helpers/validation-helpers'; | ||
9 | import Input from '../ui/Input'; | ||
10 | import Button from '../ui/button'; | ||
11 | import Link from '../ui/Link'; | ||
12 | |||
13 | import { globalError as globalErrorPropType } from '../../prop-types'; | ||
14 | import { serverBase } from '../../api/apiBase'; | ||
15 | import { H1 } from '../ui/headline'; | ||
16 | |||
17 | const messages = defineMessages({ | ||
18 | headline: { | ||
19 | id: 'signup.headline', | ||
20 | defaultMessage: 'Sign up', | ||
21 | }, | ||
22 | firstnameLabel: { | ||
23 | id: 'signup.firstname.label', | ||
24 | defaultMessage: 'First Name', | ||
25 | }, | ||
26 | lastnameLabel: { | ||
27 | id: 'signup.lastname.label', | ||
28 | defaultMessage: 'Last Name', | ||
29 | }, | ||
30 | emailLabel: { | ||
31 | id: 'signup.email.label', | ||
32 | defaultMessage: 'Email address', | ||
33 | }, | ||
34 | // companyLabel: { | ||
35 | // id: 'signup.company.label', | ||
36 | // defaultMessage: 'Company', | ||
37 | // }, | ||
38 | passwordLabel: { | ||
39 | id: 'signup.password.label', | ||
40 | defaultMessage: 'Password', | ||
41 | }, | ||
42 | legalInfo: { | ||
43 | id: 'signup.legal.info', | ||
44 | defaultMessage: 'By creating a Ferdium account you accept the', | ||
45 | }, | ||
46 | terms: { | ||
47 | id: 'signup.legal.terms', | ||
48 | defaultMessage: 'Terms of service', | ||
49 | }, | ||
50 | privacy: { | ||
51 | id: 'signup.legal.privacy', | ||
52 | defaultMessage: 'Privacy Statement', | ||
53 | }, | ||
54 | submitButtonLabel: { | ||
55 | id: 'signup.submit.label', | ||
56 | defaultMessage: 'Create account', | ||
57 | }, | ||
58 | loginLink: { | ||
59 | id: 'signup.link.login', | ||
60 | defaultMessage: 'Already have an account, sign in?', | ||
61 | }, | ||
62 | emailDuplicate: { | ||
63 | id: 'signup.emailDuplicate', | ||
64 | defaultMessage: 'A user with that email address already exists', | ||
65 | }, | ||
66 | }); | ||
67 | |||
68 | class Signup extends Component { | ||
69 | static propTypes = { | ||
70 | onSubmit: PropTypes.func.isRequired, | ||
71 | isSubmitting: PropTypes.bool.isRequired, | ||
72 | loginRoute: PropTypes.string.isRequired, | ||
73 | error: globalErrorPropType.isRequired, | ||
74 | }; | ||
75 | |||
76 | form = (() => { | ||
77 | const { intl } = this.props; | ||
78 | return new Form({ | ||
79 | fields: { | ||
80 | firstname: { | ||
81 | label: intl.formatMessage(messages.firstnameLabel), | ||
82 | value: '', | ||
83 | validators: [required], | ||
84 | }, | ||
85 | lastname: { | ||
86 | label: intl.formatMessage(messages.lastnameLabel), | ||
87 | value: '', | ||
88 | validators: [required], | ||
89 | }, | ||
90 | email: { | ||
91 | label: intl.formatMessage(messages.emailLabel), | ||
92 | value: '', | ||
93 | validators: [required, email], | ||
94 | }, | ||
95 | password: { | ||
96 | label: intl.formatMessage(messages.passwordLabel), | ||
97 | value: '', | ||
98 | validators: [required, minLength(6)], | ||
99 | type: 'password', | ||
100 | }, | ||
101 | }, | ||
102 | }, | ||
103 | intl, | ||
104 | )})(); | ||
105 | |||
106 | submit(e) { | ||
107 | e.preventDefault(); | ||
108 | this.form.submit({ | ||
109 | onSuccess: form => { | ||
110 | this.props.onSubmit(form.values()); | ||
111 | }, | ||
112 | onError: () => {}, | ||
113 | }); | ||
114 | } | ||
115 | |||
116 | render() { | ||
117 | const { form } = this; | ||
118 | const { intl } = this.props; | ||
119 | const { isSubmitting, loginRoute, error } = this.props; | ||
120 | |||
121 | return ( | ||
122 | <div className="auth__scroll-container"> | ||
123 | <div className="auth__container auth__container--signup"> | ||
124 | <form | ||
125 | className="franz-form auth__form" | ||
126 | onSubmit={e => this.submit(e)} | ||
127 | > | ||
128 | <Link to='/auth/welcome'><img src="./assets/images/logo.svg" className="auth__logo" alt="" /></Link> | ||
129 | <H1>{intl.formatMessage(messages.headline)}</H1> | ||
130 | <div className="grid__row"> | ||
131 | <Input field={form.$('firstname')} focus /> | ||
132 | <Input field={form.$('lastname')} /> | ||
133 | </div> | ||
134 | <Input field={form.$('email')} /> | ||
135 | <Input | ||
136 | field={form.$('password')} | ||
137 | showPasswordToggle | ||
138 | scorePassword | ||
139 | /> | ||
140 | {error.code === 'email-duplicate' && ( | ||
141 | <p className="error-message center"> | ||
142 | {intl.formatMessage(messages.emailDuplicate)} | ||
143 | </p> | ||
144 | )} | ||
145 | {isSubmitting ? ( | ||
146 | <Button | ||
147 | className="auth__button is-loading" | ||
148 | label={`${intl.formatMessage(messages.submitButtonLabel)} ...`} | ||
149 | loaded={false} | ||
150 | disabled | ||
151 | /> | ||
152 | ) : ( | ||
153 | <Button | ||
154 | type="submit" | ||
155 | className="auth__button" | ||
156 | label={intl.formatMessage(messages.submitButtonLabel)} | ||
157 | /> | ||
158 | )} | ||
159 | <p className="legal"> | ||
160 | {intl.formatMessage(messages.legalInfo)} | ||
161 | <br /> | ||
162 | <Link | ||
163 | to={`${serverBase()}/terms`} | ||
164 | target="_blank" | ||
165 | className="link" | ||
166 | > | ||
167 | {intl.formatMessage(messages.terms)} | ||
168 | </Link> | ||
169 | & | ||
170 | <Link | ||
171 | to={`${serverBase()}/privacy`} | ||
172 | target="_blank" | ||
173 | className="link" | ||
174 | > | ||
175 | {intl.formatMessage(messages.privacy)} | ||
176 | </Link> | ||
177 | . | ||
178 | </p> | ||
179 | </form> | ||
180 | <div className="auth__links"> | ||
181 | <Link to={loginRoute}> | ||
182 | {intl.formatMessage(messages.loginLink)} | ||
183 | </Link> | ||
184 | </div> | ||
185 | </div> | ||
186 | </div> | ||
187 | ); | ||
188 | } | ||
189 | } | ||
190 | |||
191 | export default injectIntl(inject('actions')(observer(Signup))); | ||