47 lines
1017 B
JavaScript
Raw Normal View History

2017-09-20 12:00:42 +02:00
/**
*
* TableRow
*
*/
import React from 'react';
2017-09-20 12:00:42 +02:00
import PropTypes from 'prop-types';
2018-05-23 18:23:27 +02:00
import { FormattedMessage } from 'react-intl';
import { upperFirst } from 'lodash';
2017-09-20 12:00:42 +02:00
import styles from './styles.scss';
function TableEmpty({ colspan, contentType, filters, search }) {
let id, values;
const model = upperFirst(contentType);
if (search !== '') {
id = 'withSearch',
values = { contentType: model, search };
} else {
id = filters.length > 0 ? 'withFilters' : 'withoutFilter';
values = { contentType: model || 'entry' };
}
2018-05-23 18:23:27 +02:00
return (
<tr className={styles.tableEmpty}>
<td colSpan={colspan + 1}>
<FormattedMessage id={`content-manager.components.TableEmpty.${id}`} values={values} />
2018-05-23 18:23:27 +02:00
</td>
</tr>
);
2017-09-20 12:00:42 +02:00
}
TableEmpty.defaultProps = {
search: '',
};
2017-09-20 12:00:42 +02:00
TableEmpty.propTypes = {
colspan: PropTypes.number.isRequired,
contentType: PropTypes.string.isRequired,
2018-05-23 18:23:27 +02:00
filters: PropTypes.array.isRequired,
search: PropTypes.string,
2017-09-20 12:00:42 +02:00
};
export default TableEmpty;