@shopgate/engage
Version:
Shopgate's ENGAGE library.
60 lines • 2.53 kB
JavaScript
import React, { Fragment } from 'react';
import { FAVORITES_PATH } from '@shopgate/pwa-common-commerce/favorites/constants';
import { CART_PATH } from '@shopgate/pwa-common-commerce/cart/constants';
import { LOGIN_PATH } from '@shopgate/pwa-common/constants/RoutePaths';
import appConfig from '@shopgate/pwa-common/helpers/config';
import { useSideNavigation } from "./SideNavigation.hooks";
import SideNavigationItem from "./SideNavigationItem";
import SideNavigationNestedItem from "./SideNavigationNestedItem";
import SideNavigationLinksQuicklinks from "./SideNavigationLinksQuicklinks";
import SideNavigationLinksLegal from "./SideNavigationLinksLegal";
import { PROFILE_PATH, WISH_LIST_PATH, ORDERS_PATH } from "../../account";
/**
* SideNavigationLinks component
* @returns {JSX}
*/
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
const SideNavigationLinks = () => {
const {
isLoggedIn,
logout,
currentPathname
} = useSideNavigation();
const isAccountActive = currentPathname === PROFILE_PATH || currentPathname === ORDERS_PATH || currentPathname === WISH_LIST_PATH;
return /*#__PURE__*/_jsxs(_Fragment, {
children: [/*#__PURE__*/_jsx(SideNavigationItem, {
href: CART_PATH,
label: "navigation.cart"
}), !isLoggedIn && appConfig.hasFavorites ? /*#__PURE__*/_jsx(SideNavigationItem, {
href: FAVORITES_PATH,
label: "navigation.favorites"
}) : null, isLoggedIn && /*#__PURE__*/_jsx(SideNavigationNestedItem, {
href: PROFILE_PATH,
label: "navigation.your_account",
forceActive: isAccountActive,
level: 0,
children: /*#__PURE__*/_jsxs("ul", {
children: [/*#__PURE__*/_jsx(SideNavigationItem, {
level: 1,
href: PROFILE_PATH,
label: "titles.profile"
}), /*#__PURE__*/_jsx(SideNavigationItem, {
level: 1,
href: ORDERS_PATH,
label: "titles.order_history"
}), appConfig.hasFavorites ? /*#__PURE__*/_jsx(SideNavigationItem, {
level: 1,
href: WISH_LIST_PATH,
label: "titles.favorites"
}) : null]
})
}), /*#__PURE__*/_jsx(SideNavigationLinksQuicklinks, {}), /*#__PURE__*/_jsx(SideNavigationLinksLegal, {}), isLoggedIn ? /*#__PURE__*/_jsx(SideNavigationItem, {
onClick: logout,
label: "navigation.logout"
}) : /*#__PURE__*/_jsx(SideNavigationItem, {
href: LOGIN_PATH,
label: "navigation.login_register"
})]
});
};
export default SideNavigationLinks;