misc_pterodactyl-panel/resources/scripts/state/admin/nests.ts

28 lines
761 B
TypeScript
Raw Normal View History

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