department-of-veterans-affairs/vets-website

View on GitHub
src/applications/discharge-wizard/utilities/answer-cleanup.js

Summary

Maintainability
A
0 mins
Test Coverage
import { questionsToClearMap } from '../constants';

export const cleanUpAnswers = (
  responsesInStore,
  updateCleanedFormStore,
  currentQuestionName,
) => {
  const responsesToClean = responsesInStore;
  if (questionsToClearMap[currentQuestionName].length) {
    for (const question of questionsToClearMap[currentQuestionName]) {
      responsesToClean[question] = null;
    }
    updateCleanedFormStore(responsesToClean);
  }
};