Skip to content

Commit

Permalink
Merge pull request #1392 from AletheiaFact/issues1328-AddMessageFeedback
Browse files Browse the repository at this point in the history
issues1328-AddMessageFeedback
  • Loading branch information
pepermao authored Oct 14, 2024
2 parents 4c483c3 + 9a4b30b commit 1597f85
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
4 changes: 3 additions & 1 deletion public/locales/en/topics.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"getTopicsFailed": "Error while fetching topics",
"addTopicsButton": "Add topics",
"inputRule": "Required field",
"noTopics": "No topics added"
"noTopics": "No topics added",
"deleteTopics": "Topic deleted successfully",
"deleteTopicsError": "Error when deleting topic"
}
4 changes: 3 additions & 1 deletion public/locales/pt/topics.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"getTopicsFailed": "Erro ao buscar tópicos",
"addTopicsButton": "Adicionar tópicos",
"inputRule": "Campo obrigatório",
"noTopics": "Tópicos não adicionados"
"noTopics": "Tópicos não adicionados",
"deleteTopics": "Tópico deletado com sucesso",
"deleteTopicsError": "Erro ao deletar tópico"
}
5 changes: 4 additions & 1 deletion src/api/sentenceApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios from "axios";
import { message } from "antd";

const request = axios.create({
withCredentials: true,
Expand All @@ -16,13 +17,15 @@ const getSentenceTopicsByDatahash = (data_hash) => {
});
};

const deleteSentenceTopic = (topics, data_hash) => {
const deleteSentenceTopic = (topics, data_hash, t) => {
return request
.put(`/${data_hash}`, topics)
.then((response) => {
message.success(t("topics:deleteTopics"));
return response.data;
})
.catch((err) => {
message.error(t("topics:deleteTopicsError"));
throw err;
});
};
Expand Down
4 changes: 3 additions & 1 deletion src/api/verificationRequestApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ const removeVerificationRequestFromGroup = (id, params, t) => {
});
};

const deleteVerificationRequestTopic = (topics, data_hash) => {
const deleteVerificationRequestTopic = (topics, data_hash, t) => {
return request
.put(`/${data_hash}/topics`, topics)
.then((response) => {
message.success(t("topics:deleteTopics"));
return response.data;
})
.catch((err) => {
message.error(t("topics:deleteTopicsError"));
throw err;
});
};
Expand Down
5 changes: 3 additions & 2 deletions src/components/topics/TopicDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,14 @@ const TopicDisplay = ({
if (reviewTaskType === ReviewTaskTypeEnum.VerificationRequest) {
return await verificationRequestApi.deleteVerificationRequestTopic(
newTopicsArray,
data_hash
data_hash,
t
);
}

return contentModel === ContentModelEnum.Image
? await ImageApi.deleteImageTopic(newTopicsArray, data_hash)
: await SentenceApi.deleteSentenceTopic(newTopicsArray, data_hash);
: await SentenceApi.deleteSentenceTopic(newTopicsArray, data_hash, t);
};

return (
Expand Down

0 comments on commit 1597f85

Please sign in to comment.