Show toast message when creating collection or adding/removing sketches
This commit is contained in:
parent
55e6b3162d
commit
c575559272
1 changed files with 17 additions and 0 deletions
|
@ -1,10 +1,13 @@
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import * as ActionTypes from '../../../constants';
|
import * as ActionTypes from '../../../constants';
|
||||||
import { startLoader, stopLoader } from './loader';
|
import { startLoader, stopLoader } from './loader';
|
||||||
|
import { setToastText, showToast } from './toast';
|
||||||
|
|
||||||
const __process = (typeof global !== 'undefined' ? global : window).process;
|
const __process = (typeof global !== 'undefined' ? global : window).process;
|
||||||
const ROOT_URL = __process.env.API_URL;
|
const ROOT_URL = __process.env.API_URL;
|
||||||
|
|
||||||
|
const TOAST_DISPLAY_TIME_MS = 1500;
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
export function getCollections(username) {
|
export function getCollections(username) {
|
||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
|
@ -44,6 +47,10 @@ export function createCollection(collection) {
|
||||||
});
|
});
|
||||||
dispatch(stopLoader());
|
dispatch(stopLoader());
|
||||||
|
|
||||||
|
const collectionName = response.data.name;
|
||||||
|
dispatch(setToastText(`Created "${collectionName}"`));
|
||||||
|
dispatch(showToast(TOAST_DISPLAY_TIME_MS));
|
||||||
|
|
||||||
return response.data;
|
return response.data;
|
||||||
})
|
})
|
||||||
.catch((response) => {
|
.catch((response) => {
|
||||||
|
@ -70,6 +77,11 @@ export function addToCollection(collectionId, projectId) {
|
||||||
});
|
});
|
||||||
dispatch(stopLoader());
|
dispatch(stopLoader());
|
||||||
|
|
||||||
|
const collectionName = response.data.name;
|
||||||
|
|
||||||
|
dispatch(setToastText(`Added to "${collectionName}`));
|
||||||
|
dispatch(showToast(TOAST_DISPLAY_TIME_MS));
|
||||||
|
|
||||||
return response.data;
|
return response.data;
|
||||||
})
|
})
|
||||||
.catch((response) => {
|
.catch((response) => {
|
||||||
|
@ -96,6 +108,11 @@ export function removeFromCollection(collectionId, projectId) {
|
||||||
});
|
});
|
||||||
dispatch(stopLoader());
|
dispatch(stopLoader());
|
||||||
|
|
||||||
|
const collectionName = response.data.name;
|
||||||
|
|
||||||
|
dispatch(setToastText(`Removed from "${collectionName}`));
|
||||||
|
dispatch(showToast(TOAST_DISPLAY_TIME_MS));
|
||||||
|
|
||||||
return response.data;
|
return response.data;
|
||||||
})
|
})
|
||||||
.catch((response) => {
|
.catch((response) => {
|
||||||
|
|
Loading…
Reference in a new issue