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:
parent
27250dc850
commit
e22e5afcb9
20 changed files with 297 additions and 19 deletions
|
@ -4,7 +4,7 @@ import { App } from '../../interfaces/App';
|
|||
export interface State {
|
||||
loading: boolean;
|
||||
apps: App[];
|
||||
errors: '' | undefined;
|
||||
errors: string | undefined;
|
||||
}
|
||||
|
||||
const initialState: State = {
|
||||
|
|
40
client/src/store/reducers/bookmark.ts
Normal file
40
client/src/store/reducers/bookmark.ts
Normal 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;
|
|
@ -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;
|
Loading…
Add table
Add a link
Reference in a new issue