Skip to content
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

Change all messages antd for mui #1694

Merged
merged 4 commits into from
Jan 14, 2025
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
3 changes: 2 additions & 1 deletion public/locales/en/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"sourceCardButton": "Access the source",
"sourceCreateCTAButton": "Create source",
"sourcesCreateSuccess": "Source created successfully",
"sourcesCreateError": "Error while creating the source"
"sourcesCreateError": "Error while creating the source",
"sourcesErrorFetching": "Error fetching source"
}
3 changes: 2 additions & 1 deletion public/locales/pt/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"sourceCardButton": "Acesse a fonte",
"sourceCreateCTAButton": "Incluir fonte",
"sourcesCreateSuccess": "Fonte criado com sucesso",
"sourcesCreateError": "Erro ao criar a fonte"
"sourcesCreateError": "Erro ao criar a fonte",
"sourcesErrorFetching": "Erro ao buscar a fonte"
}
12 changes: 6 additions & 6 deletions src/api/badgesApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from "axios";
import { message } from "antd";
import { MessageManager } from "../components/Messages";

const request = axios.create({
withCredentials: true,
Expand All @@ -10,11 +10,11 @@ const createBadge = (badge, users, t) => {
return request
.post(`/`, { ...badge, users })
.then((response) => {
message.success(t("badges:badgeSaved"));
MessageManager.showMessage("success", `${t("badges:badgeSaved")}`);
return response.data;
})
.catch((err) => {
message.error(err.response.data?.message);
MessageManager.showMessage("error", err.response.data?.message);
throw err;
});
};
Expand All @@ -23,11 +23,11 @@ const updateBadge = (badge, users, t) => {
return request
.put(`/${badge._id}`, { ...badge, users })
.then((response) => {
message.success(t("badges:badgeSaved"));
MessageManager.showMessage("success", `${t("badges:badgeSaved")}`);
return response.data;
})
.catch((err) => {
message.error(err.response.data?.message);
MessageManager.showMessage("error", err.response.data?.message);
throw err;
});
};
Expand All @@ -39,7 +39,7 @@ const getBadges = () => {
return response.data;
})
.catch((err) => {
message.error(err.response.data?.message);
MessageManager.showMessage("error", err.response.data?.message);
throw err;
});
};
Expand Down
26 changes: 13 additions & 13 deletions src/api/claim.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from "axios";
import { message } from "antd";
import { MessageManager } from "../components/Messages";
import { NameSpaceEnum } from "../types/Namespace";

const request = axios.create({
Expand Down Expand Up @@ -53,7 +53,7 @@ const getById = (id, t, params = {}) => {
return response.data;
})
.catch(() => {
message.error(t("claim:errorWhileFetching"));
MessageManager.showMessage("error", `${t("claim:errorWhileFetching")}`)
});
};

