27 lines
761 B
TypeScript
27 lines
761 B
TypeScript
import { action, Action } from 'easy-peasy';
|
|
|
|
export interface AdminNestStore {
|
|
selectedNests: number[];
|
|
|
|
setSelectedNests: Action<AdminNestStore, number[]>;
|
|
appendSelectedNest: Action<AdminNestStore, number>;
|
|
removeSelectedNest: Action<AdminNestStore, number>;
|
|
}
|
|
|
|
const nests: AdminNestStore = {
|
|
selectedNests: [],
|
|
|
|
setSelectedNests: action((state, payload) => {
|
|
state.selectedNests = payload;
|
|
}),
|
|
|
|
appendSelectedNest: action((state, payload) => {
|
|
state.selectedNests = state.selectedNests.filter(id => id !== payload).concat(payload);
|
|
}),
|
|
|
|
removeSelectedNest: action((state, payload) => {
|
|
state.selectedNests = state.selectedNests.filter(id => id !== payload);
|
|
}),
|
|
};
|
|
|
|
export default nests;
|