Skip to content

Commit

Permalink
Remove sort_by from table query params (#2088)
Browse files Browse the repository at this point in the history
* remove sort by from table query params

* fix the failing tests

---------

Co-authored-by: bot-bigbinary <[email protected]>
  • Loading branch information
farhanlatheef and bot-bigbinary authored Feb 22, 2024
1 parent 2adcd27 commit b50149f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/Table/hooks/useTableSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const useTableSort = () => {

const handleTableChange = (pagination, sorter) => {
const params = {
sort_by: sorter.order && camelToSnakeCase(sorter.field),
sort_by: sorter.order ? camelToSnakeCase(sorter.field) : undefined,
order_by: URL_SORT_ORDERS[sorter.order],
page: pagination.current,
};
Expand Down
4 changes: 2 additions & 2 deletions tests/Table.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe("Table", () => {
await userEvent.click(pages[2]);
const queryParams = getQueryParams();

expect(queryParams).toEqual({ page: "2", sort_by: "" });
expect(queryParams).toEqual({ page: "2" });
});

it("should navigate to previous page if all the items in the last page are deleted", () => {
Expand All @@ -196,7 +196,7 @@ describe("Table", () => {
/>
);

expect(getQueryParams()).toEqual({ page: "3", sort_by: "" });
expect(getQueryParams()).toEqual({ page: "3" });

const handlePageChange = jest.fn();
render(
Expand Down

0 comments on commit b50149f

Please sign in to comment.