UNPKG

@shopgate/engage

Version:
36 lines (35 loc) 1.2 kB
import React, { useContext, forwardRef } from 'react'; import { CardList } from '@shopgate/engage/components'; import { StoreFinderContext } from "../../locations.context"; import { StoreContext } from "./Store.context"; import StoreFinderLocation from "./StoreFinderLocation"; import { container, cardList, card } from "./StoreFinderLocations.style"; /** * @param {Object} props The component props * @param {Object} ref A forwarded ref * @returns {JSX} */ import { jsx as _jsx } from "react/jsx-runtime"; const StoreFinderLocations = (props, ref) => { const { locations } = useContext(StoreFinderContext); if (!locations || locations.length === 0) { return null; } return /*#__PURE__*/_jsx("div", { ref: ref, className: container, children: /*#__PURE__*/_jsx(CardList, { className: cardList, children: locations.map(location => /*#__PURE__*/_jsx(CardList.Item, { className: card, children: /*#__PURE__*/_jsx(StoreContext.Provider, { value: location, children: /*#__PURE__*/_jsx(StoreFinderLocation, {}) }) }, location.code)) }) }); }; export default /*#__PURE__*/forwardRef(StoreFinderLocations);