mirror of
https://github.com/strapi/strapi.git
synced 2025-09-20 14:00:48 +00:00
17 lines
511 B
JavaScript
17 lines
511 B
JavaScript
import createArrayOfValues from './createArrayOfValues';
|
|
|
|
const getCheckboxState = data => {
|
|
const arrayOfValues = createArrayOfValues(data);
|
|
|
|
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;
|