1
0
Fork 0
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:
unknown 2021-05-10 19:02:16 +02:00
parent 2acc3b72ec
commit 78acede8ab
15 changed files with 230 additions and 27 deletions

View 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;

View file

@ -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;