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.
50 lines
1.3 KiB
50 lines
1.3 KiB
import { Reducer } from 'redux'
|
|
|
|
import { AppsActions } from '../actions/apps'
|
|
import { AppsState } from '../types'
|
|
|
|
const initialState: AppsState = {
|
|
items: [],
|
|
continuation: undefined,
|
|
created: {
|
|
items: [],
|
|
continuation: undefined
|
|
}
|
|
}
|
|
|
|
const reducer: Reducer<AppsState, AppsActions> = (state = initialState, action) => {
|
|
switch (action.type) {
|
|
case 'APPS_APPEND_APPS':
|
|
return {
|
|
...state,
|
|
items: action.payload.items,
|
|
continuation: action.payload.continuation,
|
|
}
|
|
case 'APPS_CLEAR_APPS':
|
|
return {
|
|
...state,
|
|
items: [],
|
|
continuation: undefined,
|
|
}
|
|
case 'APPS_APPEND_CREATED_APPS':
|
|
return {
|
|
...state,
|
|
created: {
|
|
items: action.payload.items,
|
|
continuation: action.payload.continuation,
|
|
},
|
|
}
|
|
case 'APPS_CLEAR_CREATED_APPS':
|
|
return {
|
|
...state,
|
|
created: {
|
|
items: [],
|
|
continuation: undefined,
|
|
},
|
|
}
|
|
default:
|
|
return state
|
|
}
|
|
}
|
|
|
|
export default reducer
|