Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion admin/src/components/MenuRows/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand All @@ -40,6 +46,9 @@ const MenuRows = ({ data, onClickClone, onClickDelete, onClickEdit }) => {
fn: () => onClickEdit(row.id),
})}
>
<Td>
<Typography textColor="neutral800">{row.id}</Typography>
</Td>
<Td>
<Typography textColor="neutral800">{row.attributes.title}</Typography>
</Td>
Expand Down Expand Up @@ -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({
Expand Down
13 changes: 12 additions & 1 deletion admin/src/pages/IndexView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -255,4 +266,4 @@ IndexView.propTypes = {
}).isRequired,
};

export default memo(IndexView);
export default memo(IndexView);