2021-01-01 00:27:16 +00:00
|
|
|
import { action, Action } from 'easy-peasy';
|
|
|
|
|
|
|
|
export interface AdminNestStore {
|
2021-01-01 22:55:30 +00:00
|
|
|
selectedNests: number[];
|
|
|
|
|
|
|
|
setSelectedNests: Action<AdminNestStore, number[]>;
|
|
|
|
appendSelectedNest: Action<AdminNestStore, number>;
|
|
|
|
removeSelectedNest: Action<AdminNestStore, number>;
|
2021-01-01 00:27:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const nests: AdminNestStore = {
|
2021-01-01 22:55:30 +00:00
|
|
|
selectedNests: [],
|
2021-01-01 00:27:16 +00:00
|
|
|
|
2021-01-01 22:55:30 +00:00
|
|
|
setSelectedNests: action((state, payload) => {
|
|
|
|
state.selectedNests = payload;
|
|
|
|
}),
|
|
|
|
|
|
|
|
appendSelectedNest: action((state, payload) => {
|
2021-01-01 23:34:10 +00:00
|
|
|
state.selectedNests = state.selectedNests.filter(id => id !== payload).concat(payload);
|
2021-01-01 22:55:30 +00:00
|
|
|
}),
|
|
|
|
|
|
|
|
removeSelectedNest: action((state, payload) => {
|
2021-01-01 23:34:10 +00:00
|
|
|
state.selectedNests = state.selectedNests.filter(id => id !== payload);
|
2021-01-01 22:55:30 +00:00
|
|
|
}),
|
2021-01-01 00:27:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default nests;
|