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

28 lines
761 B
TypeScript
Raw Normal View History

2021-01-04 19:44:44 +00:00
import { action, Action } from 'easy-peasy';
export interface AdminUserStore {
selectedUsers: number[];
setSelectedUsers: Action<AdminUserStore, number[]>;
appendSelectedUser: Action<AdminUserStore, number>;
removeSelectedUser: Action<AdminUserStore, number>;
}
2021-09-11 19:20:53 +00:00
const users: AdminUserStore = {
2021-01-04 19:44:44 +00:00
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);
}),
};
2021-09-11 19:20:53 +00:00
export default users;