Skip to content

Commit

Permalink
#188 Fix bug sorting with Section number on Chapter page
Browse files Browse the repository at this point in the history
  • Loading branch information
iampz committed Sep 6, 2024
1 parent a78ddcd commit 5bf1ecd
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/pages/Chapter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,15 @@ export default function Chapter() {
.multiFilter(discussionistCriteria, [])
.list("มาตรา").data;

const sorted = dataObject.sort((a, b) =>
sort === 0 ? b.count - a.count : a.count - b.count
);
const sorted = dataObject.sort((a, b) => {
if (sort === 2) {
return a.มาตรา - b.มาตรา;
} else if (sort === 1) {
return a.count - b.count;
} else {
return b.count - a.count;
}
});
return sorted;
}, [selectedDiscussionists, name, sort]);

Expand Down Expand Up @@ -143,7 +149,7 @@ export default function Chapter() {
)}
</>
)}
<SortBy sort={sort} setSort={setSort} />
<SortBy sort={sort} setSort={setSort} mode="section" />
</div>
<div className="flex flex-col justify-center items-center gap-2.5 w-full">
{result.map(({ มาตรา, count }) => (
Expand Down

0 comments on commit 5bf1ecd

Please sign in to comment.