diff --git a/src/shared/components/Settings/Tools/Devices/index.jsx b/src/shared/components/Settings/Tools/Devices/index.jsx index 34035b5b4e..021a27bdb6 100644 --- a/src/shared/components/Settings/Tools/Devices/index.jsx +++ b/src/shared/components/Settings/Tools/Devices/index.jsx @@ -12,6 +12,7 @@ import PT from 'prop-types'; import ConsentComponent from 'components/Settings/ConsentComponent'; import Select from 'components/Select'; import { PrimaryButton } from 'topcoder-react-ui-kit'; +import { toastr } from 'react-redux-toastr'; import ConfirmationModal from '../../CofirmationModal'; import dropdowns from './dropdowns.json'; import DeviceList from './List'; @@ -30,6 +31,7 @@ export default class Devices extends ConsentComponent { this.onAddDevice = this.onAddDevice.bind(this); this.loadPersonalizationTrait = this.loadPersonalizationTrait.bind(this); this.updatePredicate = this.updatePredicate.bind(this); + this.showSuccessToast = this.showSuccessToast.bind(this); const { userTraits } = props; this.state = { @@ -130,6 +132,12 @@ export default class Devices extends ConsentComponent { }); } + showSuccessToast = () => { + setImmediate(() => { + toastr.success('Success!', 'Your information has been updated.'); + }); + } + /** * Add new device * @param answer user consent answer value @@ -150,7 +158,7 @@ export default class Devices extends ConsentComponent { const newDeviceTrait = { ...deviceTrait }; newDeviceTrait.traits.data.push(newDevice); this.setState({ deviceTrait: newDeviceTrait }); - updateUserTrait(handle, 'device', newDeviceTrait.traits.data, tokenV3); + updateUserTrait(handle, 'device', newDeviceTrait.traits.data, tokenV3).then(this.showSuccessToast); } else { const newDevices = []; newDevices.push(newDevice); @@ -158,7 +166,7 @@ export default class Devices extends ConsentComponent { data: newDevices, }; this.setState({ deviceTrait: { traits } }); - addUserTrait(handle, 'device', newDevices, tokenV3); + addUserTrait(handle, 'device', newDevices, tokenV3).then(this.showSuccessToast); } const empty = { deviceType: '', diff --git a/src/shared/components/Settings/Tools/ServiceProviders/index.jsx b/src/shared/components/Settings/Tools/ServiceProviders/index.jsx index e9bf29baab..ce54a8c62f 100644 --- a/src/shared/components/Settings/Tools/ServiceProviders/index.jsx +++ b/src/shared/components/Settings/Tools/ServiceProviders/index.jsx @@ -12,6 +12,7 @@ import _ from 'lodash'; import ConsentComponent from 'components/Settings/ConsentComponent'; import Select from 'components/Select'; import { PrimaryButton } from 'topcoder-react-ui-kit'; +import { toastr } from 'react-redux-toastr'; import ConfirmationModal from '../../CofirmationModal'; import dropdowns from './dropdowns.json'; import ServiceProviderList from './List'; @@ -30,6 +31,7 @@ export default class ServiceProviders extends ConsentComponent { this.onAddServiceProvider = this.onAddServiceProvider.bind(this); this.loadPersonalizationTrait = this.loadPersonalizationTrait.bind(this); this.updatePredicate = this.updatePredicate.bind(this); + this.showSuccessToast = this.showSuccessToast.bind(this); const { userTraits } = props; this.state = { @@ -151,6 +153,12 @@ export default class ServiceProviders extends ConsentComponent { }); } + showSuccessToast = () => { + setImmediate(() => { + toastr.success('Success!', 'Your information has been updated.'); + }); + } + /** * Add new serviceProvider * @param answer user consent answer value @@ -169,7 +177,7 @@ export default class ServiceProviders extends ConsentComponent { const newServiceProviderTrait = { ...serviceProviderTrait }; newServiceProviderTrait.traits.data.push(newServiceProvider); this.setState({ serviceProviderTrait: newServiceProviderTrait }); - updateUserTrait(handle, 'service_provider', newServiceProviderTrait.traits.data, tokenV3); + updateUserTrait(handle, 'service_provider', newServiceProviderTrait.traits.data, tokenV3).then(this.showSuccessToast); } else { const newServiceProviders = []; newServiceProviders.push(newServiceProvider); @@ -177,7 +185,7 @@ export default class ServiceProviders extends ConsentComponent { data: newServiceProviders, }; this.setState({ serviceProviderTrait: { traits } }); - addUserTrait(handle, 'service_provider', newServiceProviders, tokenV3); + addUserTrait(handle, 'service_provider', newServiceProviders, tokenV3).then(this.showSuccessToast); } const empty = { serviceProviderType: '', diff --git a/src/shared/components/Settings/Tools/Software/index.jsx b/src/shared/components/Settings/Tools/Software/index.jsx index c0a63f0459..74ddf87e28 100644 --- a/src/shared/components/Settings/Tools/Software/index.jsx +++ b/src/shared/components/Settings/Tools/Software/index.jsx @@ -12,6 +12,7 @@ import _ from 'lodash'; import ConsentComponent from 'components/Settings/ConsentComponent'; import Select from 'components/Select'; import { PrimaryButton } from 'topcoder-react-ui-kit'; +import { toastr } from 'react-redux-toastr'; import ConfirmationModal from '../../CofirmationModal'; import dropdowns from './dropdowns.json'; import SoftwareList from './List'; @@ -31,6 +32,7 @@ export default class Software extends ConsentComponent { this.onAddSoftware = this.onAddSoftware.bind(this); this.loadPersonalizationTrait = this.loadPersonalizationTrait.bind(this); this.updatePredicate = this.updatePredicate.bind(this); + this.showSuccessToast = this.showSuccessToast.bind(this); const { userTraits } = props; this.state = { @@ -152,6 +154,12 @@ export default class Software extends ConsentComponent { }); } + showSuccessToast = () => { + setImmediate(() => { + toastr.success('Success!', 'Your information has been updated.'); + }); + } + /** * Add new software * @param answer user consent answer value @@ -170,7 +178,7 @@ export default class Software extends ConsentComponent { const newSoftwareTrait = { ...softwareTrait }; newSoftwareTrait.traits.data.push(newSoftware); this.setState({ softwareTrait: newSoftwareTrait }); - updateUserTrait(handle, 'software', newSoftwareTrait.traits.data, tokenV3); + updateUserTrait(handle, 'software', newSoftwareTrait.traits.data, tokenV3).then(this.showSuccessToast); } else { const newSoftwares = []; newSoftwares.push(newSoftware); @@ -178,7 +186,7 @@ export default class Software extends ConsentComponent { data: newSoftwares, }; this.setState({ softwareTrait: { traits } }); - addUserTrait(handle, 'software', newSoftwares, tokenV3); + addUserTrait(handle, 'software', newSoftwares, tokenV3).then(this.showSuccessToast); } const empty = { softwareType: '', diff --git a/src/shared/components/Settings/Tools/Subscriptions/index.jsx b/src/shared/components/Settings/Tools/Subscriptions/index.jsx index 027ad6d516..8c04fb10d6 100644 --- a/src/shared/components/Settings/Tools/Subscriptions/index.jsx +++ b/src/shared/components/Settings/Tools/Subscriptions/index.jsx @@ -11,6 +11,7 @@ import PT from 'prop-types'; import _ from 'lodash'; import ConsentComponent from 'components/Settings/ConsentComponent'; import { PrimaryButton } from 'topcoder-react-ui-kit'; +import { toastr } from 'react-redux-toastr'; import ConfirmationModal from '../../CofirmationModal'; import SubscriptionList from './List'; @@ -29,6 +30,7 @@ export default class Subscription extends ConsentComponent { this.onAddSubscription = this.onAddSubscription.bind(this); this.loadPersonalizationTrait = this.loadPersonalizationTrait.bind(this); this.updatePredicate = this.updatePredicate.bind(this); + this.showSuccessToast = this.showSuccessToast.bind(this); const { userTraits } = props; this.state = { formInvalid: false, @@ -141,6 +143,12 @@ export default class Subscription extends ConsentComponent { }); } + showSuccessToast = () => { + setImmediate(() => { + toastr.success('Success!', 'Your information has been updated.'); + }); + } + /** * Add new subscription * @param answer user consent answer value @@ -159,7 +167,7 @@ export default class Subscription extends ConsentComponent { const newSubscriptionTrait = { ...subscriptionTrait }; newSubscriptionTrait.traits.data.push(newSubscription); this.setState({ subscriptionTrait: newSubscriptionTrait }); - updateUserTrait(handle, 'subscription', newSubscriptionTrait.traits.data, tokenV3); + updateUserTrait(handle, 'subscription', newSubscriptionTrait.traits.data, tokenV3).then(this.showSuccessToast); } else { const newSubscriptions = []; newSubscriptions.push(newSubscription); @@ -167,7 +175,7 @@ export default class Subscription extends ConsentComponent { data: newSubscriptions, }; this.setState({ subscriptionTrait: { traits } }); - addUserTrait(handle, 'subscription', newSubscriptions, tokenV3); + addUserTrait(handle, 'subscription', newSubscriptions, tokenV3).then(this.showSuccessToast); } const empty = { name: '', diff --git a/src/shared/containers/Settings.jsx b/src/shared/containers/Settings.jsx index 09928a8fd5..064cdd1384 100644 --- a/src/shared/containers/Settings.jsx +++ b/src/shared/containers/Settings.jsx @@ -220,7 +220,7 @@ function mapDispatchToProps(dispatch) { }, addUserTrait: (handle, traitId, data, tokenV3) => { dispatch(actions.settings.modifyUserTraitInit()); - dispatch(actions.settings.addUserTrait(handle, traitId, data, tokenV3)); + return dispatch(actions.settings.addUserTrait(handle, traitId, data, tokenV3)); }, addUserSkill: (handle, skill, tokenV3) => { dispatch(actions.profile.addSkillInit()); @@ -228,7 +228,7 @@ function mapDispatchToProps(dispatch) { }, updateUserTrait: (handle, traitId, data, tokenV3) => { dispatch(actions.settings.modifyUserTraitInit()); - dispatch(actions.settings.updateUserTrait(handle, traitId, data, tokenV3)); + return dispatch(actions.settings.updateUserTrait(handle, traitId, data, tokenV3)); }, deleteUserTrait: (handle, traitId, tokenV3) => { dispatch(actions.settings.modifyUserTraitInit());