mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-07 20:05:18 +02:00
Apps actions and reducer
This commit is contained in:
parent
2acc3b72ec
commit
78acede8ab
15 changed files with 230 additions and 27 deletions
42
client/src/store/reducers/app.ts
Normal file
42
client/src/store/reducers/app.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
import {
|
||||
GET_APPS,
|
||||
GET_APPS_SUCCESS,
|
||||
GET_APPS_ERROR
|
||||
} from '../actions/actionTypes';
|
||||
|
||||
import { App } from '../../interfaces/App';
|
||||
|
||||
interface State {
|
||||
loading: boolean;
|
||||
apps: App[];
|
||||
}
|
||||
|
||||
const initialState: State = {
|
||||
loading: true,
|
||||
apps: []
|
||||
}
|
||||
|
||||
const getApps = (state: State, action: any): State => {
|
||||
return {
|
||||
...state,
|
||||
loading: true
|
||||
}
|
||||
}
|
||||
|
||||
const getAppsSuccess = (state: State, action: any): State => {
|
||||
return {
|
||||
...state,
|
||||
loading: false,
|
||||
apps: action.payload
|
||||
}
|
||||
}
|
||||
|
||||
const appReducer = (state = initialState, action: any) => {
|
||||
switch (action.type) {
|
||||
case GET_APPS: return getApps(state, action);
|
||||
case GET_APPS_SUCCESS: return getAppsSuccess(state, action);
|
||||
default: return state;
|
||||
}
|
||||
}
|
||||
|
||||
export default appReducer;
|
|
@ -1,9 +1,11 @@
|
|||
import { combineReducers } from 'redux';
|
||||
|
||||
import themeReducer from './theme';
|
||||
import appReducer from './app';
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
theme: themeReducer
|
||||
theme: themeReducer,
|
||||
app: appReducer
|
||||
})
|
||||
|
||||
export default rootReducer;
|
Loading…
Add table
Add a link
Reference in a new issue