From dc6a6e46740b84113f4d2e4a701c4158cfff7365 Mon Sep 17 00:00:00 2001 From: Dawid Tarasiuk Date: Thu, 15 Apr 2021 16:36:40 +0200 Subject: [PATCH] Fix voucher and sales sorting errors --- src/discounts/views/SaleList/SaleList.tsx | 2 +- src/discounts/views/VoucherList/VoucherList.tsx | 2 +- src/utils/sort.ts | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/discounts/views/SaleList/SaleList.tsx b/src/discounts/views/SaleList/SaleList.tsx index a71ee51a42e..086e04448cf 100644 --- a/src/discounts/views/SaleList/SaleList.tsx +++ b/src/discounts/views/SaleList/SaleList.tsx @@ -75,7 +75,7 @@ export const SaleList: React.FC = ({ params }) => { () => ({ ...paginationState, filter: getFilterVariables(params), - sort: getSortQueryVariables(params) + sort: getSortQueryVariables(params, channel.slug) }), [params] ); diff --git a/src/discounts/views/VoucherList/VoucherList.tsx b/src/discounts/views/VoucherList/VoucherList.tsx index 84c804ca785..108d4d1008c 100644 --- a/src/discounts/views/VoucherList/VoucherList.tsx +++ b/src/discounts/views/VoucherList/VoucherList.tsx @@ -76,7 +76,7 @@ export const VoucherList: React.FC = ({ params }) => { () => ({ ...paginationState, filter: getFilterVariables(params), - sort: getSortQueryVariables(params) + sort: getSortQueryVariables(params, channel.slug) }), [params] ); diff --git a/src/utils/sort.ts b/src/utils/sort.ts index c35a3d75bac..74e8e7eb44c 100644 --- a/src/utils/sort.ts +++ b/src/utils/sort.ts @@ -72,7 +72,7 @@ type GetSortQueryField = ( type GetSortQueryVariables< TSortField extends string, TParams extends Record -> = (params: TParams) => SortingInput; +> = (params: TParams, channelSlug?: string) => SortingInput; export function createGetSortQueryVariables< TUrlField extends string, TSortField extends string, @@ -80,13 +80,14 @@ export function createGetSortQueryVariables< >( getSortQueryField: GetSortQueryField ): GetSortQueryVariables { - return (params: TParams) => { + return (params: TParams, channelSlug?: string) => { const field = getSortQueryField(params.sort); if (!!field) { return { direction: getOrderDirection(params.asc), - field + field, + channel: channelSlug }; }