diff --git a/admin/src/components/MenuRows/index.js b/admin/src/components/MenuRows/index.js index 760ee94..5a32896 100644 --- a/admin/src/components/MenuRows/index.js +++ b/admin/src/components/MenuRows/index.js @@ -25,7 +25,13 @@ const MenuRows = ({ data, onClickClone, onClickDelete, onClickEdit }) => { const [sortKey, sortOrder] = query.sort.split(':'); rows = data.sort((a, b) => { - const compare = a.attributes[sortKey].localeCompare(b.attributes[sortKey]); + let compare; + if (sortKey === 'id') { + // Directly compare IDs + compare = a.id - b.id; + } else { + compare = a.attributes[sortKey].localeCompare(b.attributes[sortKey]); + } return sortOrder === 'ASC' ? compare : -compare; }); @@ -40,6 +46,9 @@ const MenuRows = ({ data, onClickClone, onClickDelete, onClickEdit }) => { fn: () => onClickEdit(row.id), })} > + + {row.id} + {row.attributes.title} @@ -104,6 +113,7 @@ MenuRows.propTypes = { PropTypes.shape({ id: PropTypes.number.isRequired, attributes: PropTypes.shape({ + id: PropTypes.number.isRequired, title: PropTypes.string.isRequired, slug: PropTypes.string.isRequired, items: PropTypes.shape({ diff --git a/admin/src/pages/IndexView/index.js b/admin/src/pages/IndexView/index.js index 7ef6fd9..2e7a5c3 100644 --- a/admin/src/pages/IndexView/index.js +++ b/admin/src/pages/IndexView/index.js @@ -139,6 +139,17 @@ const IndexView = ({ history }) => { const pageCount = data?.meta?.total ? Math.ceil(data.meta.total / data.meta.limit) : 1; const tableHeaders = [ + { + name: 'id', + key: 'id', + metadatas: { + label: formatMessage({ + id: getTrad('form.label.id'), + defaultMessage: 'Id', + }), + sortable: true, + }, + }, { name: 'title', key: 'title', @@ -255,4 +266,4 @@ IndexView.propTypes = { }).isRequired, }; -export default memo(IndexView); +export default memo(IndexView); \ No newline at end of file