@commercelayer/react-components 3.12.0 → 3.12.1
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 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import ShipmentContext,{defaultShipmentContext}from"../context/ShipmentContext";import{useContext,useEffect,useReducer}from"react";import shipmentReducer,{shipmentInitialState,setShipmentErrors,getShipments,setShippingMethod}from"../reducers/ShipmentReducer";import OrderContext from"../context/OrderContext";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";import{isEmpty}from"lodash";const propTypes=components.ShipmentsContainer.propTypes,displayName=components.ShipmentsContainer.displayName,ShipmentsContainer=props=>{const{children}=props,[state,dispatch]=useReducer(shipmentReducer,shipmentInitialState),{order,getOrder,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>{(include==null?void 0:include.includes("shipments.available_shipping_methods"))?(includeLoaded==null?void 0:includeLoaded["shipments.available_shipping_methods"])||addResourceToInclude({newResourceLoaded:{"shipments.available_shipping_methods":!0,"shipments.shipment_line_items.line_item":!0,"shipments.shipping_method":!0,"shipments.stock_transfers.line_item":!0,"shipments.stock_location":!0}}):addResourceToInclude({newResource:["shipments.available_shipping_methods","shipments.shipment_line_items.line_item","shipments.shipping_method","shipments.stock_transfers.line_item","shipments.stock_location"]}),order&&!isEmpty(config)&&order.shipments&&getShipments({order,dispatch,config})},[order,include,includeLoaded]),useEffect(()=>(order&&(order.shipments&&order.shipments.length>0&&order.shipments.map(shipment=>shipment.available_shipping_methods&&shipment.available_shipping_methods.length>0).includes(!1)&&setShipmentErrors([...state.errors||[],{code:"NO_SHIPPING_METHODS",message:"No shipping methods",resource:"shipments"}],dispatch),order.line_items&&order.line_items.length>0&&order.line_items.filter(({item_type})=>item_type==="skus").map(lineItem=>{var _a,_b,_c,_d
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import ShipmentContext,{defaultShipmentContext}from"../context/ShipmentContext";import{useContext,useEffect,useReducer}from"react";import shipmentReducer,{shipmentInitialState,setShipmentErrors,getShipments,setShippingMethod}from"../reducers/ShipmentReducer";import OrderContext from"../context/OrderContext";import CommerceLayerContext from"../context/CommerceLayerContext";import components from"../config/components";import{isEmpty}from"lodash";const propTypes=components.ShipmentsContainer.propTypes,displayName=components.ShipmentsContainer.displayName,ShipmentsContainer=props=>{const{children}=props,[state,dispatch]=useReducer(shipmentReducer,shipmentInitialState),{order,getOrder,include,addResourceToInclude,includeLoaded}=useContext(OrderContext),config=useContext(CommerceLayerContext);useEffect(()=>{(include==null?void 0:include.includes("shipments.available_shipping_methods"))?(includeLoaded==null?void 0:includeLoaded["shipments.available_shipping_methods"])||addResourceToInclude({newResourceLoaded:{"shipments.available_shipping_methods":!0,"shipments.shipment_line_items.line_item":!0,"shipments.shipping_method":!0,"shipments.stock_transfers.line_item":!0,"shipments.stock_location":!0}}):addResourceToInclude({newResource:["shipments.available_shipping_methods","shipments.shipment_line_items.line_item","shipments.shipping_method","shipments.stock_transfers.line_item","shipments.stock_location"]}),order&&!isEmpty(config)&&order.shipments&&getShipments({order,dispatch,config})},[order,include,includeLoaded]),useEffect(()=>(order&&(order.shipments&&order.shipments.length>0&&order.shipments.map(shipment=>shipment.available_shipping_methods&&shipment.available_shipping_methods.length>0).includes(!1)&&setShipmentErrors([...state.errors||[],{code:"NO_SHIPPING_METHODS",message:"No shipping methods",resource:"shipments"}],dispatch),order.line_items&&order.line_items.length>0&&order.line_items.filter(({item_type})=>item_type==="skus").map(lineItem=>{var _a,_b,_c,_d;return!!(((_a=lineItem.item)===null||_a===void 0?void 0:_a.do_not_ship)||((_b=lineItem.item)===null||_b===void 0?void 0:_b.do_not_track)||((_d=(_c=lineItem.item)===null||_c===void 0?void 0:_c.inventory)===null||_d===void 0?void 0:_d.quantity)>=(lineItem==null?void 0:lineItem.quantity))}).includes(!1)&&setShipmentErrors([...state.errors||[],{code:"OUT_OF_STOCK",message:"No stock available",resource:"line_items"}],dispatch)),()=>{setShipmentErrors([],dispatch)}),[order]);const contextValue=Object.assign(Object.assign({},state),{setShipmentErrors:errors=>defaultShipmentContext.setShipmentErrors(errors,dispatch),setShippingMethod:async(shipmentId,shippingMethodId)=>await setShippingMethod({shippingMethodId,shipmentId,config,getOrder,order})});return _jsx(ShipmentContext.Provider,Object.assign({value:contextValue},{children}))};ShipmentsContainer.propTypes=propTypes,ShipmentsContainer.displayName=displayName;export default ShipmentsContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import customMessages from"../../utils/customMessages";const getAllErrors=params=>{const{allErrors,messages,field,props,lineItem,resource,returnHtml=!0}=params;return allErrors.map((v,k)=>{var _a;const objMsg=customMessages(messages,v);let text=(v==null?void 0:v.title)&&!((_a=v.detail)===null||_a===void 0?void 0:_a.includes(v.title))?`${v.title} - ${v.detail}`:`${v.detail}`;if((objMsg==null?void 0:objMsg.message)&&(text=objMsg==null?void 0:objMsg.message),field){if(v.resource==="line_items"&&lineItem&&v.id===lineItem.id)return returnHtml?_jsx("span",Object.assign({},props,{children:text}),k):text;if(field===v.field&&resource===v.resource)return returnHtml?_jsx("span",Object.assign({},props,{children:text}),k):text}if(resource===v.resource&&!field)return returnHtml?_jsx("span",Object.assign({},props,{children:text}),k):text}).filter(v=>v!==void 0)};export default getAllErrors;
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import customMessages from"../../utils/customMessages";const getAllErrors=params=>{const{allErrors,messages,field,props,lineItem,resource,returnHtml=!0}=params;return allErrors.map((v,k)=>{var _a;const objMsg=customMessages(messages,v);let text=(v==null?void 0:v.title)&&!((_a=v.detail)===null||_a===void 0?void 0:_a.includes(v.title))?`${v.title} - ${v.detail}`:`${(v==null?void 0:v.detail)||v.message}`;if((objMsg==null?void 0:objMsg.message)&&(text=objMsg==null?void 0:objMsg.message),field){if(v.resource==="line_items"&&lineItem&&v.id===lineItem.id)return returnHtml?_jsx("span",Object.assign({},props,{children:text}),k):text;if(field===v.field&&resource===v.resource)return returnHtml?_jsx("span",Object.assign({},props,{children:text}),k):text}if(resource===v.resource&&!field)return returnHtml?_jsx("span",Object.assign({},props,{children:text}),k):text}).filter(v=>v!==void 0)};export default getAllErrors;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercelayer/react-components",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.1",
|
|
4
4
|
"description": "The Official Commerce Layer React Components",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"babel-loader": "^8.2.5",
|
|
130
130
|
"babel-plugin-istanbul": "^6.1.1",
|
|
131
131
|
"dotenv": "^16.0.0",
|
|
132
|
-
"eslint": "^8.
|
|
132
|
+
"eslint": "^8.15.0",
|
|
133
133
|
"eslint-config-prettier": "^8.5.0",
|
|
134
134
|
"eslint-config-react-app": "^7.0.1",
|
|
135
135
|
"eslint-plugin-react": "^7.29.4",
|
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
"rollup-plugin-babel": "^4.4.0",
|
|
150
150
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
151
151
|
"tailwindcss": "^3.0.24",
|
|
152
|
-
"ts-jest": "^28.0.
|
|
152
|
+
"ts-jest": "^28.0.2",
|
|
153
153
|
"ts-loader": "^9.3.0",
|
|
154
154
|
"tsc-alias": "^1.6.7",
|
|
155
155
|
"tsconfig-paths-jest": "^0.0.1",
|