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

@@ -1 +1,5 @@
export const SET_THEME = 'SET_THEME';
export const GET_APPS = 'GET_APPS';
export const GET_APPS_SUCCESS = 'GET_APPS_SUCCESS';
export const GET_APPS_ERROR = 'GET_APPS_ERROR';

View File

@@ -0,0 +1,25 @@
import axios from 'axios';
import { Dispatch } from 'redux';
import {
GET_APPS,
GET_APPS_SUCCESS,
GET_APPS_ERROR
} from './actionTypes';
export const getApps = () => async (dispatch: Dispatch) => {
dispatch({ type: GET_APPS });
try {
const res = await axios.get('/api/apps');
dispatch({
type: GET_APPS_SUCCESS,
payload: res.data.data
})
} catch (err) {
dispatch({
type: GET_APPS_ERROR,
payload: err.data.data
})
}
}

View File

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