PromucFlow_constructor/app/client/src/pages/UserAuth/SignUp.tsx

173 lines
5.1 KiB
TypeScript
Raw Normal View History

2019-12-16 08:49:10 +00:00
import React from "react";
import { reduxForm, InjectedFormProps } from "redux-form";
import { AUTH_LOGIN_URL } from "constants/routes";
import { SIGNUP_FORM_NAME } from "constants/forms";
import { Link } from "react-router-dom";
import Divider from "components/editorComponents/Divider";
import {
AuthCardHeader,
AuthCardBody,
AuthCardFooter,
AuthCardNavLink,
SpacedForm,
FormActions,
AuthCardContainer,
} from "./StyledComponents";
import {
SIGNUP_PAGE_TITLE,
SIGNUP_PAGE_SUBTITLE,
SIGNUP_PAGE_EMAIL_INPUT_LABEL,
SIGNUP_PAGE_EMAIL_INPUT_PLACEHOLDER,
SIGNUP_PAGE_PASSWORD_INPUT_LABEL,
SIGNUP_PAGE_PASSWORD_INPUT_PLACEHOLDER,
SIGNUP_PAGE_LOGIN_LINK_TEXT,
FORM_VALIDATION_EMPTY_EMAIL,
FORM_VALIDATION_EMPTY_PASSWORD,
FORM_VALIDATION_INVALID_EMAIL,
FORM_VALIDATION_INVALID_PASSWORD,
SIGNUP_PAGE_SUBMIT_BUTTON_TEXT,
PRIVACY_POLICY_LINK,
TERMS_AND_CONDITIONS_LINK,
SIGNUP_PAGE_SUCCESS,
SIGNUP_PAGE_SUCCESS_LOGIN_BUTTON_TEXT,
FORM_VALIDATION_PASSWORD_RULE,
2019-12-16 08:49:10 +00:00
} from "constants/messages";
import FormMessage from "components/editorComponents/form/FormMessage";
import FormGroup from "components/editorComponents/form/FormGroup";
import FormTextField from "components/editorComponents/form/FormTextField";
2019-12-16 08:49:10 +00:00
import ThirdPartyAuth, { SocialLoginTypes } from "./ThirdPartyAuth";
2020-02-24 09:35:11 +00:00
import Button from "components/editorComponents/Button";
2019-12-16 08:49:10 +00:00
import { isEmail, isStrongPassword, isEmptyString } from "utils/formhelpers";
import { signupFormSubmitHandler, SignupFormValues } from "./helpers";
2020-03-11 13:59:46 +00:00
import AnalyticsUtil from "utils/AnalyticsUtil";
2019-12-16 08:49:10 +00:00
Use injected configuration from Nginx at runtime instead of build time (#30) * Use envsubst and nginx templates to generate nginx configs which can substitute environment variables and inject into the index.html file * Fix path in dockerfile. Add .gitignore and .env.example files. Fix nginx-linux template. * Add all environment variables. Add prefix to all environment variables. Update scripts to attempt to substitute all environment variables with the prefix * Setup dockerfile to execute a bash script. use env.example for fetching environment variables in development * Toggle features based on injected configs. Fix nginx template substitution script. * Update env.example file * Remove debug code from start-nginx.sh * Fix nginx config templates by adding quotes by default. Fix sed regex to include numerals. Toggle social login buttons on Login page based on the config. * Update rapid api environment variable name. Toggle oauth buttons based on config in SignUp page. Update .env.example to be a union of server and client environment variables * Adding a Map disabled message on Map widget * Adding links to Privacy policy and TNC * Use REACT_APP_ env variables with higher priority over injected config variables for toggling features * Update netlify.toml by commenting out the build environment variables * Remove env variables not required by the client * Remove start-storybook entry from package.json * Fix netlify.toml. Fallback algolia configs * Add contexts to netlify.toml for successful deploys. Swith to using APPSMITH_MARKETPLACE_URL as the toggle for RapidAPI feature on the client. Remove comments in nginx config templates. Fix template used in dockerfile. Co-authored-by: Satbir Singh <apple@apples-MacBook-Pro.local> Co-authored-by: Satbir Singh <satbir121@gmail.com>
2020-07-07 10:22:17 +00:00
import { getAppsmithConfigs } from "configs";
const {
enableGithubOAuth,
enableGoogleOAuth,
enableTNCPP,
} = getAppsmithConfigs();
const SocialLoginList: string[] = [];
if (enableGithubOAuth) SocialLoginList.push(SocialLoginTypes.GITHUB);
if (enableGoogleOAuth) SocialLoginList.push(SocialLoginTypes.GOOGLE);
export const TncPPLinks = () => {
if (!enableTNCPP) return null;
return (
<>
<Link target="_blank" to="/privacy-policy.html">
{PRIVACY_POLICY_LINK}
</Link>
<Link target="_blank" to="/terms-and-conditions.html">
{TERMS_AND_CONDITIONS_LINK}
</Link>
</>
);
};
2019-12-16 08:49:10 +00:00
const validate = (values: SignupFormValues) => {
const errors: SignupFormValues = {};
if (!values.password || isEmptyString(values.password)) {
errors.password = FORM_VALIDATION_EMPTY_PASSWORD;
} else if (!isStrongPassword(values.password)) {
errors.password = FORM_VALIDATION_INVALID_PASSWORD;
}
if (!values.email || isEmptyString(values.email)) {
errors.email = FORM_VALIDATION_EMPTY_EMAIL;
} else if (!isEmail(values.email)) {
errors.email = FORM_VALIDATION_INVALID_EMAIL;
}
return errors;
};
export const SignUp = (props: InjectedFormProps<SignupFormValues>) => {
const {
error,
handleSubmit,
submitting,
submitFailed,
submitSucceeded,
pristine,
valid,
2019-12-16 08:49:10 +00:00
} = props;
return (
<AuthCardContainer>
{submitSucceeded && (
<FormMessage
2019-12-16 08:49:10 +00:00
intent="success"
message={SIGNUP_PAGE_SUCCESS}
actions={[
{
url: AUTH_LOGIN_URL,
text: SIGNUP_PAGE_SUCCESS_LOGIN_BUTTON_TEXT,
intent: "success",
},
]}
/>
)}
{submitFailed && error && <FormMessage intent="danger" message={error} />}
2019-12-16 08:49:10 +00:00
<AuthCardHeader>
<h1>{SIGNUP_PAGE_TITLE}</h1>
<h5>{SIGNUP_PAGE_SUBTITLE}</h5>
</AuthCardHeader>
<AuthCardBody>
<SpacedForm onSubmit={handleSubmit(signupFormSubmitHandler)}>
<FormGroup
intent={error ? "danger" : "none"}
label={SIGNUP_PAGE_EMAIL_INPUT_LABEL}
>
<FormTextField
2019-12-16 08:49:10 +00:00
name="email"
type="email"
placeholder={SIGNUP_PAGE_EMAIL_INPUT_PLACEHOLDER}
/>
</FormGroup>
<FormGroup
intent={error ? "danger" : "none"}
label={SIGNUP_PAGE_PASSWORD_INPUT_LABEL}
helperText={FORM_VALIDATION_PASSWORD_RULE}
2019-12-16 08:49:10 +00:00
>
<FormTextField
2019-12-16 08:49:10 +00:00
type="password"
name="password"
placeholder={SIGNUP_PAGE_PASSWORD_INPUT_PLACEHOLDER}
/>
</FormGroup>
<FormActions>
2020-02-24 09:35:11 +00:00
<Button
2019-12-16 08:49:10 +00:00
type="submit"
disabled={pristine || !valid}
2019-12-16 08:49:10 +00:00
loading={submitting}
text={SIGNUP_PAGE_SUBMIT_BUTTON_TEXT}
intent="primary"
2020-02-24 09:35:11 +00:00
filled
size="large"
2020-03-11 13:59:46 +00:00
onClick={() => {
AnalyticsUtil.logEvent("SIGNUP_CLICK", {
signupMethod: "EMAIL",
});
}}
2019-12-16 08:49:10 +00:00
/>
</FormActions>
</SpacedForm>
Use injected configuration from Nginx at runtime instead of build time (#30) * Use envsubst and nginx templates to generate nginx configs which can substitute environment variables and inject into the index.html file * Fix path in dockerfile. Add .gitignore and .env.example files. Fix nginx-linux template. * Add all environment variables. Add prefix to all environment variables. Update scripts to attempt to substitute all environment variables with the prefix * Setup dockerfile to execute a bash script. use env.example for fetching environment variables in development * Toggle features based on injected configs. Fix nginx template substitution script. * Update env.example file * Remove debug code from start-nginx.sh * Fix nginx config templates by adding quotes by default. Fix sed regex to include numerals. Toggle social login buttons on Login page based on the config. * Update rapid api environment variable name. Toggle oauth buttons based on config in SignUp page. Update .env.example to be a union of server and client environment variables * Adding a Map disabled message on Map widget * Adding links to Privacy policy and TNC * Use REACT_APP_ env variables with higher priority over injected config variables for toggling features * Update netlify.toml by commenting out the build environment variables * Remove env variables not required by the client * Remove start-storybook entry from package.json * Fix netlify.toml. Fallback algolia configs * Add contexts to netlify.toml for successful deploys. Swith to using APPSMITH_MARKETPLACE_URL as the toggle for RapidAPI feature on the client. Remove comments in nginx config templates. Fix template used in dockerfile. Co-authored-by: Satbir Singh <apple@apples-MacBook-Pro.local> Co-authored-by: Satbir Singh <satbir121@gmail.com>
2020-07-07 10:22:17 +00:00
{SocialLoginList.length > 0 && <Divider />}
<ThirdPartyAuth type={"SIGNUP"} logins={SocialLoginList} />
2019-12-16 08:49:10 +00:00
</AuthCardBody>
Use injected configuration from Nginx at runtime instead of build time (#30) * Use envsubst and nginx templates to generate nginx configs which can substitute environment variables and inject into the index.html file * Fix path in dockerfile. Add .gitignore and .env.example files. Fix nginx-linux template. * Add all environment variables. Add prefix to all environment variables. Update scripts to attempt to substitute all environment variables with the prefix * Setup dockerfile to execute a bash script. use env.example for fetching environment variables in development * Toggle features based on injected configs. Fix nginx template substitution script. * Update env.example file * Remove debug code from start-nginx.sh * Fix nginx config templates by adding quotes by default. Fix sed regex to include numerals. Toggle social login buttons on Login page based on the config. * Update rapid api environment variable name. Toggle oauth buttons based on config in SignUp page. Update .env.example to be a union of server and client environment variables * Adding a Map disabled message on Map widget * Adding links to Privacy policy and TNC * Use REACT_APP_ env variables with higher priority over injected config variables for toggling features * Update netlify.toml by commenting out the build environment variables * Remove env variables not required by the client * Remove start-storybook entry from package.json * Fix netlify.toml. Fallback algolia configs * Add contexts to netlify.toml for successful deploys. Swith to using APPSMITH_MARKETPLACE_URL as the toggle for RapidAPI feature on the client. Remove comments in nginx config templates. Fix template used in dockerfile. Co-authored-by: Satbir Singh <apple@apples-MacBook-Pro.local> Co-authored-by: Satbir Singh <satbir121@gmail.com>
2020-07-07 10:22:17 +00:00
<AuthCardFooter>
<TncPPLinks></TncPPLinks>
</AuthCardFooter>
2019-12-16 08:49:10 +00:00
<AuthCardNavLink to={AUTH_LOGIN_URL}>
{SIGNUP_PAGE_LOGIN_LINK_TEXT}
</AuthCardNavLink>
</AuthCardContainer>
);
};
export default reduxForm<SignupFormValues>({
validate,
form: SIGNUP_FORM_NAME,
touchOnBlur: true,
})(SignUp);