@shopgate/engage
Version:
Shopgate's ENGAGE library.
33 lines (32 loc) • 1.27 kB
JavaScript
import React, { useContext, useMemo } from 'react';
import classNames from 'classnames';
import { StoreContext } from "./Store.context";
import { StoreFinderContext } from "../../locations.context";
import StoreFinderLocationHeader from "./StoreFinderLocationHeader";
import { container, selected } from "./StoreFinderLocation.style";
import { StoreFinderSelectLocationButton } from "./StoreFinderSelectLocationButton";
import StoreFinderStoreInfoButton from "./StoreFinderStoreInfoButton";
/**
* @returns {JSX.Element}
*/
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const StoreFinderLocation = () => {
const store = useContext(StoreContext);
const {
selectedLocation
} = useContext(StoreFinderContext);
const isSelected = useMemo(() => {
const {
code
} = selectedLocation || {};
return store.code === code;
}, [selectedLocation, store.code]);
return /*#__PURE__*/_jsxs("div", {
className: classNames(container, {
[selected]: isSelected
}),
"data-location-code": store.code,
children: [/*#__PURE__*/_jsx(StoreFinderLocationHeader, {}), /*#__PURE__*/_jsx(StoreFinderSelectLocationButton, {}), /*#__PURE__*/_jsx(StoreFinderStoreInfoButton, {})]
});
};
export default StoreFinderLocation;