fix(medusa): add support for order field on GET /admin/orders (#6258)
**What** - Adds support for `order` field on `GET /admin/orders`
This commit is contained in:
committed by
GitHub
parent
8ec093dc07
commit
90cff0777f
6
.changeset/little-carrots-serve.md
Normal file
6
.changeset/little-carrots-serve.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@medusajs/client-types": patch
|
||||
"@medusajs/medusa": patch
|
||||
---
|
||||
|
||||
fix(medusa): Adds support for ordering GET /admin/orders
|
||||
@@ -78,6 +78,23 @@ describe("/admin/orders", () => {
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
})
|
||||
|
||||
it("gets orders ordered by display_id", async () => {
|
||||
const api = useApi()
|
||||
|
||||
const response = await api
|
||||
.get("/admin/orders?order=display_id", adminReqConfig)
|
||||
.catch((err) => {
|
||||
console.log(err)
|
||||
})
|
||||
expect(response.status).toEqual(200)
|
||||
|
||||
const sortedOrders = response.data.orders.sort((a, b) => {
|
||||
return a.display_id - b.display_id
|
||||
})
|
||||
|
||||
expect(response.data.orders).toEqual(sortedOrders)
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/orders/:id", () => {
|
||||
|
||||
@@ -155,4 +155,8 @@ export interface AdminGetOrdersParams {
|
||||
* Comma-separated fields that should be included in the returned order.
|
||||
*/
|
||||
fields?: string
|
||||
/**
|
||||
* A order field to sort-order the retrieved orders by.
|
||||
*/
|
||||
order?: string
|
||||
}
|
||||
|
||||
@@ -152,6 +152,7 @@ import { cleanResponseData } from "../../../../utils/clean-response-data"
|
||||
* - (query) limit=50 {integer} Limit the number of orders returned.
|
||||
* - (query) expand {string} Comma-separated relations that should be expanded in the returned order.
|
||||
* - (query) fields {string} Comma-separated fields that should be included in the returned order.
|
||||
* - (query) order {string} A order field to sort-order the retrieved orders by.
|
||||
* x-codegen:
|
||||
* method: list
|
||||
* queryParams: AdminGetOrdersParams
|
||||
@@ -277,4 +278,11 @@ export class AdminGetOrdersParams extends AdminListOrdersSelector {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
fields?: string
|
||||
|
||||
/**
|
||||
* The field to sort the data by. By default, the sort order is ascending. To change the order to descending, prefix the field name with `-`.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
order?: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user