<commit_before>import _ from 'lodash/fp';

import {
  UPDATE_PROFILE_FIELD,
  FETCHING_MHV_TERMS_ACCEPTANCE,
  FETCHING_MHV_TERMS_ACCEPTANCE_SUCCESS,
  FETCHING_MHV_TERMS_ACCEPTANCE_FAILURE,
  FETCHING_LATEST_MHV_TERMS,
  FETCHING_LATEST_MHV_TERMS_SUCCESS,
  FETCHING_LATEST_MHV_TERMS_FAILURE,
  ACCEPTING_LATEST_MHV_TERMS,
  ACCEPTING_LATEST_MHV_TERMS_SUCCESS,
  ACCEPTING_LATEST_MHV_TERMS_FAILURE,
 } from '../actions';

// TODO(crew): Romove before this goes to production.
const initialState = {
  userFullName: {
    first: null,
    middle: null,
    last: null,
    suffix: null,
  },
  email: null,
  dob: null,
  gender: null,
  accountType: null,
  terms: {
    loading: false,
    acceptance: false,
    terms: {},
  }
};

function profileInformation(state = initialState, action) {
  switch (action.type) {
    case UPDATE_PROFILE_FIELD: {
      return _.set(action.propertyPath, action.value, state);
    }
    case FETCHING_MHV_TERMS_ACCEPTANCE: {
      return {
        ...state,
        terms: {
          loading: true,
        }
      };
    }
    case FETCHING_MHV_TERMS_ACCEPTANCE_SUCCESS: {
      return {
        ...state,
        terms: {
          loading: false,
          acceptance: action.acceptance,
        }
      };
    }
    case FETCHING_MHV_TERMS_ACCEPTANCE_FAILURE: {
      return {
        ...state,
        terms: {
          loading: false,
        }
      };
    }
    case FETCHING_LATEST_MHV_TERMS: {
      return {
        ...state,
        terms: {
          ...state.terms,
          content: {},
          loading: true,
        }
      };
    }
    case FETCHING_LATEST_MHV_TERMS_SUCCESS: {
      return {
        ...state,
        terms: {
          ...state.terms,
          ...action.terms,
          loading: false,
        }
      };
    }
    case FETCHING_LATEST_MHV_TERMS_FAILURE: {
      return {
        ...state,
        terms: {
          loading: false,
        }
      };
    }
    case ACCEPTING_LATEST_MHV_TERMS: {
      return state;
    }
    case ACCEPTING_LATEST_MHV_TERMS_SUCCESS: {
      return {
        ...state,
        terms: {
          acceptance: true,
          loading: false,
        }
      };
    }
    case ACCEPTING_LATEST_MHV_TERMS_FAILURE: {
      return {
        ...state,
        terms: {
          loading: false,
        }
      };
    }

    default:
      return state;
  }
}

export default profileInformation;
<commit_msg>fix bug for users who havent accepted terms<commit_after>import _ from 'lodash/fp';

import {
  UPDATE_PROFILE_FIELD,
  FETCHING_MHV_TERMS_ACCEPTANCE,
  FETCHING_MHV_TERMS_ACCEPTANCE_SUCCESS,
  FETCHING_MHV_TERMS_ACCEPTANCE_FAILURE,
  FETCHING_LATEST_MHV_TERMS,
  FETCHING_LATEST_MHV_TERMS_SUCCESS,
  FETCHING_LATEST_MHV_TERMS_FAILURE,
  ACCEPTING_LATEST_MHV_TERMS,
  ACCEPTING_LATEST_MHV_TERMS_SUCCESS,
  ACCEPTING_LATEST_MHV_TERMS_FAILURE,
 } from '../actions';

// TODO(crew): Romove before this goes to production.
const initialState = {
  userFullName: {
    first: null,
    middle: null,
    last: null,
    suffix: null,
  },
  email: null,
  dob: null,
  gender: null,
  accountType: null,
  terms: {
    loading: false,
    acceptance: false,
    terms: {},
  }
};

function profileInformation(state = initialState, action) {
  switch (action.type) {
    case UPDATE_PROFILE_FIELD: {
      return _.set(action.propertyPath, action.value, state);
    }
    case FETCHING_MHV_TERMS_ACCEPTANCE: {
      return {
        ...state,
        terms: {
          loading: true,
        }
      };
    }
    case FETCHING_MHV_TERMS_ACCEPTANCE_SUCCESS: {
      return {
        ...state,
        terms: {
          loading: false,
          acceptance: action.acceptance,
        }
      };
    }
    case FETCHING_MHV_TERMS_ACCEPTANCE_FAILURE: {
      return {
        ...state,
        terms: {
          ...state.terms,
          loading: false,
        }
      };
    }
    case FETCHING_LATEST_MHV_TERMS: {
      return {
        ...state,
        terms: {
          ...state.terms,
          content: {},
          loading: true,
        }
      };
    }
    case FETCHING_LATEST_MHV_TERMS_SUCCESS: {
      return {
        ...state,
        terms: {
          ...state.terms,
          ...action.terms,
          loading: false,
        }
      };
    }
    case FETCHING_LATEST_MHV_TERMS_FAILURE: {
      return {
        ...state,
        terms: {
          acceptance: false,
          loading: false,
        }
      };
    }
    case ACCEPTING_LATEST_MHV_TERMS: {
      return state;
    }
    case ACCEPTING_LATEST_MHV_TERMS_SUCCESS: {
      return {
        ...state,
        terms: {
          acceptance: true,
          loading: false,
        }
      };
    }
    case ACCEPTING_LATEST_MHV_TERMS_FAILURE: {
      return {
        ...state,
        terms: {
          ...state.terms,
          loading: false,
        }
      };
    }

    default:
      return state;
  }
}

export default profileInformation;

{'fraction_non_alphanumeric': 0.09913008294557961, 'fraction_numerical': 0.0, 'mean_word_length': 1.8059023836549375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2352197', 'n_tokens_mistral': 1773, 'n_tokens_neox': 1729, 'n_words': 279}