mirror of
https://github.com/strapi/strapi.git
synced 2025-09-19 13:31:34 +00:00
20 lines
670 B
JavaScript
20 lines
670 B
JavaScript
import createArrayOfValues from './createArrayOfValues';
|
|
import removeConditionKeyFromData from './removeConditionKeyFromData';
|
|
|
|
const getCheckboxState = dataObj => {
|
|
const dataWithoutCondition = removeConditionKeyFromData(dataObj);
|
|
|
|
const arrayOfValues = createArrayOfValues(dataWithoutCondition);
|
|
|
|
if (!arrayOfValues.length) {
|
|
return { hasAllActionsSelected: false, hasSomeActionsSelected: false };
|
|
}
|
|
|
|
const hasAllActionsSelected = arrayOfValues.every(val => val);
|
|
const hasSomeActionsSelected = arrayOfValues.some(val => val) && !hasAllActionsSelected;
|
|
|
|
return { hasAllActionsSelected, hasSomeActionsSelected };
|
|
};
|
|
|
|
export default getCheckboxState;
|