From 20a5ac5ec3695c40d2fe57bbcf1243b13a5fa8b9 Mon Sep 17 00:00:00 2001 From: Andrew Nicolaou Date: Mon, 9 Sep 2019 18:53:54 +0200 Subject: [PATCH] Show toast message when creating collection or adding/removing sketches --- client/modules/IDE/actions/collections.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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) => {