UNPKG

@hhgtech/hhg-components

Version:
458 lines (434 loc) • 28.2 kB
import React__default, { useMemo, useState, Fragment, useEffect } from 'react'; import { a as CARE_LOCALES, T as TOGETHER_LOCALES, E as ECOM_LOCALES, D as DATA_PRIVACY_LOCALES } from './index-5e947517.js'; import { a as Avatar } from './index-5d405c0d.js'; import '@mantine/core'; import '@mantine/dates'; import './index-90813715.js'; import { C as CommonGAssets } from './index-ebe66e27.js'; import './useMantineLocale-0c6bea99.js'; import { T as Text } from './index-9f5659e8.js'; import './index-c68a0fa7.js'; import './index.styles-770020ac.js'; import { u as useTranslations } from './index-9d21b711.js'; import '@mantine/hooks'; import './utils-cb7242c7.js'; import './other-4ccb5568.js'; import './index-c2190f6e.js'; import { C as ChevronDown } from './ChevronDown-9f2ae50a.js'; import { e as normalizeLinkSlash, a as getCurrentSsoUrl, g as getCurrentBaseUrl } from './normalizeLink-593b397a.js'; import { css } from '@emotion/react'; import styled from '@emotion/styled'; import { theme } from './miscTheme.js'; import './translationsContext-3a9e3453.js'; import 'date-fns/locale'; import './constantsSite.js'; import './Locale-f270bd9d.js'; import './constantsDomainLocales.js'; import './constantsRiskScreener.js'; import './constantsIsProduction.js'; import './tslib.es6-ea4dfe68.js'; import '@hhgtech/icons/other'; import './useScreenSize-981e5b51.js'; import '@mantine/carousel'; import 'classnames'; import './useUniqueId-4305c9aa.js'; import '@hhgtech/icons/core'; import '@mantine/notifications'; import 'dayjs'; const NavBookingIcon = (props) => (React__default.createElement("svg", Object.assign({ width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" }, props), React__default.createElement("path", { d: "M2.5 6.5a3.2 3.2 0 0 1 3.2-3.2h7.9a3.2 3.2 0 0 1 3.19 3.2v4.72a3.2 3.2 0 0 1-3.2 3.2H5.7a3.2 3.2 0 0 1-3.19-3.2V6.49Z", fill: "#E3F2FF" }), React__default.createElement("path", { d: "M2.5 5.68A2.38 2.38 0 0 1 4.88 3.3h9.52a2.38 2.38 0 0 1 2.39 2.38z", fill: "#2D87F3" }), React__default.createElement("path", { d: "M13.6 2.5h-.03c-.36 0-.65.3-.65.65V4.2c0 .36.3.65.65.65h.03c.36 0 .65-.3.65-.65V3.15a.65.65 0 0 0-.65-.65M5.27 4.86h.03c.36 0 .65-.3.65-.65V3.15a.65.65 0 0 0-.65-.65h-.03c-.36 0-.65.3-.65.65V4.2c0 .36.3.65.65.65Z", fill: "#2743AD" }), React__default.createElement("path", { d: "M5.56 8.17h-.5a.4.4 0 0 0-.4.4v.59c0 .22.18.4.4.4h.5a.4.4 0 0 0 .4-.4v-.58a.4.4 0 0 0-.4-.41m2.7 0h-.5a.4.4 0 0 0-.4.4v.59c0 .22.18.4.4.4h.5a.4.4 0 0 0 .4-.4v-.58a.4.4 0 0 0-.4-.41m2.7 0h-.5a.4.4 0 0 0-.4.4v.59c0 .22.18.4.4.4h.5a.4.4 0 0 0 .4-.4v-.58a.4.4 0 0 0-.4-.41m2.87 0h-.49a.4.4 0 0 0-.4.4v.59c0 .22.18.4.4.4h.49a.4.4 0 0 0 .4-.4v-.58a.4.4 0 0 0-.4-.41m-8.3 2.52h-.5a.4.4 0 0 0-.4.4v.58c0 .23.18.4.4.4h.5a.4.4 0 0 0 .4-.4v-.58a.4.4 0 0 0-.4-.4m2.7 0h-.5a.4.4 0 0 0-.4.4v.58c0 .23.18.4.4.4h.5a.4.4 0 0 0 .4-.4v-.58a.4.4 0 0 0-.4-.4m2.7 0h-.49a.4.4 0 0 0-.4.4v.58c0 .23.18.4.4.4h.5a.4.4 0 0 0 .4-.4v-.58a.4.4 0 0 0-.4-.4Zm2.87 0h-.49a.4.4 0 0 0-.4.4v.58c0 .23.18.4.4.4h.5a.4.4 0 0 0 .4-.4v-.58a.4.4 0 0 0-.4-.4Z", fill: "#2D87F3" }), React__default.createElement("path", { d: "M16 16.8a3.17 3.17 0 1 0 0-6.36 3.17 3.17 0 0 0 0 6.35Z", fill: "#FE921D" }), React__default.createElement("path", { d: "M15.78 13.62v-1.36a.21.21 0 0 1 .42 0v1.26l.48.4a.21.21 0 0 1-.01.33.21.21 0 0 1-.26-.01l-.55-.46-.02-.01a.2.2 0 0 1-.06-.15", fill: "#fff" }))); const NavCommunityIcon = (props) => (React__default.createElement("svg", Object.assign({ width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" }, props), React__default.createElement("path", { d: "M7.06 4.97h-2.3a3.12 3.12 0 0 0-3.1 3.1v.43a3.12 3.12 0 0 0 3.1 3.1h1.39s1.47 1.11 1.5.97c.03-.22-.23-.99-.23-.99a3.13 3.13 0 0 0 2.72-3.09v-.41a3.12 3.12 0 0 0-3.08-3.11m-2.7 3.55a.23.23 0 1 1 0-.46.23.23 0 0 1 0 .46m1.35.4a.33.33 0 1 1 0-.66.33.33 0 0 1 0 .65Zm1.57-.05", fill: "#2D87F3" }), React__default.createElement("path", { d: "M12.88 9.52a3.53 3.53 0 0 0-1.35 6.8s-.23 1.03-.2 1.25c.03.14 1.55-.99 1.55-.99a3.53 3.53 0 0 0 0-7.06m-1.33 4.24a.48.48 0 1 1 0-.97.48.48 0 0 1 0 .97m1.58.04a.33.33 0 1 1 0-.66.33.33 0 0 1 0 .66m1.34-.39a.23.23 0 1 1 0-.46.23.23 0 0 1 0 .46", fill: "#FFB521" }), React__default.createElement("path", { d: "M16.45 1.67h-3.87a1.88 1.88 0 0 0-1.88 2.06l.22 2.29a1.88 1.88 0 0 0 1.73 1.7s-.17.94-.14 1.16c.02.14 1.66-1.13 1.66-1.13l1.92-.03a1.88 1.88 0 0 0 1.86-1.59l.36-2.29a1.88 1.88 0 0 0-1.86-2.17M13.1 5.23a.48.48 0 1 1 .34-.14c-.1.1-.22.14-.34.14m1.57.05a.33.33 0 1 1 .23-.1.33.33 0 0 1-.23.1m1.34-.4a.23.23 0 1 1 .1-.01.2.2 0 0 1-.1.02Z", fill: "#91CAFF" }))); const NavDotIcon = (props) => (React__default.createElement("svg", Object.assign({ width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" }, props), React__default.createElement("rect", { x: "8.333", y: "8.333", width: "3.333", height: "3.333", rx: "1.667", fill: "#2D87F3" }))); const NavEshopIcon = (props) => (React__default.createElement("svg", Object.assign({ width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" }, props), React__default.createElement("path", { d: "m3.18 7.06 1.6 1.6 4.33-4.69a.72.72 0 0 0-.03-.99l-.22-.22a.72.72 0 0 0-.99-.02zm13.64 0-1.6 1.6-4.33-4.69a.72.72 0 0 1 .02-.99l.23-.22a.72.72 0 0 1 .99-.02z", fill: "#2743AD" }), React__default.createElement("path", { d: "M15.04 16.7H4.9a.78.78 0 0 1-.77-.7l-.7-6.67h13.09l-.7 6.67a.78.78 0 0 1-.78.7", fill: "#2D87F3" }), React__default.createElement("path", { d: "M6.23 15.7a.23.23 0 0 1-.23-.22l-.3-4.46a.23.23 0 1 1 .47-.04l.3 4.47a.23.23 0 0 1-.22.25zm2.39 0a.23.23 0 0 1-.23-.23L8.3 11a.23.23 0 1 1 .47 0l.07 4.46a.23.23 0 0 1-.22.24h-.01Zm5.15 0h-.02a.23.23 0 0 1-.2-.16.2.2 0 0 1-.02-.09l.3-4.47a.24.24 0 0 1 .25-.22.23.23 0 0 1 .22.26l-.3 4.46a.23.23 0 0 1-.23.22m-2.39 0a.23.23 0 0 1-.23-.23l.07-4.47a.24.24 0 0 1 .24-.23.23.23 0 0 1 .23.23l-.08 4.47a.23.23 0 0 1-.23.23", fill: "#2743AD" }), React__default.createElement("path", { d: "M16.04 18.12a2.01 2.01 0 1 0 0-4.03 2.01 2.01 0 0 0 0 4.03", fill: "#FE921D" }), React__default.createElement("path", { d: "M16.97 15.87h-.7v-.7a.23.23 0 0 0-.46 0v.7h-.7a.23.23 0 1 0 0 .47h.7v.69a.23.23 0 1 0 .47 0v-.7h.69a.23.23 0 1 0 0-.46", fill: "#fff" }), React__default.createElement("path", { d: "M16.58 9.48H3.42a.8.8 0 0 1-.78-.7l-.13-1.1a.8.8 0 0 1 .78-.88h13.42a.8.8 0 0 1 .78.88l-.13 1.1a.8.8 0 0 1-.78.7", fill: "#BCDEFF" }))); const NavHelpIcon = (props) => (React__default.createElement("svg", Object.assign({ width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" }, props), React__default.createElement("path", { d: "M10 1.667c-4.595 0-8.333 3.738-8.333 8.333 0 4.595 3.738 8.333 8.333 8.333 4.595 0 8.333-3.738 8.333-8.333 0-4.595-3.738-8.333-8.333-8.333Zm0 13.194a.695.695 0 1 1 0-1.39.695.695 0 0 1 0 1.39Zm1.1-4.415a.698.698 0 0 0-.405.631v.312a.694.694 0 1 1-1.39 0v-.312c0-.81.477-1.553 1.213-1.893.707-.326 1.218-1.19 1.218-1.615 0-.956-.778-1.736-1.736-1.736s-1.736.78-1.736 1.736a.694.694 0 1 1-1.389 0A3.129 3.129 0 0 1 10 4.444a3.129 3.129 0 0 1 3.125 3.125c0 .939-.814 2.318-2.026 2.877Z", fill: "#FF6F4D" }))); const NavLogOutIcon = (props) => (React__default.createElement("svg", Object.assign({ width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" }, props), React__default.createElement("path", { d: "M11.116 1.72 5.488.85a1.898 1.898 0 0 0-2.155 1.856v14.588a1.898 1.898 0 0 0 2.158 1.855l5.625-.869a1.865 1.865 0 0 0 1.592-1.855V3.575a1.87 1.87 0 0 0-1.592-1.855", fill: "#2D87F3" }), React__default.createElement("path", { d: "M17.642 9.584a.6.6 0 0 1-.232.472l-1.964 1.518a.446.446 0 0 1-.719-.353v-.51l-2.118-.01a.225.225 0 0 1-.223-.225v-1.8a.225.225 0 0 1 .224-.225l2.12.002-.004-.506a.446.446 0 0 1 .719-.354l1.965 1.52a.6.6 0 0 1 .232.471", fill: "#FF6F4D" }), React__default.createElement("path", { d: "M17.642 9.584a.6.6 0 0 1-.232.472l-1.964 1.518a.446.446 0 0 1-.719-.353v-.51l-2.118-.01a.225.225 0 0 1-.223-.225v-1.8a.225.225 0 0 1 .224-.225l2.12.002-.004-.506a.446.446 0 0 1 .719-.354l1.965 1.52a.6.6 0 0 1 .232.471m-7.603-.908v1.802c0 .124.1.225.224.225h1.257c.124 0 .225-.1.225-.225V8.676c0-.124-.1-.224-.225-.224h-1.257c-.124 0-.224.1-.224.224m-.673 1.809a.224.224 0 0 1-.225.225h-.407a.61.61 0 0 1-.609-.61V9.069a.61.61 0 0 1 .61-.61h.406a.224.224 0 0 1 .225.225z", fill: "#FF6F4D" }))); const NavMyHealthIcon = (props) => (React__default.createElement("svg", Object.assign({ width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" }, props), React__default.createElement("path", { d: "M6.114 3.333a4.64 4.64 0 0 1 3.565 1.708.412.412 0 0 0 .642 0 4.64 4.64 0 0 1 3.565-1.708c2.646 0 4.447 2.302 4.447 5.142 0 1.698-.904 4.446-2.675 6.102-2.522 2.358-4.665 2.965-5.392 3.11a1.3 1.3 0 0 1-.53 0c-.728-.146-2.871-.752-5.393-3.11-1.772-1.656-2.676-4.404-2.676-6.102 0-2.84 1.801-5.142 4.447-5.142", fill: "#FF6F4D" }), React__default.createElement("path", { d: "M13.298 11.226v-.829a1.205 1.205 0 0 0-1.202-1.204h-.208a.26.26 0 0 1-.261-.259v-.208a1.205 1.205 0 0 0-1.201-1.204h-.832A1.205 1.205 0 0 0 8.39 8.726v.205a.26.26 0 0 1-.259.261h-.207a1.2 1.2 0 0 0-1.202 1.202v.834a1.204 1.204 0 0 0 1.202 1.201h.207a.26.26 0 0 1 .259.262v.205A1.205 1.205 0 0 0 9.594 14.1h.832a1.204 1.204 0 0 0 1.201-1.204v-.208a.26.26 0 0 1 .261-.258h.208a1.205 1.205 0 0 0 1.202-1.204", fill: "#fff" }))); const NavSaveIcon = (props) => (React__default.createElement("svg", Object.assign({ width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" }, props), React__default.createElement("path", { d: "M4.767 17.236a1.36 1.36 0 0 0 1.256.188l4.097-1.397a.37.37 0 0 1 .28 0l4.097 1.397q.22.071.45.075c.29.002.573-.09.807-.263a1.43 1.43 0 0 0 .6-1.171V3.935A1.417 1.417 0 0 0 14.946 2.5H5.573a1.416 1.416 0 0 0-1.406 1.434v12.13a1.43 1.43 0 0 0 .6 1.172", fill: "#00CB8A" }))); const NavSettingsIcon = (props) => (React__default.createElement("svg", Object.assign({ width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" }, props), React__default.createElement("path", { d: "M17.339 8.075a2.177 2.177 0 0 1-1.717-2.944 1.02 1.02 0 0 0-.305-1.15 8.2 8.2 0 0 0-2.445-1.417 1.03 1.03 0 0 0-1.16.323 2.173 2.173 0 0 1-3.423 0 1.03 1.03 0 0 0-1.161-.323A8.2 8.2 0 0 0 4.85 3.842a1.03 1.03 0 0 0-.322 1.183 2.167 2.167 0 0 1-1.806 2.978 1.03 1.03 0 0 0-.9.828 8 8 0 0 0-.05 2.861 1.03 1.03 0 0 0 .906.861 2.166 2.166 0 0 1 1.767 3.061 1.01 1.01 0 0 0 .283 1.211A8.2 8.2 0 0 0 7.15 18.22q.17.059.35.061a1.02 1.02 0 0 0 .833-.433 2.15 2.15 0 0 1 1.778-.934 2.18 2.18 0 0 1 1.745.878 1.02 1.02 0 0 0 1.2.339 8.3 8.3 0 0 0 2.222-1.328 1.03 1.03 0 0 0 .3-1.172 2.167 2.167 0 0 1 1.739-2.995 1.03 1.03 0 0 0 .872-.844 8 8 0 0 0 .144-1.405q0-.749-.138-1.484a1.02 1.02 0 0 0-.856-.828m-4.561 2.312a2.778 2.778 0 1 1-5.556 0 2.778 2.778 0 0 1 5.556 0", fill: "#2D87F3" }))); const NavUserIcon = (props) => (React__default.createElement("svg", Object.assign({ width: "20", height: "20", viewBox: "0 0 20 20", fill: "none" }, props), React__default.createElement("path", { d: "M10 19.167A9.167 9.167 0 1 0 10 .833a9.167 9.167 0 0 0 0 18.334", fill: "#BCDEFF" }), React__default.createElement("path", { d: "M17.356 15.463a9.188 9.188 0 0 0-14.716-.005 9.155 9.155 0 0 0 14.716.005", fill: "#2D87F3" }), React__default.createElement("path", { d: "M10 10.591a3.548 3.548 0 1 0 0-7.096 3.548 3.548 0 0 0 0 7.096", fill: "#2D87F3" }))); const StyledNavMenu = styled.div ` padding: 16px; border-radius: 16px; background-color: white; hr { border-color: ${theme.colors.neutral100}; border-bottom-width: 0px; border-style: solid; } .profile-nav-item-group { background-color: white; border-radius: 8px; } `; const StyledNavMenuItem = styled.div ` display: block; border: 1px solid transparent; transition: all 300ms linear; cursor: pointer; position: relative; ${(props) => props.hasSubmenu && css ` cursor: pointer; `} &[data-is-open='true'] { & + div { margin-top: 8px; } } border-left-width: 0; border-right-width: 0; &[data-is-open='true'] { & + div { margin-top: 0; } .nav-menu-item:last-child { border-bottom-color: ${theme.colors.neutral100}; } } .nav-menu-item { background-color: ${theme.colors.neutral50}; } .nav-menu-item { padding-left: 38px; } `; const StyledNavMenuItemContent = styled.div ` display: flex; align-items: center; height: 48px; border: 1px solid transparent; transition: all 300ms; border-radius: 8px; &:hover { background-color: ${theme.colors.neutral150}; } &[data-active='true'] { background-color: ${theme.colors.blue50}; } `; const StyledNavMenuItemDropdown = styled.div ` margin-left: auto; svg { fill: ${theme.colors.gray600}; transition: transform 300ms; } &[data-is-open='true'] svg { transform: rotate(180deg); } `; const StyledNavFooterSubMenu = styled.div ` overflow: hidden; max-height: 0; transition: max-height 0.3s ease-out; [data-is-open='true'] & { max-height: 500px; transition-timing-function: ease-in; } `; const rankIconUrlMap = { helloSites: { member: () => CommonGAssets.getAssetPath('userProfileNav/helloSites/icon-rank-member.svg'), ambassador: () => CommonGAssets.getAssetPath('userProfileNav/helloSites/icon-rank-ambassador.svg'), doctor: () => CommonGAssets.getAssetPath('userProfileNav/helloSites/icon-rank-doctor.svg'), expert: () => CommonGAssets.getAssetPath('userProfileNav/helloSites/icon-rank-expert.svg'), influencer: () => CommonGAssets.getAssetPath('userProfileNav/helloSites/icon-rank-influencer.svg'), }, marryBaby: { member: () => CommonGAssets.getAssetPath('userProfileNav/marryBaby/icon-rank-member.svg'), ambassador: () => CommonGAssets.getAssetPath('userProfileNav/marryBaby/icon-rank-ambassador.svg'), doctor: () => CommonGAssets.getAssetPath('userProfileNav/marryBaby/icon-rank-doctor.svg'), expert: () => CommonGAssets.getAssetPath('userProfileNav/marryBaby/icon-rank-expert.svg'), influencer: () => CommonGAssets.getAssetPath('userProfileNav/marryBaby/icon-rank-influencer.svg'), }, }; const Rank = ({ rank, siteType = 'helloSites', }) => { const iconUrl = useMemo(() => { var _a, _b; return ((_b = (_a = rankIconUrlMap[siteType]) === null || _a === void 0 ? void 0 : _a[rank]) === null || _b === void 0 ? void 0 : _b.call(_a)) || ''; }, [rank, siteType]); const { t } = useTranslations(); return (React__default.createElement("div", { style: { display: 'inline-flex', height: 'fit-content', alignItems: 'center', padding: '5px 12px', gap: '4px', borderRadius: 16, border: `1px solid ${siteType === 'helloSites' ? theme.colors.blue100 : theme.colors.mb100}`, } }, React__default.createElement("img", { src: iconUrl, alt: rank, style: { height: 16, width: 16, } }), React__default.createElement(Text, { size: "s5", color: "gray.8", weight: "semiBold" }, t(`userProfile.userRank.${rank}`)))); }; const UserInfoSection = ({ siteType = 'helloSites', userInfo, }) => { return (userInfo === null || userInfo === void 0 ? void 0 : userInfo.id) ? (React__default.createElement(React__default.Fragment, null, React__default.createElement("div", { style: { display: 'flex', width: '100%', justifyContent: 'space-between', } }, React__default.createElement(Avatar, { src: userInfo.avatar, alt: userInfo.name, size: 48, style: { marginBottom: 8 } }), React__default.createElement(Rank, { rank: "member", siteType: siteType })), React__default.createElement(Text, { size: "s3", weight: "semiBold", color: "gray.8", style: { marginBottom: 4 } }, userInfo.name), React__default.createElement(Text, { size: "n1", weight: "regular", color: siteType === 'helloSites' ? 'hb.6' : 'mb.6' }, "@", userInfo.username), React__default.createElement("hr", null))) : null; }; const ProfileNavigation = ({ className, activeItem: forceActiveItem, navMenuItems: navMenuItemsProp, style, onLogout, siteType = 'helloSites', userInfo, onNavigate, }) => { const { locale } = useTranslations(); const [localActiveItem, setLocalActiveItem] = useState(); const activeItem = typeof forceActiveItem === 'string' ? forceActiveItem : localActiveItem; const SSO_URL = normalizeLinkSlash(getCurrentSsoUrl(locale, siteType === 'marryBaby') + '/'); const BASE_URL = normalizeLinkSlash(getCurrentBaseUrl(locale, siteType === 'marryBaby') + '/'); const navMenuItems = navMenuItemsProp || [ [ { key: 'userProfile.nav.header.viewProfile', icon: React__default.createElement(NavUserIcon, { width: "24", height: "24" }), value: 'profile', tracking: { action: 'Profile Click', }, link: `${SSO_URL}user/profile/`, }, { key: 'userProfile.nav.card.myHealth', icon: React__default.createElement(NavMyHealthIcon, { width: "24", height: "24" }), value: 'myHealth', tracking: { action: 'My Health Click', }, link: `${SSO_URL}user/health/`, }, { key: 'userProfile.nav.card.mySaved', icon: React__default.createElement(NavSaveIcon, { width: "24", height: "24" }), iconColor: 'green_300', value: 'saved', tracking: { action: 'Bookmarks Click', }, link: `${SSO_URL}user/saved/`, }, { key: 'userProfile.nav.card.myBooking', icon: React__default.createElement(NavBookingIcon, { width: "24", height: "24" }), value: 'booking', disabled: !CARE_LOCALES.includes(locale), tracking: { action: 'Manage Booking Click', }, link: `${SSO_URL}user/booking/`, }, { key: 'userProfile.nav.card.myCommunity', icon: React__default.createElement(NavCommunityIcon, { width: "24", height: "24" }), value: 'myCommunities', disabled: !TOGETHER_LOCALES.includes(locale), tracking: { action: 'Community Click', }, link: `${SSO_URL}user/my-communities/`, }, ], ...(ECOM_LOCALES.includes(locale) ? [ [ { key: 'userProfile.nav.card.eCom', icon: React__default.createElement(NavEshopIcon, { width: "24", height: "24" }), value: 'eCom', disabled: !ECOM_LOCALES.includes(locale), subMenu: [ { key: 'userProfile.nav.card.ecom.manageOrders', value: 'eCom-manageOrders', icon: React__default.createElement(NavDotIcon, { width: "24", height: "24" }), link: `${BASE_URL}shop/ho-so/quan-li-don-hang/`, tracking: { action: 'Order Management Click', }, }, { key: 'userProfile.nav.card.ecom.DeliveryAddress', value: 'eCom-manageAddress', icon: React__default.createElement(NavDotIcon, { width: "24", height: "24" }), link: `${BASE_URL}shop/ho-so/dia-chi-giao-hang/`, tracking: { action: 'Address Management Click', }, }, { key: 'userProfile.nav.card.ecom.voucher', value: 'eCom-voucher', icon: React__default.createElement(NavDotIcon, { width: "24", height: "24" }), link: `${BASE_URL}shop/ho-so/khuyen-mai/`, tracking: { action: 'Voucher Click', }, }, // { // key: 'nav.card.memberCard', // value: 'eCom-memberCard', // icon: <NavDotIcon width="24" // height="24"/>, // link: routingHandler // .getLocalisedUrl('', 'PROFILE_MEMBER_CARD') // .toString(), // tracking: { // action: 'Member Card Click', // }, // }, ], }, ], ] : []), [ { key: 'userProfile.nav.menu.accountSettings', icon: React__default.createElement(NavSettingsIcon, { width: "24", height: "24" }), subMenu: [ // { // key: 'common.profileNavigator.newsletterSubscription', // value: 'subscription', // icon: <NavDotIcon width="24" height="24" />, // tracking: { action: 'Subscription Click' }, // link: `${SSO_URL}user/subscriptions/`, // disabled: locale !== 'vi-VN', // }, { key: 'userProfile.nav.menu.password', value: 'password', icon: React__default.createElement(NavDotIcon, { width: "24", height: "24" }), tracking: { action: 'Set Password Click' }, link: `${SSO_URL}user/password/`, }, { key: 'userProfile.nav.menu.disableAccount', value: 'disable-account', icon: React__default.createElement(NavDotIcon, { width: "24", height: "24" }), tracking: { action: 'Disable Account Click' }, link: `${SSO_URL}user/disable-account/`, }, ...(DATA_PRIVACY_LOCALES.includes(locale) ? [ { key: 'userProfile.nav.menu.dataPrivacy', value: 'data-privacy', icon: React__default.createElement(NavDotIcon, { width: "24", height: "24" }), tracking: { action: 'Data Privacy Click' }, link: `${SSO_URL}user/data-privacy/`, }, ] : []), ], }, ], [ { key: 'userProfile.nav.menu.help', icon: React__default.createElement(NavHelpIcon, { width: "24", height: "24" }), value: 'help', link: `${SSO_URL}user/help`, tracking: { action: 'Support Click', }, }, { key: 'userProfile.nav.menu.logout', icon: React__default.createElement(NavLogOutIcon, { width: "24", height: "24" }), value: 'logout', tracking: { action: 'Sign Out Click', }, }, ], ]; return (React__default.createElement(StyledNavMenu, { className: className, style: style }, React__default.createElement(UserInfoSection, { userInfo: userInfo, siteType: siteType }), navMenuItems.map((items, index) => (React__default.createElement(Fragment, { key: index }, React__default.createElement("div", { className: "profile-nav-item-group", key: index }, items.map((item) => (React__default.createElement(NavMenuItem, { key: item.key, item: item, activeKey: activeItem || '', onLogout: onLogout, onClick: () => setLocalActiveItem((k) => k === item.key ? undefined : item.key), siteType: siteType, onNavigate: onNavigate })))), index !== navMenuItems.length - 1 && React__default.createElement("hr", null)))))); }; const NavMenuItem = ({ item, activeKey, forceOpen, onLogout, onClick, siteType = 'helloSites', onNavigate, }) => { var _a, _b; const [localOpen, setLocalOpen] = useState(false); const currentUrl = useMemo(() => { if (typeof window !== 'undefined') { return window.location.href; } else return ''; }, []); if (item.disabled) { return null; } const { t } = useTranslations(); const hasChildActive = (_a = item.subMenu) === null || _a === void 0 ? void 0 : _a.some((subItem) => subItem.key === activeKey); const isActive = activeKey === item.key; useEffect(() => { if (hasChildActive || isActive) { setLocalOpen(true); } }, [hasChildActive, isActive]); const isOpen = typeof forceOpen === 'boolean' ? forceOpen : localOpen; return (React__default.createElement(StyledNavMenuItem, { as: !item.subMenu ? 'a' : undefined, "data-is-open": isOpen, key: item.key, hasSubmenu: !!item.subMenu, onClick: () => { onClick === null || onClick === void 0 ? void 0 : onClick(); if (item.subMenu && !forceOpen) { setLocalOpen((k) => !k); } else { if (item.value === 'logout') { onLogout === null || onLogout === void 0 ? void 0 : onLogout(); } else if (item.link) { if (onNavigate) { onNavigate(item.link); } else { window.location.href = item.link; } } } }, "data-event-category": "Ecommerce", "data-event-action": ((_b = item === null || item === void 0 ? void 0 : item.tracking) === null || _b === void 0 ? void 0 : _b.action) || '', "data-event-label": currentUrl }, React__default.createElement(StyledNavMenuItemContent, { "data-active": isActive }, item.icon, React__default.createElement(Text, { size: "p3", style: { marginLeft: item.icon ? 24 : 48, transition: `color 300ms`, }, color: isActive ? (siteType === 'helloSites' ? 'hb.6' : 'mb.6') : 'gray.8' }, t(item.key)), item.subMenu && (React__default.createElement(StyledNavMenuItemDropdown, { "data-is-open": isOpen }, React__default.createElement(ChevronDown, { width: 14 })))), item.subMenu && (React__default.createElement(StyledNavFooterSubMenu, null, item.subMenu.map((subItem) => (React__default.createElement(NavMenuItem, { key: subItem.key, item: subItem, activeKey: activeKey, onLogout: onLogout, siteType: siteType }))))))); }; export { ProfileNavigation };