diff --git a/client/modules/IDE/actions/collections.js b/client/modules/IDE/actions/collections.js index 17f0b872..df05f2f7 100644 --- a/client/modules/IDE/actions/collections.js +++ b/client/modules/IDE/actions/collections.js @@ -1,10 +1,13 @@ import axios from 'axios'; import * as ActionTypes from '../../../constants'; import { startLoader, stopLoader } from './loader'; +import { setToastText, showToast } from './toast'; const __process = (typeof global !== 'undefined' ? global : window).process; const ROOT_URL = __process.env.API_URL; +const TOAST_DISPLAY_TIME_MS = 1500; + // eslint-disable-next-line export function getCollections(username) { return (dispatch) => { @@ -44,6 +47,10 @@ export function createCollection(collection) { }); dispatch(stopLoader()); + const collectionName = response.data.name; + dispatch(setToastText(`Created "${collectionName}"`)); + dispatch(showToast(TOAST_DISPLAY_TIME_MS)); + return response.data; }) .catch((response) => { @@ -70,6 +77,11 @@ export function addToCollection(collectionId, projectId) { }); dispatch(stopLoader()); + const collectionName = response.data.name; + + dispatch(setToastText(`Added to "${collectionName}`)); + dispatch(showToast(TOAST_DISPLAY_TIME_MS)); + return response.data; }) .catch((response) => { @@ -96,6 +108,11 @@ export function removeFromCollection(collectionId, projectId) { }); dispatch(stopLoader()); + const collectionName = response.data.name; + + dispatch(setToastText(`Removed from "${collectionName}`)); + dispatch(showToast(TOAST_DISPLAY_TIME_MS)); + return response.data; }) .catch((response) => {