From 7c72523040a4cb88323bd352d327ae4c5b85f13e Mon Sep 17 00:00:00 2001 From: David Ly Date: Tue, 19 Nov 2024 08:46:49 +0100 Subject: [PATCH] Fixed api mapping sort options --- packages/network/src/api/inspection/mappers.ts | 9 +++++---- packages/network/src/api/models/inspection.ts | 9 +++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/network/src/api/inspection/mappers.ts b/packages/network/src/api/inspection/mappers.ts index a68ff398..eb07b362 100644 --- a/packages/network/src/api/inspection/mappers.ts +++ b/packages/network/src/api/inspection/mappers.ts @@ -696,10 +696,11 @@ export function mapApiInspectionsUrlParamsGet(options: GetInspectionsOptions): s params.append(key, value.toString()); }); } - if (options.sort) { - Object.entries(options.sort).forEach(([key, value]) => { - params.append(key, value.toString()); - }); + if (options.sort?.sortByProperty) { + params.append('sort_by_property', options.sort.sortByProperty); + } + if (options.sort?.sortOrder) { + params.append('sort_order', options.sort.sortOrder.toString()); } return `${url}${params.toString()}`; } diff --git a/packages/network/src/api/models/inspection.ts b/packages/network/src/api/models/inspection.ts index 453d70e2..7af35f3b 100644 --- a/packages/network/src/api/models/inspection.ts +++ b/packages/network/src/api/models/inspection.ts @@ -46,8 +46,8 @@ interface ApiPaginationParams { } interface ApiCursors { - before?: Pick; - after?: Pick; + before?: string; + after?: string; next?: ApiPaginationParams; previous?: ApiPaginationParams; } @@ -76,3 +76,8 @@ export interface ApiInspectionPost { vehicle?: ApiVehiclePostPatch; damage_severity?: ApiDamageSeverity; } + +export interface ApiInspectionsSortRequest { + sort_by_property?: string; + sort_drder?: SortOrder; +}