Skip to content

Commit

Permalink
fix(ui): refactor add and remove Related Terms tab message to showcas…
Browse files Browse the repository at this point in the history
…e actual request result
  • Loading branch information
olgadimova committed Nov 29, 2023
1 parent 4dd6738 commit d33ab31
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function AddRelatedTermsModal(props: Props) {
const [AddRelatedTerms] = useAddRelatedTermsMutation();

function addTerms() {
message.loading({ content: 'Adding...' });
AddRelatedTerms({
variables: {
input: {
Expand All @@ -43,19 +44,19 @@ function AddRelatedTermsModal(props: Props) {
},
},
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to move: \n ${e.message || ''}`, duration: 3 });
})
.finally(() => {
message.loading({ content: 'Adding...', duration: 2 });
.then(() => {
setTimeout(() => {
refetch();
message.destroy();
message.success({
content: 'Added Related Terms!',
duration: 2,
});
refetch();
}, 2000);
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to move: \n ${e.message || ''}`, duration: 3 });
});
onClose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ function useRemoveRelatedTerms(termUrn: string, relationshipType: TermRelationsh
const [removeRelatedTerms] = useRemoveRelatedTermsMutation();

function handleRemoveRelatedTerms() {
message.loading({
content: 'Removing...',
});
removeRelatedTerms({
variables: {
input: {
Expand All @@ -21,22 +24,19 @@ function useRemoveRelatedTerms(termUrn: string, relationshipType: TermRelationsh
},
},
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to remove: \n ${e.message || ''}`, duration: 3 });
})
.finally(() => {
message.loading({
content: 'Removing...',
duration: 2,
});
.then(() => {
setTimeout(() => {
refetch();
message.destroy();
message.success({
content: `Removed Glossary Term!`,
duration: 2,
});
}, 2000);
})
.catch((e) => {
message.destroy();
message.error({ content: `Failed to remove: \n ${e.message || ''}`, duration: 3 });
});
}

Expand Down

0 comments on commit d33ab31

Please sign in to comment.