@commercelayer/react-components 4.13.3 → 4.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setShippingMethod=exports.getShipments=exports.setShipmentErrors=exports.shipmentInitialState=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk"));exports.shipmentInitialState={errors:[]};const setShipmentErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})};exports.setShipmentErrors=setShipmentErrors;const getShipments=_a=>tslib_1.__awaiter(void 0,[_a],void 0,function*({order,dispatch,config}){try{const sdk=(0,getSdk_1.default)(config),shipments=order.shipments,
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.setShippingMethod=exports.getShipments=exports.setShipmentErrors=exports.shipmentInitialState=void 0;const tslib_1=require("tslib"),baseReducer_1=tslib_1.__importDefault(require("../utils/baseReducer")),getSdk_1=tslib_1.__importDefault(require("../utils/getSdk"));exports.shipmentInitialState={errors:[]};const setShipmentErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})};exports.setShipmentErrors=setShipmentErrors;const getShipments=_a=>tslib_1.__awaiter(void 0,[_a],void 0,function*({order,dispatch,config}){try{const sdk=(0,getSdk_1.default)(config),shipments=order.shipments;let allDeliveryLeadTimes=[],currentPage=1,totalPages=1;do{const response=yield 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:allDeliveryLeadTimes}})}catch(error){console.error(error)}});exports.getShipments=getShipments;function setShippingMethod(_a){return tslib_1.__awaiter(this,arguments,void 0,function*({config,shipmentId,shippingMethodId,getOrder,order}){try{if(shippingMethodId){const sdk=(0,getSdk_1.default)(config);if(yield sdk.shipments.update({id:shipmentId,shipping_method:sdk.shipping_methods.relationship(shippingMethodId)}),getOrder!=null&&order!=null)return{success:!0,order:yield getOrder(order.id)}}return{success:!1}}catch(error){return console.error(error),{success:!1}}})}exports.setShippingMethod=setShippingMethod;const type=["setErrors","setShipments","setShippingMethod"],shipmentReducer=(state,reducer)=>(0,baseReducer_1.default)(state,reducer,type);exports.default=shipmentReducer;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shipmentInitialState={errors:[]},setShipmentErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},getShipments=async({order,dispatch,config})=>{try{const sdk=getSdk(config),shipments=order.shipments,
|
|
2
|
+
import baseReducer from"../utils/baseReducer";import getSdk from"../utils/getSdk";export const shipmentInitialState={errors:[]},setShipmentErrors=(errors,dispatch)=>{dispatch&&dispatch({type:"setErrors",payload:{errors}})},getShipments=async({order,dispatch,config})=>{try{const sdk=getSdk(config),shipments=order.shipments;let allDeliveryLeadTimes=[],currentPage=1,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:allDeliveryLeadTimes}})}catch(error){console.error(error)}};export async function setShippingMethod({config,shipmentId,shippingMethodId,getOrder,order}){try{if(shippingMethodId){const sdk=getSdk(config);if(await sdk.shipments.update({id:shipmentId,shipping_method:sdk.shipping_methods.relationship(shippingMethodId)}),getOrder!=null&&order!=null)return{success:!0,order:await getOrder(order.id)}}return{success:!1}}catch(error){return console.error(error),{success:!1}}}const type=["setErrors","setShipments","setShippingMethod"],shipmentReducer=(state,reducer)=>baseReducer(state,reducer,type);export default shipmentReducer;
|