mirror of
https://framagit.org/framasoft/mobilizon.git
synced 2024-12-22 07:52:43 +00:00
fix(front): correctly show error message when a tag is too short
Closes #1382 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
6a482b0d97
commit
cba2075431
3 changed files with 26 additions and 5 deletions
|
@ -1643,5 +1643,6 @@
|
|||
"Software details: {software_details}": "Software details: {software_details}",
|
||||
"Only instances with an application actor can be followed": "Only instances with an application actor can be followed",
|
||||
"Domain or instance name": "Domain or instance name",
|
||||
"You need to enter a text": "You need to enter a text"
|
||||
"You need to enter a text": "You need to enter a text",
|
||||
"Error while adding tag: {error}": "Error while adding tag: {error}"
|
||||
}
|
|
@ -1637,5 +1637,6 @@
|
|||
"Software details: {software_details}": "Détails du logiciel : {software_details}",
|
||||
"Only instances with an application actor can be followed": "Seules les instances avec un acteur application peuvent être suivies",
|
||||
"Domain or instance name": "Domaine ou nom de l'instance",
|
||||
"You need to enter a text": "Vous devez entrer un texte"
|
||||
"You need to enter a text": "Vous devez entrer un texte",
|
||||
"Error while adding tag: {error}": "Erreur lors de l'ajout d'un tag : {error}"
|
||||
}
|
||||
|
|
|
@ -924,9 +924,28 @@ const handleError = (err: any) => {
|
|||
console.error(err);
|
||||
|
||||
if (err.graphQLErrors !== undefined) {
|
||||
err.graphQLErrors.forEach(({ message }: { message: string }) => {
|
||||
notifier?.error(message);
|
||||
});
|
||||
err.graphQLErrors.forEach(
|
||||
({
|
||||
message,
|
||||
field,
|
||||
}: {
|
||||
message: string | { slug?: string[] }[];
|
||||
field: string;
|
||||
}) => {
|
||||
if (
|
||||
field === "tags" &&
|
||||
Array.isArray(message) &&
|
||||
message.some((msg) => msg.slug)
|
||||
) {
|
||||
const finalMsg = message.find((msg) => msg.slug?.[0]);
|
||||
notifier?.error(
|
||||
t("Error while adding tag: {error}", { error: finalMsg?.slug?.[0] })
|
||||
);
|
||||
} else if (typeof message === "string") {
|
||||
notifier?.error(message);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue