forked from Alex/Pterodactyl-Panel
Fix checkboxes in NestsContainer.tsx
This commit is contained in:
parent
f72402b5fa
commit
04799fa44b
@ -23,9 +23,9 @@ const RowCheckbox = ({ id }: { id: number}) => {
|
|||||||
checked={isChecked}
|
checked={isChecked}
|
||||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
if (e.currentTarget.checked) {
|
if (e.currentTarget.checked) {
|
||||||
appendSelectedNest(name);
|
appendSelectedNest(id);
|
||||||
} else {
|
} else {
|
||||||
removeSelectedNest(name);
|
removeSelectedNest(id);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -39,15 +39,11 @@ const nests: AdminNestStore = {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
appendSelectedNest: action((state, payload) => {
|
appendSelectedNest: action((state, payload) => {
|
||||||
if (state.selectedNests.find(id => id === payload)) {
|
state.selectedNests = state.selectedNests.filter(id => id !== payload).concat(payload);
|
||||||
state.selectedNests = state.selectedNests.map(id => id === payload ? payload : id);
|
|
||||||
} else {
|
|
||||||
state.selectedNests = [ ...state.selectedNests, payload ];
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
removeSelectedNest: action((state, payload) => {
|
removeSelectedNest: action((state, payload) => {
|
||||||
state.selectedNests = [ ...state.selectedNests.filter(id => id !== payload) ];
|
state.selectedNests = state.selectedNests.filter(id => id !== payload);
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user