|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import { withTranslation } from 'react-i18next';
|
|
import { withTranslation } from 'react-i18next';
|
|
|
|
|
+import toArrayIfNot from '../../../../lib/util/toArrayIfNot';
|
|
|
|
|
|
|
|
const ApiErrorMessage = (props) => {
|
|
const ApiErrorMessage = (props) => {
|
|
|
const {
|
|
const {
|
|
@@ -16,6 +17,8 @@ const ApiErrorMessage = (props) => {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ const errArray = toArrayIfNot(errors);
|
|
|
|
|
+
|
|
|
function renderMessage(err) {
|
|
function renderMessage(err) {
|
|
|
|
|
|
|
|
function renderMessageByErrorCode() {
|
|
function renderMessageByErrorCode() {
|
|
@@ -67,7 +70,7 @@ const ApiErrorMessage = (props) => {
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
- {errors.map((error) => {
|
|
|
|
|
|
|
+ {errArray.map((error) => {
|
|
|
return (
|
|
return (
|
|
|
<span key={error.message} className="text-danger">
|
|
<span key={error.message} className="text-danger">
|
|
|
{renderMessage(error)}
|
|
{renderMessage(error)}
|
|
@@ -82,7 +85,7 @@ const ApiErrorMessage = (props) => {
|
|
|
ApiErrorMessage.propTypes = {
|
|
ApiErrorMessage.propTypes = {
|
|
|
t: PropTypes.func.isRequired, // i18next
|
|
t: PropTypes.func.isRequired, // i18next
|
|
|
|
|
|
|
|
- errors: PropTypes.array,
|
|
|
|
|
|
|
+ errors: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
|
|
targetPath: PropTypes.string,
|
|
targetPath: PropTypes.string,
|
|
|
};
|
|
};
|
|
|
|
|
|