mirror of
https://github.com/pawelmalak/flame.git
synced 2026-03-10 22:43:11 +08:00
Cleaned up Apps component. Delete App redux action. Apps edit mode with functionality do delete and pin apps
This commit is contained in:
@@ -2,7 +2,8 @@ import {
|
||||
GetAppsAction,
|
||||
SetTheme,
|
||||
PinAppAction,
|
||||
AddAppAction
|
||||
AddAppAction,
|
||||
DeleteAppAction
|
||||
} from './';
|
||||
|
||||
export enum ActionTypes {
|
||||
@@ -12,7 +13,8 @@ export enum ActionTypes {
|
||||
getAppsError = 'GET_APPS_ERROR',
|
||||
pinApp = 'PIN_APP',
|
||||
addApp = 'ADD_APP',
|
||||
addAppSuccess = 'ADD_APP_SUCCESS'
|
||||
addAppSuccess = 'ADD_APP_SUCCESS',
|
||||
deleteApp = 'DELETE_APP'
|
||||
}
|
||||
|
||||
export type Action = GetAppsAction<any> | SetTheme | PinAppAction | AddAppAction;
|
||||
export type Action = GetAppsAction<any> | SetTheme | PinAppAction | AddAppAction | DeleteAppAction;
|
||||
@@ -63,4 +63,22 @@ export const addApp = (formData: NewApp) => async (dispatch: Dispatch) => {
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
export interface DeleteAppAction {
|
||||
type: ActionTypes.deleteApp,
|
||||
payload: number
|
||||
}
|
||||
|
||||
export const deleteApp = (id: number) => async (dispatch: Dispatch) => {
|
||||
try {
|
||||
const res = await axios.delete<AppResponse<{}>>(`/api/apps/${id}`);
|
||||
|
||||
dispatch<DeleteAppAction>({
|
||||
type: ActionTypes.deleteApp,
|
||||
payload: id
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user