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 //
// // { t('page_api_error.notfound_or_forbidden') } // // // { t('page_api_error.user_not_admin') } // // // { t('page_api_error.outdated') } // {/* */} // { t('Load latest') } // {/* */} // // // Invalid path // // // Unknown error occured // //
}; ApiErrorMessage.propTypes = { t: PropTypes.func.isRequired, // i18next errorCode: PropTypes.string, errorMessage: PropTypes.string, linkPath: PropTypes.string, }; export default withTranslation()(ApiErrorMessage);