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

28 lines
801 B
TypeScript
Raw Normal View History

import { action, Action } from 'easy-peasy';
export interface AdminServerStore {
selectedServers: number[];
setSelectedServers: Action<AdminServerStore, number[]>;
appendSelectedServer: Action<AdminServerStore, number>;
removeSelectedServer: Action<AdminServerStore, number>;
}
2021-09-11 19:20:53 +00:00
const servers: AdminServerStore = {
selectedServers: [],
setSelectedServers: action((state, payload) => {
state.selectedServers = payload;
}),
appendSelectedServer: action((state, payload) => {
state.selectedServers = state.selectedServers.filter(id => id !== payload).concat(payload);
}),
removeSelectedServer: action((state, payload) => {
state.selectedServers = state.selectedServers.filter(id => id !== payload);
}),
};
2021-09-11 19:20:53 +00:00
export default servers;