SALEOR-1888-1889 - Fix voucher and sales sorting errors (#1063)

* Fix voucher and sales sorting errors

* Update changelog

* Fix channel slug argument in sorting
This commit is contained in:
Dawid Tarasiuk 2021-04-19 16:03:51 +02:00 committed by GitHub
parent e5df1b2dbf
commit bddfa2c4af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 5 deletions

View file

@ -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

View file

@ -75,7 +75,7 @@ export const SaleList: React.FC<SaleListProps> = ({ params }) => {
() => ({
...paginationState,
filter: getFilterVariables(params),
sort: getSortQueryVariables(params)
sort: getSortQueryVariables(params, channel?.slug)
}),
[params]
);

View file

@ -76,7 +76,7 @@ export const VoucherList: React.FC<VoucherListProps> = ({ params }) => {
() => ({
...paginationState,
filter: getFilterVariables(params),
sort: getSortQueryVariables(params)
sort: getSortQueryVariables(params, channel?.slug)
}),
[params]
);

View file

@ -72,7 +72,7 @@ type GetSortQueryField<TUrlField extends string, TSortField extends string> = (
type GetSortQueryVariables<
TSortField extends string,
TParams extends Record<any, any>
> = (params: TParams) => SortingInput<TSortField>;
> = (params: TParams, channelSlug?: string) => SortingInput<TSortField>;
export function createGetSortQueryVariables<
TUrlField extends string,
TSortField extends string,
@ -80,13 +80,14 @@ export function createGetSortQueryVariables<
>(
getSortQueryField: GetSortQueryField<TUrlField, TSortField>
): GetSortQueryVariables<TSortField, TParams> {
return (params: TParams) => {
return (params: TParams, channelSlug?: string) => {
const field = getSortQueryField(params.sort);
if (!!field) {
return {
direction: getOrderDirection(params.asc),
field
field,
channel: channelSlug
};
}