@commercelayer/react-components
Version:
The Official Commerce Layer React Components
2 lines • 1.01 kB
JavaScript
"use client";
;Object.defineProperty(exports,"__esModule",{value:!0}),exports.StockTransfer=StockTransfer;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),ShipmentChildrenContext_1=tslib_1.__importDefault(require("../../context/ShipmentChildrenContext")),StockTransferChildrenContext_1=tslib_1.__importDefault(require("../../context/StockTransferChildrenContext"));function StockTransfer(props){const{children}=props,{stockTransfers,lineItems}=(0,react_1.useContext)(ShipmentChildrenContext_1.default),components=stockTransfers?.filter(st=>!!lineItems?.find(l=>l?.sku_code!==st?.sku_code)).map((stockTransfer,k)=>{const stockTransferProps={stockTransfer:stockTransfer.type==="line_items"?stockTransfer:stockTransfer?.line_item};return(0,jsx_runtime_1.jsx)(StockTransferChildrenContext_1.default.Provider,{value:stockTransferProps,children},k)});return(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:components})}exports.default=StockTransfer;