Skip to content

Commit

Permalink
Merge pull request #522 from commercelayer/fix/delivey-lead-times
Browse files Browse the repository at this point in the history
Fix delivery lead times pagination
  • Loading branch information
acasazza authored May 15, 2024
2 parents c4bd26d + 2aa4fe5 commit 4870452
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useNx": false,
"npmClient": "pnpm",
"version": "4.13.3",
"version": "4.13.4-beta.0",
"command": {
"version": {
"preid": "beta"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@commercelayer/react-components",
"version": "4.13.3",
"version": "4.13.4-beta.0",
"description": "The Official Commerce Layer React Components",
"main": "lib/cjs/index.js",
"module": "lib/esm/index.js",
Expand Down
17 changes: 13 additions & 4 deletions packages/react-components/src/reducers/ShipmentReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,23 @@ export const getShipments: GetShipments = async ({
try {
const sdk = getSdk(config)
const shipments = order.shipments
const deliveryLeadTimes = await sdk.delivery_lead_times.list({
include: ['shipping_method', 'stock_location']
})
let allDeliveryLeadTimes: DeliveryLeadTime[] = []
let currentPage = 1
let totalPages = 1
do {
const response = await sdk.delivery_lead_times.list({
include: ['shipping_method', 'stock_location'],
pageNumber: currentPage
})
allDeliveryLeadTimes = allDeliveryLeadTimes.concat(response)
totalPages = response.meta.pageCount
currentPage++
} while (currentPage <= totalPages)
dispatch({
type: 'setShipments',
payload: {
shipments,
deliveryLeadTimes
deliveryLeadTimes: allDeliveryLeadTimes
}
})
} catch (error) {
Expand Down

0 comments on commit 4870452

Please sign in to comment.