diff --git a/resources/scripts/components/admin/nests/NestsContainer.tsx b/resources/scripts/components/admin/nests/NestsContainer.tsx index 9ae2f96ce..d44f448c6 100644 --- a/resources/scripts/components/admin/nests/NestsContainer.tsx +++ b/resources/scripts/components/admin/nests/NestsContainer.tsx @@ -23,9 +23,9 @@ const RowCheckbox = ({ id }: { id: number}) => { checked={isChecked} onChange={(e: React.ChangeEvent) => { if (e.currentTarget.checked) { - appendSelectedNest(name); + appendSelectedNest(id); } else { - removeSelectedNest(name); + removeSelectedNest(id); } }} /> diff --git a/resources/scripts/state/admin/nests.ts b/resources/scripts/state/admin/nests.ts index 3002c6d2c..a0d817a17 100644 --- a/resources/scripts/state/admin/nests.ts +++ b/resources/scripts/state/admin/nests.ts @@ -39,15 +39,11 @@ const nests: AdminNestStore = { }), appendSelectedNest: action((state, payload) => { - if (state.selectedNests.find(id => id === payload)) { - state.selectedNests = state.selectedNests.map(id => id === payload ? payload : id); - } else { - state.selectedNests = [ ...state.selectedNests, payload ]; - } + state.selectedNests = state.selectedNests.filter(id => id !== payload).concat(payload); }), removeSelectedNest: action((state, payload) => { - state.selectedNests = [ ...state.selectedNests.filter(id => id !== payload) ]; + state.selectedNests = state.selectedNests.filter(id => id !== payload); }), };