<commit_before>import _ from 'lodash';
import Joi from 'joi';
import sendEmail from '../../../../shared/lib/send-exchange-email';
import {validate} from './common';

const schema = Joi.object().keys({
  'submit': Joi.any().optional().strip()
});


const title = 'Summary?';
const key = 'summary';
const nextStep = 'end';


function summaryGetHandler(request, reply) {
  request.log(['cookie'], request.state.data);
  const data = _.get(request, 'state.data', {});
  return reply
    .view('register-form/summary', {data, title});
}

function summaryPostHandler(request, reply) {
  validate(request.payload, schema)
    .then(value => {
      const data = _.get(request, 'state.data', {});
      request.server.plugins.NunjucksConfig.nunjucksEnv.render(
        'email/registration-summary.njk',
        {data: data}
      ).then(emailText => {
        sendEmail(
          process.env.EMAIL_USERNAME,
          emailText,
          'Patient registration'
        ).then(() => {
          return reply
            .redirect(request.aka(nextStep))
            .state('data', _.merge({}, request.state.data, {[key]: value}));
        }).catch(err => {
          throw err;
        });
      });
    })
    .catch(err => {
      request.log(['error'], err);
      return reply
        .redirect(request.aka(`register-form:${key}`));
    });
}

const handlers = {
  GET: summaryGetHandler,
  POST: summaryPostHandler
};

exports.options = {
  title,
  schema,
  handlers
};

export default [key, exports.options];
<commit_msg>Remove ? from page title<commit_after>import _ from 'lodash';
import Joi from 'joi';
import sendEmail from '../../../../shared/lib/send-exchange-email';
import {validate} from './common';

const schema = Joi.object().keys({
  'submit': Joi.any().optional().strip()
});


const title = 'Summary';
const key = 'summary';
const nextStep = 'end';


function summaryGetHandler(request, reply) {
  request.log(['cookie'], request.state.data);
  const data = _.get(request, 'state.data', {});
  return reply
    .view('register-form/summary', {data, title});
}

function summaryPostHandler(request, reply) {
  validate(request.payload, schema)
    .then(value => {
      const data = _.get(request, 'state.data', {});
      request.server.plugins.NunjucksConfig.nunjucksEnv.render(
        'email/registration-summary.njk',
        {data: data}
      ).then(emailText => {
        sendEmail(
          process.env.EMAIL_USERNAME,
          emailText,
          'Patient registration'
        ).then(() => {
          return reply
            .redirect(request.aka(nextStep))
            .state('data', _.merge({}, request.state.data, {[key]: value}));
        }).catch(err => {
          throw err;
        });
      });
    })
    .catch(err => {
      request.log(['error'], err);
      return reply
        .redirect(request.aka(`register-form:${key}`));
    });
}

const handlers = {
  GET: summaryGetHandler,
  POST: summaryPostHandler
};

exports.options = {
  title,
  schema,
  handlers
};

export default [key, exports.options];

{'fraction_non_alphanumeric': 0.17365661861074705, 'fraction_numerical': 0.0, 'mean_word_length': 2.7460122699386504, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3219976', 'n_tokens_mistral': 942, 'n_tokens_neox': 931, 'n_words': 193}