import React from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; const ApiErrorMessage = (props) => { const { t, errorCode, errorMessage, linkPath, } = props; function renderMessageByErrorCode() { switch (errorCode) { case 'already_exists': return ( <> { t('page_api_error.already_exists') } {linkPath} > ); default: return null; } } if (errorCode != null) { return ( {renderMessageByErrorCode()} ); } if (errorMessage != null) { return ( {errorMessage} ); } // render null if no error has occurred return null; // TODO GW-79 Set according to error message //