feat: adding a toggle switch for left panel items

This commit is contained in:
Anuraag Gupta
2021-02-26 02:05:51 +05:30
parent d98e591fee
commit cf47447102
17 changed files with 18168 additions and 72 deletions

View File

@ -1,5 +1,5 @@
import dayjs from 'dayjs';
import { get, isEmpty } from 'lodash';
import { get, isEmpty, clone } from 'lodash';
export const getModalText = (isEditMode, type, t) =>
isEditMode
@ -9,6 +9,18 @@ export const getModalText = (isEditMode, type, t) =>
export const safetyCheck = (section, path = 'items') =>
!!(section && section.visible === true && !isEmpty(section[path]));
export const isItemVisible = (section) =>
section && section.isVisible !== false;
// Thought about creating a generic function to filter out non-visible items
export const genericFilter = (key, data) => {
const clonedData = clone(data);
clonedData[`${key}`].items = clonedData[`${key}`].items.filter((x) =>
isItemVisible(x),
);
return data;
};
export const handleKeyUp = (event, action) => {
(event.which === 13 || event.which === 32) && action();
};