27 lines
761 B
TypeScript
27 lines
761 B
TypeScript
import { action, Action } from 'easy-peasy';
|
|
|
|
export interface AdminRoleStore {
|
|
selectedRoles: number[];
|
|
|
|
setSelectedRoles: Action<AdminRoleStore, number[]>;
|
|
appendSelectedRole: Action<AdminRoleStore, number>;
|
|
removeSelectedRole: Action<AdminRoleStore, number>;
|
|
}
|
|
|
|
const roles: AdminRoleStore = {
|
|
selectedRoles: [],
|
|
|
|
setSelectedRoles: action((state, payload) => {
|
|
state.selectedRoles = payload;
|
|
}),
|
|
|
|
appendSelectedRole: action((state, payload) => {
|
|
state.selectedRoles = state.selectedRoles.filter(id => id !== payload).concat(payload);
|
|
}),
|
|
|
|
removeSelectedRole: action((state, payload) => {
|
|
state.selectedRoles = state.selectedRoles.filter(id => id !== payload);
|
|
}),
|
|
};
|
|
|
|
export default roles;
|