Skip to content

Show success message on save #2257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/shared/components/Settings/Tools/Devices/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 = {
Expand Down Expand Up @@ -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
Expand All @@ -150,15 +158,15 @@ 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);
const traits = {
data: newDevices,
};
this.setState({ deviceTrait: { traits } });
addUserTrait(handle, 'device', newDevices, tokenV3);
addUserTrait(handle, 'device', newDevices, tokenV3).then(this.showSuccessToast);
}
const empty = {
deviceType: '',
Expand Down
12 changes: 10 additions & 2 deletions src/shared/components/Settings/Tools/ServiceProviders/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 = {
Expand Down Expand Up @@ -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
Expand All @@ -169,15 +177,15 @@ 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);
const traits = {
data: newServiceProviders,
};
this.setState({ serviceProviderTrait: { traits } });
addUserTrait(handle, 'service_provider', newServiceProviders, tokenV3);
addUserTrait(handle, 'service_provider', newServiceProviders, tokenV3).then(this.showSuccessToast);
}
const empty = {
serviceProviderType: '',
Expand Down
12 changes: 10 additions & 2 deletions src/shared/components/Settings/Tools/Software/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 = {
Expand Down Expand Up @@ -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
Expand All @@ -170,15 +178,15 @@ 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);
const traits = {
data: newSoftwares,
};
this.setState({ softwareTrait: { traits } });
addUserTrait(handle, 'software', newSoftwares, tokenV3);
addUserTrait(handle, 'software', newSoftwares, tokenV3).then(this.showSuccessToast);
}
const empty = {
softwareType: '',
Expand Down
12 changes: 10 additions & 2 deletions src/shared/components/Settings/Tools/Subscriptions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -159,15 +167,15 @@ 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);
const traits = {
data: newSubscriptions,
};
this.setState({ subscriptionTrait: { traits } });
addUserTrait(handle, 'subscription', newSubscriptions, tokenV3);
addUserTrait(handle, 'subscription', newSubscriptions, tokenV3).then(this.showSuccessToast);
}
const empty = {
name: '',
Expand Down
4 changes: 2 additions & 2 deletions src/shared/containers/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ 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());
dispatch(actions.profile.addSkillDone(handle, tokenV3, _.assign(skill, { tagId: skill.id })));
},
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());
Expand Down