Skip to content

Commit

Permalink
Fixed nested logic
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmarete committed Nov 15, 2024
1 parent da66dcf commit cd5b0f7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/pages/FeaturePreviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ export const FeaturePreviews = () => {
setFeaturePreviewState(getFeaturePreviewState());
}, [getFeaturePreviewState]);

const handleToggleAll = (checked) => {
_.forEach(({ id }) => {
toggleFeaturePreview(id, checked);
setFeaturePreviewState(_.set(id, checked));
}, featurePreviews);
};

return Utils.cond(
[loading, () => spinnerOverlay],
[error, () => p({ style: { margin: 0 } }, ['Unable to load feature previews.'])],
Expand All @@ -54,12 +61,7 @@ export const FeaturePreviews = () => {
return h(Switch, {
onLabel: '',
offLabel: '',
onChange: (checked) => {
_.forEach(({ id }) => {
toggleFeaturePreview(id, checked);
setFeaturePreviewState(_.set(id, checked));
}, featurePreviews);
},
onChange: handleToggleAll,
id: 'toggle-all',
checked: allEnabled,
width: 30,
Expand Down

0 comments on commit cd5b0f7

Please sign in to comment.