|
1 | 1 | import {Avatar, Menu, UnstyledButton} from "@mantine/core";
|
2 | 2 | import {getInitials} from "../../../utilites/helpers.ts";
|
3 |
| -import {IconLifebuoy, IconLogout, IconSettingsCog, IconSpeakerphone, IconUser} from "@tabler/icons-react"; |
| 3 | +import {IconLifebuoy, IconLogout, IconSettingsCog, IconUser,} from "@tabler/icons-react"; |
4 | 4 | import {useGetMe} from "../../../queries/useGetMe.ts";
|
5 | 5 | import {NavLink} from "react-router-dom";
|
6 | 6 | import {t} from "@lingui/macro";
|
7 | 7 | import {authClient} from "../../../api/auth.client.ts";
|
| 8 | +import {useDisclosure} from "@mantine/hooks"; |
| 9 | +import {AboutModal} from "../../modals/AboutModal/index.tsx"; |
| 10 | +import {getConfig} from "../../../utilites/config.ts"; |
8 | 11 |
|
9 | 12 | export const GlobalMenu = () => {
|
10 | 13 | const {data: me} = useGetMe();
|
| 14 | + const [aboutModalOpen, {open: openAboutModal, close: closeAboutModal}] = |
| 15 | + useDisclosure(false); |
11 | 16 |
|
12 | 17 | const links = [
|
13 | 18 | {
|
14 | 19 | label: t`My Profile`,
|
15 | 20 | icon: IconUser,
|
16 |
| - link: '/manage/profile', |
| 21 | + link: "/manage/profile", |
17 | 22 | },
|
18 | 23 | {
|
19 | 24 | label: t`Account Settings`,
|
20 | 25 | icon: IconSettingsCog,
|
21 | 26 | link: `/account/settings`,
|
22 | 27 | },
|
23 |
| - { |
24 |
| - label: t`Help & Support`, |
25 |
| - icon: IconLifebuoy, |
26 |
| - link: 'https://hi.events/docs?utm_source=app-top-menu-help-support', |
27 |
| - target: '_blank', |
28 |
| - }, |
29 |
| - { |
30 |
| - label: t`Feedback`, |
31 |
| - icon: IconSpeakerphone, |
32 |
| - link: 'mailto:[email protected]?subject=Feedback', |
33 |
| - target: '_blank', |
34 |
| - }, |
35 | 28 | {
|
36 | 29 | label: t`Logout`,
|
37 | 30 | icon: IconLogout,
|
38 | 31 | onClick: (event: any) => {
|
39 | 32 | event.preventDefault();
|
40 | 33 | authClient.logout();
|
41 |
| - localStorage.removeItem('token'); |
42 |
| - window.location.href = '/auth/login'; |
43 |
| - } |
44 |
| - } |
| 34 | + localStorage.removeItem("token"); |
| 35 | + window.location.href = "/auth/login"; |
| 36 | + }, |
| 37 | + }, |
45 | 38 | ];
|
46 | 39 |
|
| 40 | + if (!getConfig("VITE_HIDE_ABOUT_LINK")) { |
| 41 | + links.push({ |
| 42 | + label: `About & Support`, |
| 43 | + icon: IconLifebuoy, |
| 44 | + onClick: openAboutModal, |
| 45 | + }); |
| 46 | + } |
| 47 | + |
47 | 48 | return (
|
48 |
| - <Menu shadow="md" width={200}> |
49 |
| - <Menu.Target> |
50 |
| - <UnstyledButton> |
51 |
| - <Avatar color={'pink'} radius="xl"> |
52 |
| - {me |
53 |
| - ? getInitials(me.first_name + ' ' + me.last_name) |
54 |
| - : '..'} |
55 |
| - </Avatar> |
56 |
| - </UnstyledButton> |
57 |
| - </Menu.Target> |
| 49 | + <> |
| 50 | + <Menu shadow="md" width={200}> |
| 51 | + <Menu.Target> |
| 52 | + <UnstyledButton> |
| 53 | + <Avatar color={"pink"} radius="xl"> |
| 54 | + {me ? getInitials(me.first_name + " " + me.last_name) : ".."} |
| 55 | + </Avatar> |
| 56 | + </UnstyledButton> |
| 57 | + </Menu.Target> |
58 | 58 |
|
59 |
| - <Menu.Dropdown> |
60 |
| - {links.map((link) => { |
61 |
| - return ( |
62 |
| - <NavLink onClick={link.onClick} to={link.link ?? '#'} key={link.label} |
63 |
| - target={link.target ?? ''}> |
64 |
| - <Menu.Item component={'div'} leftSection={<link.icon/>}>{link.label}</Menu.Item> |
| 59 | + <Menu.Dropdown> |
| 60 | + {links.map((link) => ( |
| 61 | + <NavLink |
| 62 | + onClick={link.onClick} |
| 63 | + to={link.link ?? "#"} |
| 64 | + key={link.label} |
| 65 | + target={link.target ?? ""} |
| 66 | + > |
| 67 | + <Menu.Item component={"div"} leftSection={<link.icon/>}> |
| 68 | + {link.label} |
| 69 | + </Menu.Item> |
65 | 70 | </NavLink>
|
66 |
| - ); |
67 |
| - })} |
68 |
| - </Menu.Dropdown> |
69 |
| - </Menu> |
| 71 | + ))} |
| 72 | + </Menu.Dropdown> |
| 73 | + </Menu> |
| 74 | + {aboutModalOpen && <AboutModal onClose={closeAboutModal}/>} |
| 75 | + </> |
70 | 76 | );
|
71 |
| -} |
| 77 | +}; |
0 commit comments