<commit_before>// Copyright © 2015-2019 <NAME>
// This software is released under the Apache License 2.0.
// The license text is at http://www.apache.org/licenses/LICENSE-2.0

/* @flow */

import React from "react";
import {ErrorMessage, Field, Form, Formik} from "formik";
import {createCongregation, getSettings} from "../api";
import {buildAuthenticator} from "../authentication";
import {navigate} from "@reach/router";

const RegistrationPage = () => {
  const settings = getSettings();
  const loggedIn = settings.user.authenticated;

  if (!loggedIn) {
    const {domain, clientId} = settings.auth0;
    const auth = buildAuthenticator(domain, clientId);
    auth.login();
    return <p>Please wait, you will be redirected...</p>;
  }

  return (
    <>
      <h1>Registration</h1>

      <h2>Join an Existing Congregation</h2>
      <p>TODO: instructions</p>

      <h2>Register a New Congregation</h2>

      <Formik initialValues={{congregationName: ""}}
              validate={values => {
                let errors = {};
                if (!values.congregationName) {
                  errors.congregationName = "Congregation name is required.";
                }
                return errors;
              }}
              onSubmit={async (values, {setSubmitting}) => {
                try {
                  const id = await createCongregation(values.congregationName);
                  // TODO: use short IDs
                  navigate(`/congregation/${id}`);
                } finally {
                  setSubmitting(false)
                }
              }}>
        {({isSubmitting}) => (
          <Form className="pure-form pure-form-aligned">
            <fieldset>
              <div className="pure-control-group">
                <label htmlFor="congregationName">Congregation Name</label>
                <Field type="text" name="congregationName" id="congregationName"/>
                <ErrorMessage name="congregationName" component="div" className="pure-form-message-inline"/>
              </div>
              <div className="pure-controls">
                <button type="submit" disabled={isSubmitting} className="pure-button pure-button-primary">
                  Register
                </button>
              </div>
            </fieldset>
          </Form>
        )}
      </Formik>

      <p>It is recommended to <a href="https://groups.google.com/forum/#!forum/territory-bro-announcements/join">subscribe
        to the announcements mailing list</a> to be notified about important updates to Territory Bro.</p>
    </>
  );
};

export default RegistrationPage;
<commit_msg>📝 Placeholder text for joining an existing congregation<commit_after>// Copyright © 2015-2019 <NAME>
// This software is released under the Apache License 2.0.
// The license text is at http://www.apache.org/licenses/LICENSE-2.0

/* @flow */

import React from "react";
import {ErrorMessage, Field, Form, Formik} from "formik";
import {createCongregation, getSettings} from "../api";
import {buildAuthenticator} from "../authentication";
import {navigate} from "@reach/router";

const RegistrationPage = () => {
  const settings = getSettings();
  const loggedIn = settings.user.authenticated;

  if (!loggedIn) {
    const {domain, clientId} = settings.auth0;
    const auth = buildAuthenticator(domain, clientId);
    auth.login();
    return <p>Please wait, you will be redirected...</p>;
  }

  return (
    <>
      <h1>Registration</h1>

      <h2>Join an Existing Congregation</h2>

      <p>Coming soon. <a href="https://groups.google.com/forum/#!forum/territory-bro-announcements/join">Subscribe to
        the mailing list</a> to be notified when this becomes available.</p>

      <h2>Register a New Congregation</h2>

      <Formik initialValues={{congregationName: ""}}
              validate={values => {
                let errors = {};
                if (!values.congregationName) {
                  errors.congregationName = "Congregation name is required.";
                }
                return errors;
              }}
              onSubmit={async (values, {setSubmitting}) => {
                try {
                  const id = await createCongregation(values.congregationName);
                  // TODO: use short IDs
                  navigate(`/congregation/${id}`);
                } finally {
                  setSubmitting(false)
                }
              }}>
        {({isSubmitting}) => (
          <Form className="pure-form pure-form-aligned">
            <fieldset>
              <div className="pure-control-group">
                <label htmlFor="congregationName">Congregation Name</label>
                <Field type="text" name="congregationName" id="congregationName"/>
                <ErrorMessage name="congregationName" component="div" className="pure-form-message-inline"/>
              </div>
              <div className="pure-controls">
                <button type="submit" disabled={isSubmitting} className="pure-button pure-button-primary">
                  Register
                </button>
              </div>
            </fieldset>
          </Form>
        )}
      </Formik>

      <p>It is recommended to <a href="https://groups.google.com/forum/#!forum/territory-bro-announcements/join">subscribe
        to the announcements mailing list</a> to be notified about important updates to Territory Bro.</p>
    </>
  );
};

export default RegistrationPage;

{'fraction_non_alphanumeric': 0.1277961129446278, 'fraction_numerical': 0.006967363403006967, 'mean_word_length': 2.1082621082621085, 'pattern_counts': {'":': 0, '<': 71, '<?xml version=': 0, '>': 79, 'https://': 3, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1986771', 'n_tokens_mistral': 1547, 'n_tokens_neox': 1409, 'n_words': 354}