Skip to content

Commit

Permalink
Fixed api mapping sort options
Browse files Browse the repository at this point in the history
  • Loading branch information
dlymonkai committed Nov 19, 2024
1 parent da13d3a commit 7c72523
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 5 additions & 4 deletions packages/network/src/api/inspection/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`;
}
9 changes: 7 additions & 2 deletions packages/network/src/api/models/inspection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ interface ApiPaginationParams {
}

interface ApiCursors {
before?: Pick<ApiPaginationParams, 'before'>;
after?: Pick<ApiPaginationParams, 'after'>;
before?: string;
after?: string;
next?: ApiPaginationParams;
previous?: ApiPaginationParams;
}
Expand Down Expand Up @@ -76,3 +76,8 @@ export interface ApiInspectionPost {
vehicle?: ApiVehiclePostPatch;
damage_severity?: ApiDamageSeverity;
}

export interface ApiInspectionsSortRequest {
sort_by_property?: string;
sort_drder?: SortOrder;
}

0 comments on commit 7c72523

Please sign in to comment.