config#REGISTRATION_HELP_LINK TypeScript Examples

The following examples show how to use config#REGISTRATION_HELP_LINK. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Registration.tsx    From glific-frontend with GNU Affero General Public License v3.0 4 votes vote down vote up
Registration: React.SFC<RegistrationProps> = () => {
  const [redirect, setRedirect] = useState(false);
  const [user, setUser] = useState({ userName: '', phone: '', password: '' });
  const [authError, setAuthError] = useState('');
  const { t } = useTranslation();

  if (redirect) {
    return (
      <Redirect
        to={{
          pathname: '/confirmotp',
          state: {
            name: user.userName,
            phoneNumber: user.phone,
            password: user.password,
          },
        }}
      />
    );
  }

  const onSubmitRegistration = (values: any) => {
    sendOTP(values.phone, 'true')
      .then(() => {
        setUser(values);
        setRedirect(true);
      })
      .catch(() => {
        setAuthError(t('We are unable to register, kindly contact your technical team.'));
      });
  };

  const staffInstructions = (
    <div className={styles.Instructions}>
      <AlertIcon />
      <div>
        {t('Please optin to your org chatbot number before proceeding below. ')}
        <a
          href={REGISTRATION_HELP_LINK}
          rel="noreferrer"
          target="_blank"
          className={styles.DocumentationLink}
        >
          {t('Here’s how.')}
        </a>
      </div>
    </div>
  );

  const formFields = [
    {
      component: Input,
      name: 'userName',
      type: 'text',
      placeholder: t('Your name'),
    },
    {
      component: PhoneInput,
      name: 'phone',
      type: 'phone',
      placeholder: t('Your phone number'),
      helperText: t('Please enter a phone number.'),
    },
    {
      component: Input,
      name: 'password',
      type: 'password',
      placeholder: t('Password'),
    },
  ];

  const FormSchema = Yup.object().shape({
    userName: Yup.string().required(t('Input required')),
    phone: Yup.string().required(t('Input required')),
    password: Yup.string()
      .min(8, t('Password must be at least 8 characters long.'))
      .required(t('Input required')),
  });

  const initialFormValues = { userName: '', phone: '', password: '' };

  return (
    <Auth
      pageTitle={t('Create your new account')}
      buttonText={t('Continue')}
      staffInstructions={staffInstructions}
      alternateLink="login"
      alternateText={t('Login to Glific')}
      mode="registration"
      formFields={formFields}
      validationSchema={FormSchema}
      saveHandler={onSubmitRegistration}
      initialFormValues={initialFormValues}
      errorMessage={authError}
    />
  );
}