mirror of
https://github.com/pawelmalak/flame.git
synced 2026-03-11 06:53:12 +08:00
Apps actions and reducer
This commit is contained in:
@@ -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';
|
||||
25
client/src/store/actions/app.ts
Normal file
25
client/src/store/actions/app.ts
Normal 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
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from './theme';
|
||||
export * from './app';
|
||||
export * from './actionTypes';
|
||||
Reference in New Issue
Block a user