<commit_before>import {takeLatest, take, call, put, select } from 'redux-saga/effects';
import { delay } from 'redux-saga'
import { emailModulesComplete, emailModulesError, emailClearAll} from './actions';
import { REQUEST_EMAIL, EMAIL_CLEAR_ALL } from './constants';

import request from 'utils/request';

const getUserEmail = (state) => state.get('emailTools');
const getTools = (state) => state.get('tools');
const getLanguage = (state) => state.get('language');

export function* sendModulesToEmail() {
  const emailTools = yield select(getUserEmail);
  const tools = yield select(getTools);
  const language = yield select(getLanguage);

  const userEmail = emailTools.get('email');
  const selectedTools = tools.get('selectedTools');
  const locale = language.get('locale');

  const toolsValue = selectedTools.map(item=>item.slug).join(',');

  const requestURL = `https://api.beautifulrising.org/pdf/email?tools=${encodeURIComponent(toolsValue)}&lang=${encodeURIComponent(locale)}&address=${encodeURIComponent(userEmail)}`;

  try {
    const data = yield call(request, requestURL);
    yield put(emailModulesComplete());

    yield delay(3000);
    yield put(emailClearAll());
  } catch (e) {
    yield call(put, emailModulesError());
  }



}
// Individual exports for testing
export function* listenEmailModules() {
  // See example in containers/HomePage/sagas.js
  yield takeLatest(REQUEST_EMAIL, sendModulesToEmail);
}

// This will hide the tools area the page
// when the user changes a page if at all...
export function* listenToPageChange() {

}

// All sagas to be loaded
export default [
  listenEmailModules,
];
<commit_msg>Email tools fix<commit_after>import {takeLatest, take, call, put, select } from 'redux-saga/effects';
import { delay } from 'redux-saga'
import { emailModulesComplete, emailModulesError, emailClearAll} from './actions';
import { REQUEST_EMAIL, EMAIL_CLEAR_ALL } from './constants';

import request from 'utils/request';

const getUserEmail = (state) => state.get('emailTools');
const getTools = (state) => state.get('tools');
const getLanguage = (state) => state.get('language');

export function* sendModulesToEmail() {
  const emailTools = yield select(getUserEmail);
  const tools = yield select(getTools);
  const language = yield select(getLanguage);

  const userEmail = emailTools.get('email');
  const selectedTools = tools.get('selectedTools');
  const locale = language.get('locale');

  const toolsValue = selectedTools.map(item=>item.slug).join(',');

  const requestURL = `https://api.beautifulrising.org/pdf/email?tools=${encodeURIComponent(toolsValue)}&lang=${encodeURIComponent(locale)}&address=${encodeURIComponent(userEmail)}`;

  try {
    const data = yield call(request, requestURL, { mode: 'no-cors'});
    yield put(emailModulesComplete());

    yield delay(3000);
    yield put(emailClearAll());
  } catch (e) {
    yield call(put, emailModulesError());
  }



}
// Individual exports for testing
export function* listenEmailModules() {
  // See example in containers/HomePage/sagas.js
  yield takeLatest(REQUEST_EMAIL, sendModulesToEmail);
}

// This will hide the tools area the page
// when the user changes a page if at all...
export function* listenToPageChange() {

}

// All sagas to be loaded
export default [
  listenEmailModules,
];

{'fraction_non_alphanumeric': 0.13556763285024154, 'fraction_numerical': 0.0024154589371980675, 'mean_word_length': 5.123844731977819, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, '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': '3084297', 'n_tokens_mistral': 987, 'n_tokens_neox': 992, 'n_words': 260}