You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
925 B
36 lines
925 B
import { Reducer } from 'redux'
|
|
|
|
import { DirectoryActions } from '../actions/directory'
|
|
import { DirectoryState } from '../types'
|
|
|
|
const initialState: DirectoryState = {
|
|
groups: [],
|
|
continuation: undefined,
|
|
}
|
|
|
|
const reducer: Reducer<DirectoryState, DirectoryActions> = (state = initialState, action) => {
|
|
switch (action.type) {
|
|
case 'DIRECTORY_SET_GROUPS':
|
|
return {
|
|
...state,
|
|
groups: action.payload,
|
|
}
|
|
case 'DIRECTORY_APPEND_GROUPS':
|
|
return {
|
|
...state,
|
|
groups: [
|
|
...state.groups,
|
|
...action.payload,
|
|
],
|
|
}
|
|
case 'DIRECTORY_SET_CONTINUATION':
|
|
return {
|
|
...state,
|
|
continuation: action.payload,
|
|
}
|
|
default:
|
|
return state
|
|
}
|
|
}
|
|
|
|
export default reducer
|