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,8 @@ import {
PinAppAction,
AddAppAction,
DeleteAppAction,
UpdateAppAction
UpdateAppAction,
GetCategoriesAction
} from './';
export enum ActionTypes {
@@ -16,7 +17,10 @@ export enum ActionTypes {
addApp = 'ADD_APP',
addAppSuccess = 'ADD_APP_SUCCESS',
deleteApp = 'DELETE_APP',
updateApp = 'UPDATE_APP'
updateApp = 'UPDATE_APP',
getCategories = 'GET_CATEGORIES',
getCategoriesSuccess = 'GET_CATEGORIES_SUCCESS',
getCategoriesError = 'GET_CATEGORIES_ERROR'
}
export type Action = GetAppsAction<any> | SetThemeAction | PinAppAction | AddAppAction | DeleteAppAction | UpdateAppAction;
export type Action = GetAppsAction<any> | SetThemeAction | PinAppAction | AddAppAction | DeleteAppAction | UpdateAppAction | GetCategoriesAction<any>;

View File

@@ -0,0 +1,27 @@
import axios from 'axios';
import { Dispatch } from 'redux';
import { ActionTypes } from './actionTypes';
import { Category, ApiResponse } from '../../interfaces';
export interface GetCategoriesAction<T> {
type: ActionTypes.getCategories | ActionTypes.getCategoriesSuccess | ActionTypes.getCategoriesError;
payload: T;
}
export const getCategories = () => async (dispatch: Dispatch) => {
dispatch<GetCategoriesAction<undefined>>({
type: ActionTypes.getCategories,
payload: undefined
})
try {
const res = await axios.get<ApiResponse<Category[]>>('/api/categories');
dispatch<GetCategoriesAction<Category[]>>({
type: ActionTypes.getCategoriesSuccess,
payload: res.data.data
})
} catch (err) {
console.log(err);
}
}

View File

@@ -1,3 +1,4 @@
export * from './theme';
export * from './app';
export * from './actionTypes';
export * from './actionTypes';
export * from './bookmark';