1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-08-07 11:55:17 +02:00

Bookmarks view with grid + redux actions

This commit is contained in:
unknown 2021-05-23 18:38:39 +02:00
parent 27250dc850
commit e22e5afcb9
20 changed files with 297 additions and 19 deletions

View file

@ -4,7 +4,7 @@ import { App } from '../../interfaces/App';
export interface State {
loading: boolean;
apps: App[];
errors: '' | undefined;
errors: string | undefined;
}
const initialState: State = {

View file

@ -0,0 +1,40 @@
import { ActionTypes, Action } from '../actions';
import { Category, Bookmark } from '../../interfaces';
export interface State {
loading: boolean;
errors: string | undefined;
categories: Category[];
}
const initialState: State = {
loading: true,
errors: undefined,
categories: []
}
const getCategories = (state: State, action: Action): State => {
return {
...state,
loading: true,
errors: undefined
}
}
const getCategoriesSuccess = (state: State, action: Action): State => {
return {
...state,
loading: false,
categories: action.payload
}
}
const bookmarkReducer = (state = initialState, action: Action) => {
switch (action.type) {
case ActionTypes.getCategories: return getCategories(state, action);
case ActionTypes.getCategoriesSuccess: return getCategoriesSuccess(state, action);
default: return state;
}
}
export default bookmarkReducer;

View file

@ -4,10 +4,12 @@ import { GlobalState } from '../../interfaces/GlobalState';
import themeReducer from './theme';
import appReducer from './app';
import bookmarkReducer from './bookmark';
const rootReducer = combineReducers<GlobalState>({
theme: themeReducer,
app: appReducer
app: appReducer,
bookmark: bookmarkReducer
})
export default rootReducer;