misc_pterodactyl-panel/resources/scripts/state/admin/nests.ts
2021-01-03 16:25:32 -07:00

27 lines
761 B
TypeScript

import { action, Action } from 'easy-peasy';
export interface AdminNestStore {
selectedNests: number[];
setSelectedNests: Action<AdminNestStore, number[]>;
appendSelectedNest: Action<AdminNestStore, number>;
removeSelectedNest: Action<AdminNestStore, number>;
}
const nests: AdminNestStore = {
selectedNests: [],
setSelectedNests: action((state, payload) => {
state.selectedNests = payload;
}),
appendSelectedNest: action((state, payload) => {
state.selectedNests = state.selectedNests.filter(id => id !== payload).concat(payload);
}),
removeSelectedNest: action((state, payload) => {
state.selectedNests = state.selectedNests.filter(id => id !== payload);
}),
};
export default nests;