Expand All @@ -62,7 +62,7 @@ const saveSpeech = (t, claim = {}) => {
.post("/", claim)
.then((response) => {
const { title } = response.data;
message.success(
MessageManager.showMessage("success",
`"${title}" ${t("claimForm:successCreateMessage")}`
);
return response.data;
Expand All @@ -73,7 +73,7 @@ const saveSpeech = (t, claim = {}) => {
// TODO: Track errors with Sentry
}
const { data } = response;
message.error(
MessageManager.showMessage("error",
data && data.message
? data.message
: t("claimForm:errorCreateMessage")
Expand All @@ -86,14 +86,14 @@ const saveImage = (t, claimImage = {}) => {
.post("/image", claimImage)
.then((response) => {
const { title } = response.data;
message.success(
MessageManager.showMessage("success",
`"${title}" ${t("claimForm:successCreateMessage")}`
);
return response.data;
})
.catch((err) => {
const response = err && err.response;
message.error(
MessageManager.showMessage("error",
response?.data && response?.data.message
? response?.data.message
: t("claimForm:errorCreateMessage")
Expand All @@ -106,7 +106,7 @@ const saveDebate = (t, debate = {}) => {
.post("/debate", debate)
.then((response) => {
const { title } = response.data;
message.success(
MessageManager.showMessage("success",
`"${title}" ${t("claimForm:successCreateMessage")}`
);
return response.data;
Expand All @@ -125,7 +125,7 @@ const saveUnattributed = (t, unattributed = {}) => {
.post("/unattributed", unattributed)
.then((response) => {
const { title } = response.data;
message.success(
MessageManager.showMessage("success",
`"${title}" ${t("claimForm:successCreateMessage")}`
);
return response.data;
Expand Down Expand Up @@ -155,7 +155,7 @@ const updateDebate = (
// TODO: Track errors with Sentry
}
const { data } = response;
message.error(
MessageManager.showMessage("error",
data && data.message
? data.message
: t("claimForm:errorUpdateMessage")
Expand All @@ -167,11 +167,11 @@ const deleteClaim = (id: string, t: any) => {
return request
.delete(`/${id}`)
.then(() => {
message.success(t("claim:deleteSuccess"));
MessageManager.showMessage("success", t("claim:deleteSuccess"));
})
.catch((err) => {
console.error(err);
message.error(t("claim:deleteError"));
MessageManager.showMessage("error", t("claim:deleteError"));
});
};

Expand All @@ -189,13 +189,13 @@ const updateClaimHiddenStatus = (
description,
})
.then(() => {
message.success(
MessageManager.showMessage("success",
t(`claim:${isHidden ? "hideSuccess" : "unhideSuccess"}`)
);
})
.catch((err) => {
console.error(err);
message.error(t(`claim:${isHidden ? "hideError" : "unhideError"}`));
MessageManager.showMessage("error", t(`claim:${isHidden ? "hideError" : "unhideError"}`));
});
};

Expand Down
10 changes: 5 additions & 5 deletions src/api/claimReviewApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { message } from "antd";
import { MessageManager } from "../components/Messages";
import axios from "axios";
import { NameSpaceEnum } from "../types/Namespace";

Expand Down Expand Up @@ -50,13 +50,13 @@ const updateClaimReviewHiddenStatus = (
return request
.put(`/review/${id}`, { isHidden, description, recaptcha })
.then((response) => {
message.success(
MessageManager.showMessage("success",
t(`claimReview:${isHidden ? "hideSuccess" : "unhideSuccess"}`)
);
return response.data;
})
.catch((err) => {
message.error(
MessageManager.showMessage("error",
t(`claimReview:${isHidden ? "hideError" : "unhideError"}`)
);
throw err;
Expand All @@ -67,11 +67,11 @@ const deleteClaimReview = (id: string, t: any) => {
return request
.delete(`/review/${id}`)
.then(() => {
message.success(t("claim:deleteSuccess"));
MessageManager.showMessage("success", t("claim:deleteSuccess"));
})
.catch((err) => {
console.error(err);
message.error(t("claim:deleteError"));
MessageManager.showMessage("error",t("claim:deleteError"));
});
};

Expand Down
12 changes: 6 additions & 6 deletions src/api/comment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from "axios";
import { message } from "antd";
import { MessageManager } from "../components/Messages";

const request = axios.create({
withCredentials: true,
Expand All @@ -13,7 +13,7 @@ const createComment = (comment) => {
return response.data;
})
.catch((err) => {
message.error(err.response.data?.message);
MessageManager.showMessage("error", err.response.data?.message);
throw err;
});
};
Expand All @@ -25,7 +25,7 @@ const updateComments = (comments) => {
return response.data;
})
.catch((err) => {
message.error(err.response.data?.message);
MessageManager.showMessage("error", err.response.data?.message);
throw err;
});
};
Expand All @@ -37,7 +37,7 @@ const updateComment = (commentId, comment) => {
return response.data;
})
.catch((err) => {
message.error(err.response.data?.message);
MessageManager.showMessage("error", err.response.data?.message);
throw err;
});
};
Expand All @@ -49,7 +49,7 @@ const createReplyComment = (commentId, newComment) => {
return response.data;
})
.catch((err) => {
message.error(err.response.data?.message);
MessageManager.showMessage("error", err.response.data?.message);
throw err;
});
};
Expand All @@ -61,7 +61,7 @@ const deleteReplyComment = (commentId, replyCommentId) => {
return response.data;
})
.catch((err) => {
message.error(err.response.data?.message);
MessageManager.showMessage("error", err.response.data?.message);
throw err;
});
};
Expand Down
6 changes: 3 additions & 3 deletions src/api/dailyReport.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { message } from "antd";
import { MessageManager } from "../components/Messages";
import axios from "axios";

const request = axios.create({
Expand All @@ -10,11 +10,11 @@ const sendDailyReportEmail = (topic, nameSpace, t) => {
return request
.post(`/topic/${topic}/send/${nameSpace}`)
.then((response) => {
message.success(t("notification:sendDailyReportSuccess"));
MessageManager.showMessage("success", t("notification:sendDailyReportSuccess"));
return response.data;
})
.catch((err) => {
message.error(t("notification:sendDailyReportError"));
MessageManager.showMessage("error",t("notification:sendDailyReportError"));
throw err;
});
};
Expand Down
4 changes: 2 additions & 2 deletions src/api/editor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from "axios";
import { message } from "antd";
import { MessageManager } from "../components/Messages";

const request = axios.create({
withCredentials: true,
Expand All @@ -13,7 +13,7 @@ const update = (reference, editorContentObject, t) => {
return response;
})
.catch((err) => {
message.error(t(`claim:${err.response.data?.message}`));
MessageManager.showMessage("error", t(`claim:${err.response.data?.message}`));
throw err;
});
};
Expand Down
8 changes: 4 additions & 4 deletions src/api/image.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from "axios";
import { message } from "antd";
import { MessageManager } from "../components/Messages";

const request = axios.create({
withCredentials: true,
Expand All @@ -24,7 +24,7 @@ const uploadImage = (files, t) => {
return response.data;
})
.catch((err) => {
message.error(t(`claim:${err.response.data.message}`));
MessageManager.showMessage("error", t(`claim:${err.response.data.message}`));
throw err;
});
};
Expand All @@ -33,11 +33,11 @@ const createClaimTypeImage = (file) => {
return request
.post("/create", file)
.then((response) => {
message.success("upload success");
MessageManager.showMessage("success", "upload success");
return response.data;
})
.catch((err) => {
message.error("upload failed");
MessageManager.showMessage("error", "upload failed");
throw err;
});
};
Expand Down
12 changes: 6 additions & 6 deletions src/api/namespace.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from "axios";
import { message } from "antd";
import { MessageManager } from "../components/Messages";

const request = axios.create({
withCredentials: true,
Expand All @@ -10,11 +10,11 @@ const createNameSpace = (nameSpace, t) => {
return request
.post(`/`, { ...nameSpace })
.then((response) => {
message.success(t("namespaces:nameSpaceSaved"));
MessageManager.showMessage("success", t("namespaces:nameSpaceSaved"));
return response.data;
})
.catch((err) => {
message.error(err.response.data?.message);
MessageManager.showMessage("error", err.response.data?.message);
throw err;
});
};
Expand All @@ -23,11 +23,11 @@ const updateNameSpace = (nameSpace, t) => {
return request
.put(`/${nameSpace._id}`, { ...nameSpace })
.then((response) => {
message.success(t("namespaces:nameSpaceSaved"));
MessageManager.showMessage("success", t("namespaces:nameSpaceSaved"));
return response.data;
})
.catch((err) => {
message.error(err.response.data?.message);
MessageManager.showMessage("error", err.response.data?.message);
throw err;
});
};
Expand All @@ -39,7 +39,7 @@ const getNameSpaces = () => {
return response.data;
})
.catch((err) => {
message.error(err.response.data?.message);
MessageManager.showMessage("error", err.response.data?.message);
throw err;
});
};
Expand Down
Loading
Loading