misc_pterodactyl-panel/resources/scripts/state/admin/users.ts
2021-01-04 12:44:44 -07:00

27 lines
761 B
TypeScript

import { action, Action } from 'easy-peasy';
export interface AdminUserStore {
selectedUsers: number[];
setSelectedUsers: Action<AdminUserStore, number[]>;
appendSelectedUser: Action<AdminUserStore, number>;
removeSelectedUser: Action<AdminUserStore, number>;
}
const roles: AdminUserStore = {
selectedUsers: [],
setSelectedUsers: action((state, payload) => {
state.selectedUsers = payload;
}),
appendSelectedUser: action((state, payload) => {
state.selectedUsers = state.selectedUsers.filter(id => id !== payload).concat(payload);
}),
removeSelectedUser: action((state, payload) => {
state.selectedUsers = state.selectedUsers.filter(id => id !== payload);
}),
};
export default roles;