diff --git a/client/src/store/action-creators/app.ts b/client/src/store/action-creators/app.ts index 6f1b505..f84bfbd 100644 --- a/client/src/store/action-creators/app.ts +++ b/client/src/store/action-creators/app.ts @@ -11,7 +11,6 @@ import { UpdateAppAction, } from '../actions/app'; import axios from 'axios'; -import { createNotification } from '.'; export const getApps = () => async (dispatch: Dispatch>) => { @@ -44,9 +43,12 @@ export const pinApp = ? 'unpinned from Homescreen' : 'pinned to Homescreen'; - createNotification({ - title: 'Success', - message: `App ${name} ${status}`, + dispatch({ + type: ActionType.createNotification, + payload: { + title: 'Success', + message: `App ${name} ${status}`, + }, }); dispatch({ @@ -63,9 +65,12 @@ export const addApp = try { const res = await axios.post>('/api/apps', formData); - createNotification({ - title: 'Success', - message: `App added`, + dispatch({ + type: ActionType.createNotification, + payload: { + title: 'Success', + message: `App added`, + }, }); await dispatch({ @@ -74,8 +79,7 @@ export const addApp = }); // Sort apps - // dispatch(sortApps()); - sortApps(); + dispatch(sortApps()); } catch (err) { console.log(err); } @@ -86,9 +90,12 @@ export const deleteApp = try { await axios.delete>(`/api/apps/${id}`); - createNotification({ - title: 'Success', - message: 'App deleted', + dispatch({ + type: ActionType.createNotification, + payload: { + title: 'Success', + message: 'App deleted', + }, }); dispatch({ @@ -109,9 +116,12 @@ export const updateApp = formData ); - createNotification({ - title: 'Success', - message: `App updated`, + dispatch({ + type: ActionType.createNotification, + payload: { + title: 'Success', + message: `App updated`, + }, }); await dispatch({ diff --git a/client/src/store/action-creators/bookmark.ts b/client/src/store/action-creators/bookmark.ts index ac7c420..c299ec6 100644 --- a/client/src/store/action-creators/bookmark.ts +++ b/client/src/store/action-creators/bookmark.ts @@ -1,6 +1,5 @@ import axios from 'axios'; import { Dispatch } from 'redux'; -import { createNotification } from '.'; import { ApiResponse, Bookmark, @@ -51,9 +50,12 @@ export const addCategory = formData ); - createNotification({ - title: 'Success', - message: `Category ${formData.name} created`, + dispatch({ + type: ActionType.createNotification, + payload: { + title: 'Success', + message: `Category ${formData.name} created`, + }, }); dispatch({ @@ -61,8 +63,7 @@ export const addCategory = payload: res.data.data, }); - // dispatch(sortCategories()); - sortCategories(); + dispatch(sortCategories()); } catch (err) { console.log(err); } @@ -77,9 +78,12 @@ export const addBookmark = formData ); - createNotification({ - title: 'Success', - message: `Bookmark created`, + dispatch({ + type: ActionType.createNotification, + payload: { + title: 'Success', + message: `Bookmark created`, + }, }); dispatch({ @@ -104,9 +108,12 @@ export const pinCategory = ? 'unpinned from Homescreen' : 'pinned to Homescreen'; - createNotification({ - title: 'Success', - message: `Category ${name} ${status}`, + dispatch({ + type: ActionType.createNotification, + payload: { + title: 'Success', + message: `Category ${name} ${status}`, + }, }); dispatch({ @@ -123,9 +130,12 @@ export const deleteCategory = try { await axios.delete>(`/api/categories/${id}`); - createNotification({ - title: 'Success', - message: `Category deleted`, + dispatch({ + type: ActionType.createNotification, + payload: { + title: 'Success', + message: `Category deleted`, + }, }); dispatch({ @@ -145,9 +155,13 @@ export const updateCategory = `/api/categories/${id}`, formData ); - createNotification({ - title: 'Success', - message: `Category ${formData.name} updated`, + + dispatch({ + type: ActionType.createNotification, + payload: { + title: 'Success', + message: `Category ${formData.name} updated`, + }, }); dispatch({ @@ -155,8 +169,7 @@ export const updateCategory = payload: res.data.data, }); - // dispatch(sortCategories()); - sortCategories(); + dispatch(sortCategories()); } catch (err) { console.log(err); } @@ -168,9 +181,12 @@ export const deleteBookmark = try { await axios.delete>(`/api/bookmarks/${bookmarkId}`); - createNotification({ - title: 'Success', - message: 'Bookmark deleted', + dispatch({ + type: ActionType.createNotification, + payload: { + title: 'Success', + message: 'Bookmark deleted', + }, }); dispatch({ @@ -205,9 +221,12 @@ export const updateBookmark = formData ); - createNotification({ - title: 'Success', - message: `Bookmark updated`, + dispatch({ + type: ActionType.createNotification, + payload: { + title: 'Success', + message: `Bookmark updated`, + }, }); // Check if category was changed diff --git a/client/src/store/action-creators/config.ts b/client/src/store/action-creators/config.ts index 6bbde52..67eeac2 100644 --- a/client/src/store/action-creators/config.ts +++ b/client/src/store/action-creators/config.ts @@ -18,7 +18,6 @@ import { } from '../../interfaces'; import { ActionType } from '../action-types'; import { storeUIConfig } from '../../utility'; -import { createNotification } from '.'; export const getConfig = () => async (dispatch: Dispatch) => { try { @@ -53,9 +52,12 @@ export const updateConfig = try { const res = await axios.put>('/api/config', formData); - createNotification({ - title: 'Success', - message: 'Settings updated', + dispatch({ + type: ActionType.createNotification, + payload: { + title: 'Success', + message: 'Settings updated', + }, }); dispatch({