Skip to content

Commit c536638

Browse files
[Human App] HUM-39: click on logo redirects to home page (#2678)
1 parent 1cac147 commit c536638

File tree

6 files changed

+87
-8
lines changed

6 files changed

+87
-8
lines changed

packages/apps/human-app/frontend/src/components/layout/protected/drawer-navigation.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { NAVBAR_PADDING } from '@/components/layout/protected/navbar';
1616
import { colorPalette } from '@/styles/color-palette';
1717
import { useColorMode } from '@/hooks/use-color-mode';
1818
import { onlyDarkModeColor } from '@/styles/dark-color-palette';
19+
import { useHandleMainNavIconClick } from '@/hooks/use-handle-main-nav-icon-click';
1920

2021
const drawerWidth = 240;
2122

@@ -49,6 +50,7 @@ export function DrawerNavigation({
4950
const navigate = useNavigate();
5051
const isMobile = useIsMobile();
5152
const location = useLocation();
53+
const handleMainNavIconClick = useHandleMainNavIconClick();
5254

5355
return (
5456
<Box
@@ -72,7 +74,13 @@ export function DrawerNavigation({
7274
variant="persistent"
7375
>
7476
{!isMobile && (
75-
<Stack alignItems="flex-start" sx={{ paddingLeft: '26px' }}>
77+
<Stack
78+
alignItems="flex-start"
79+
sx={{ paddingLeft: '26px', cursor: 'pointer' }}
80+
onClick={() => {
81+
handleMainNavIconClick();
82+
}}
83+
>
7684
<HumanLogoNavbarIcon />
7785
</Stack>
7886
)}

packages/apps/human-app/frontend/src/components/layout/protected/navbar.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useIsMobile } from '@/hooks/use-is-mobile';
77
import { Button } from '@/components/ui/button';
88
import { useIsHCaptchaLabelingPage } from '@/hooks/use-is-hcaptcha-labeling-page';
99
import { useColorMode } from '@/hooks/use-color-mode';
10+
import { useHandleMainNavIconClick } from '@/hooks/use-handle-main-nav-icon-click';
1011

1112
export const NAVBAR_PADDING = '16px';
1213

@@ -23,6 +24,7 @@ export function Navbar({
2324
userStatsDrawerOpen,
2425
toggleUserStatsDrawer,
2526
}: NavbarProps) {
27+
const handleMainNavIconClick = useHandleMainNavIconClick();
2628
const { colorPalette } = useColorMode();
2729
const isMobile = useIsMobile();
2830
const isHCaptchaLabelingPage = useIsHCaptchaLabelingPage();
@@ -79,9 +81,20 @@ export function Navbar({
7981
top: open ? '0' : 'unset',
8082
}}
8183
>
82-
<Stack sx={{ paddingLeft: '8px' }}>
84+
<Grid
85+
sx={{ cursor: 'pointer', paddingLeft: '8px' }}
86+
onClick={() => {
87+
if (isMobile) {
88+
setOpen(false);
89+
}
90+
handleMainNavIconClick();
91+
}}
92+
role="button"
93+
tabIndex={0}
94+
aria-hidden="true"
95+
>
8396
<HumanLogoIcon />
84-
</Stack>
97+
</Grid>
8598
<Grid
8699
sx={{
87100
display: 'flex',

packages/apps/human-app/frontend/src/components/layout/unprotected/navbar.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from 'react';
2-
import { Box, Drawer, IconButton } from '@mui/material';
2+
import { Box, Drawer, Grid, IconButton } from '@mui/material';
33
import { useTranslation } from 'react-i18next';
44
import MenuIcon from '@mui/icons-material/Menu';
55
import { Link } from 'react-router-dom';
@@ -10,6 +10,7 @@ import { breakpoints } from '@/styles/breakpoints';
1010
import { env } from '@/shared/env';
1111
import { useHomePageState } from '@/contexts/homepage-state';
1212
import { DarkModeSwitch } from '@/components/ui/dark-mode-switch';
13+
import { useHandleMainNavIconClick } from '@/hooks/use-handle-main-nav-icon-click';
1314

1415
interface NavbarProps {
1516
withNavigation: boolean;
@@ -20,6 +21,7 @@ export function Navbar({ withNavigation }: NavbarProps) {
2021
const { t } = useTranslation();
2122
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
2223
const isMobile = useIsMobile();
24+
const handleMainNavIconClick = useHandleMainNavIconClick();
2325

2426
return (
2527
<Box
@@ -40,7 +42,17 @@ export function Navbar({ withNavigation }: NavbarProps) {
4042
},
4143
}}
4244
>
43-
{isMobile ? <HumanLogoIcon /> : <HumanLogoNavbarIcon />}
45+
<Grid
46+
sx={{ cursor: 'pointer' }}
47+
onClick={() => {
48+
handleMainNavIconClick();
49+
}}
50+
role="button"
51+
tabIndex={0}
52+
aria-hidden="true"
53+
>
54+
{isMobile ? <HumanLogoIcon /> : <HumanLogoNavbarIcon />}
55+
</Grid>
4456
{withNavigation ? (
4557
<Box
4658
sx={{
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { useNavigate } from 'react-router-dom';
2+
import { useWeb3Auth } from '@/auth-web3/use-web3-auth';
3+
import { useAuth } from '@/auth/use-auth';
4+
import { useHomePageState } from '@/contexts/homepage-state';
5+
import { routerPaths } from '@/router/router-paths';
6+
7+
export const useHandleMainNavIconClick = () => {
8+
const navigate = useNavigate();
9+
const { user: web3User } = useWeb3Auth();
10+
const { user: web2Auth } = useAuth();
11+
const { setPageView } = useHomePageState();
12+
13+
const handleIconClick = () => {
14+
if (web3User) {
15+
navigate(routerPaths.operator.profile);
16+
return;
17+
}
18+
19+
if (web2Auth) {
20+
navigate(routerPaths.worker.profile);
21+
return;
22+
}
23+
setPageView('welcome');
24+
navigate(routerPaths.homePage);
25+
};
26+
27+
return handleIconClick;
28+
};

packages/apps/human-app/frontend/src/pages/worker/jobs/components/available-jobs/mobile/available-jobs-drawer-mobile.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ import type { Dispatch, SetStateAction } from 'react';
88
import { HumanLogoIcon } from '@/components/ui/icons';
99
import { AvailableJobsNetworkFilterMobile } from '@/pages/worker/jobs/components/available-jobs/mobile/available-jobs-network-filter-mobile';
1010
import { AvailableJobsStatusFilterMobile } from '@/pages/worker/jobs/components/available-jobs/mobile/available-jobs-status-filter-mobile';
11+
import { useHandleMainNavIconClick } from '@/hooks/use-handle-main-nav-icon-click';
1112
import { AvailableJobsJobTypeFilterMobile } from '@/pages/worker/jobs/components/available-jobs/mobile/available-jobs-job-type-filter-mobile';
12-
import { useColorMode } from '@/hooks/use-color-mode';
1313
import { AvailableJobsRewardAmountSortMobile } from '@/pages/worker/jobs/components/available-jobs/mobile/available-jobs-reward-amount-sort-mobile';
14+
import { useColorMode } from '@/hooks/use-color-mode';
1415

1516
interface DrawerMobileProps {
1617
setIsMobileFilterDrawerOpen: Dispatch<SetStateAction<boolean>>;
1718
}
1819
export function AvailableJobsDrawerMobile({
1920
setIsMobileFilterDrawerOpen,
2021
}: DrawerMobileProps) {
22+
const handleMainNavIconClick = useHandleMainNavIconClick();
2123
const { colorPalette } = useColorMode();
2224
const { t } = useTranslation();
2325

@@ -55,7 +57,14 @@ export function AvailableJobsDrawerMobile({
5557
zIndex: '999999',
5658
}}
5759
>
58-
<HumanLogoIcon />
60+
<Stack
61+
sx={{ cursor: 'pointer' }}
62+
onClick={() => {
63+
handleMainNavIconClick();
64+
}}
65+
>
66+
<HumanLogoIcon />
67+
</Stack>
5968

6069
<IconButton
6170
onClick={() => {

packages/apps/human-app/frontend/src/pages/worker/jobs/components/my-jobs/mobile/my-jobs-drawer-mobile.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { HumanLogoIcon } from '@/components/ui/icons';
99
import { useColorMode } from '@/hooks/use-color-mode';
1010
import { MyJobsRewardAmountSortMobile } from '@/pages/worker/jobs/components/my-jobs/mobile/my-jobs-reward-amount-sort-mobile';
1111
import { MyJobsExpiresAtSortMobile } from '@/pages/worker/jobs/components/my-jobs/mobile/my-jobs-expires-at-sort-mobile';
12+
import { useHandleMainNavIconClick } from '@/hooks/use-handle-main-nav-icon-click';
1213
import { MyJobsNetworkFilterMobile } from './my-jobs-network-filter-mobile';
1314
import { MyJobsJobTypeFilterMobile } from './my-jobs-job-type-filter-mobile';
1415
import { MyJobsStatusFilterMobile } from './my-jobs-status-filter-mobile';
@@ -19,6 +20,7 @@ interface DrawerMobileProps {
1920
export function MyJobsDrawerMobile({
2021
setIsMobileFilterDrawerOpen,
2122
}: DrawerMobileProps) {
23+
const handleMainNavIconClick = useHandleMainNavIconClick();
2224
const { colorPalette } = useColorMode();
2325
const { t } = useTranslation();
2426

@@ -56,7 +58,14 @@ export function MyJobsDrawerMobile({
5658
zIndex: '999999',
5759
}}
5860
>
59-
<HumanLogoIcon />
61+
<Stack
62+
sx={{ cursor: 'pointer' }}
63+
onClick={() => {
64+
handleMainNavIconClick();
65+
}}
66+
>
67+
<HumanLogoIcon />
68+
</Stack>
6069

6170
<IconButton
6271
onClick={() => {

0 commit comments

Comments
 (0)