summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/nav/utils/reset_menu_items_active.js
blob: 9b5d8e97c9c0fe16deb985c246d80f4f3ee7de1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
const resetActiveInArray = (arr) => arr?.map((menuItem) => ({ ...menuItem, active: false }));

/**
 * This method sets `active: false` for the menu items within the given nav data.
 *
 * @returns navData with the menu items updated with `active: false`
 */
export const resetMenuItemsActive = ({ primary, secondary, ...navData }) => {
  return {
    ...navData,
    primary: resetActiveInArray(primary),
    secondary: resetActiveInArray(secondary),
  };
};