department-of-veterans-affairs/vets-website

View on GitHub
src/applications/representative-search/utils/helpers.js

Summary

Maintainability
A
25 mins
Test Coverage
export const appendReportsFromLocalStorage = resultsArray => {
  const localReportsArray = localStorage.getItem('vaReports');

  if (localReportsArray) {
    const parsedLocalReportsArray = JSON.parse(localReportsArray);
    for (const localReport of parsedLocalReportsArray) {
      const resultMatch = resultsArray.find(
        resultItem => resultItem.id === localReport.representativeId,
      );

      if (resultMatch) {
        resultMatch.reports = localReport.reports;
      }
    }
  }

  return resultsArray;
};

/**
 * "Enum" of keyboard keys to their numerical equivalent
 */
export const keyMap = {
  TAB: 9,
  ENTER: 13,
  ESCAPE: 27,
  SPACE: 32,
  UP: 38,
  DOWN: 40,
};