From bddfa2c4af22e76b947a8cfab2532d33fd8d6904 Mon Sep 17 00:00:00 2001 From: Dawid Tarasiuk Date: Mon, 19 Apr 2021 16:03:51 +0200 Subject: [PATCH] SALEOR-1888-1889 - Fix voucher and sales sorting errors (#1063) * Fix voucher and sales sorting errors * Update changelog * Fix channel slug argument in sorting --- CHANGELOG.md | 1 + src/discounts/views/SaleList/SaleList.tsx | 2 +- src/discounts/views/VoucherList/VoucherList.tsx | 2 +- src/utils/sort.ts | 7 ++++--- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d46bb72e8..3c34b2420 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ All notable, unreleased changes to this project will be documented in this file. - Handle limit reached error - #990 by @dominik-zeglen - Display Cloud limits - #1004 by @dominik-zeglen - Add shipping method description - #1058 by @jwm0 +- Fix voucher and sales sorting errors - #1063 by @orzechdev # 2.11.1 diff --git a/src/discounts/views/SaleList/SaleList.tsx b/src/discounts/views/SaleList/SaleList.tsx index a71ee51a4..ab34fa8b8 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 84c804ca7..40e89a44e 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 c35a3d75b..74e8e7eb4 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 }; }