department-of-veterans-affairs/vets-website

View on GitHub
src/applications/discharge-wizard/reducers/v2/utilities.js

Summary

Maintainability
A
2 hrs
Test Coverage
export const createFormStore = shortNameMap => {
  const storeObject = {};

  for (const question of Object.keys(shortNameMap)) {
    if (!question.includes('HOME') && !question.includes('RESULTS')) {
      storeObject[question] = null;
    }
  }

  return storeObject;
};
export const setShortNameValue = (SHORT_NAME, newFormContents, state) => {
  return {
    ...state,
    form: {
      ...state.form,
      [SHORT_NAME]: newFormContents,
    },
  };
};

export const updateFormValue = (SHORT_NAME, state, action) => {
  return setShortNameValue(SHORT_NAME, action.payload, state);
};