Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#188 Fix bug sorting with Section number on Chapter page #189

Merged
Merged
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
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
Loading