| @@ -143,18 +143,18 @@ const ItemPriceSearch: ItemPriceSearchComponent = () => { | |||||
| const data = res.data; | const data = res.data; | ||||
| if (!data.success) { | if (!data.success) { | ||||
| const errMsg = | const errMsg = | ||||
| data.errors?.length > 0 | |||||
| ? `${t("Upload failed", { ns: "common" })}\n\n${data.errors.join("\n")}` | |||||
| (data.errors?.length ?? 0) > 0 | |||||
| ? `${t("Upload failed", { ns: "common" })}\n\n${(data.errors ?? []).join("\n")}` | |||||
| : t("Upload failed", { ns: "common" }); | : t("Upload failed", { ns: "common" }); | ||||
| alert(errMsg); | alert(errMsg); | ||||
| return; | return; | ||||
| } | } | ||||
| const updated = data.updated ?? 0; | const updated = data.updated ?? 0; | ||||
| if (data.errors?.length) { | |||||
| if ((data.errors?.length ?? 0) > 0) { | |||||
| const successLabel = t("Upload successful", { ns: "common" }); | const successLabel = t("Upload successful", { ns: "common" }); | ||||
| const countLabel = t("item(s) updated", { ns: "common" }); | const countLabel = t("item(s) updated", { ns: "common" }); | ||||
| const rowErrorsLabel = t("Upload row errors", { ns: "common" }); | const rowErrorsLabel = t("Upload row errors", { ns: "common" }); | ||||
| const msg = `${successLabel} ${updated} ${countLabel}\n\n${rowErrorsLabel}\n${data.errors.join("\n")}`; | |||||
| const msg = `${successLabel} ${updated} ${countLabel}\n\n${rowErrorsLabel}\n${(data.errors ?? []).join("\n")}`; | |||||
| alert(msg); | alert(msg); | ||||
| } else { | } else { | ||||
| alert(t("Upload successful", { ns: "common" })); | alert(t("Upload successful", { ns: "common" })); | ||||