Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hum 39 click on human app logo should redirect to default page #2678

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { NAVBAR_PADDING } from '@/components/layout/protected/navbar';
import { colorPalette } from '@/styles/color-palette';
import { useColorMode } from '@/hooks/use-color-mode';
import { onlyDarkModeColor } from '@/styles/dark-color-palette';
import { useHandleMainNavIconClick } from '@/hooks/use-handle-main-nav-icon-click';

const drawerWidth = 240;

Expand Down Expand Up @@ -49,6 +50,7 @@ export function DrawerNavigation({
const navigate = useNavigate();
const isMobile = useIsMobile();
const location = useLocation();
const handleMainNavIconClick = useHandleMainNavIconClick();

return (
<Box
Expand All @@ -72,7 +74,13 @@ export function DrawerNavigation({
variant="persistent"
>
{!isMobile && (
<Stack alignItems="flex-start" sx={{ paddingLeft: '26px' }}>
<Stack
alignItems="flex-start"
sx={{ paddingLeft: '60px', cursor: 'pointer' }}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be 60px?

Looks a bit too much in comparison to design
Screenshot 2024-10-25 at 18 47 08
Screenshot 2024-10-25 at 18 47 40

onClick={() => {
handleMainNavIconClick();
}}
>
<HumanLogoNavbarIcon />
</Stack>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useIsMobile } from '@/hooks/use-is-mobile';
import { Button } from '@/components/ui/button';
import { useIsHCaptchaLabelingPage } from '@/hooks/use-is-hcaptcha-labeling-page';
import { useColorMode } from '@/hooks/use-color-mode';
import { useHandleMainNavIconClick } from '@/hooks/use-handle-main-nav-icon-click';

export const NAVBAR_PADDING = '16px';

Expand All @@ -23,6 +24,7 @@ export function Navbar({
userStatsDrawerOpen,
toggleUserStatsDrawer,
}: NavbarProps) {
const handleMainNavIconClick = useHandleMainNavIconClick();
const { colorPalette } = useColorMode();
const isMobile = useIsMobile();
const isHCaptchaLabelingPage = useIsHCaptchaLabelingPage();
Expand Down Expand Up @@ -79,9 +81,20 @@ export function Navbar({
top: open ? '0' : 'unset',
}}
>
<Stack sx={{ paddingLeft: '8px' }}>
<Grid
sx={{ cursor: 'pointer', paddingLeft: '8px' }}
onClick={() => {
if (isMobile) {
setOpen(false);
}
handleMainNavIconClick();
}}
role="button"
tabIndex={0}
aria-hidden="true"
>
<HumanLogoIcon />
</Stack>
</Grid>
<Grid
sx={{
display: 'flex',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState } from 'react';
import { Box, Drawer, IconButton } from '@mui/material';
import { Box, Drawer, Grid, IconButton } from '@mui/material';
import { useTranslation } from 'react-i18next';
import MenuIcon from '@mui/icons-material/Menu';
import { Link } from 'react-router-dom';
Expand All @@ -10,6 +10,7 @@ import { breakpoints } from '@/styles/breakpoints';
import { env } from '@/shared/env';
import { useHomePageState } from '@/contexts/homepage-state';
import { DarkModeSwitch } from '@/components/ui/dark-mode-switch';
import { useHandleMainNavIconClick } from '@/hooks/use-handle-main-nav-icon-click';

interface NavbarProps {
withNavigation: boolean;
Expand All @@ -20,6 +21,7 @@ export function Navbar({ withNavigation }: NavbarProps) {
const { t } = useTranslation();
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
const isMobile = useIsMobile();
const handleMainNavIconClick = useHandleMainNavIconClick();

return (
<Box
Expand All @@ -40,7 +42,17 @@ export function Navbar({ withNavigation }: NavbarProps) {
},
}}
>
{isMobile ? <HumanLogoIcon /> : <HumanLogoNavbarIcon />}
<Grid
sx={{ cursor: 'pointer' }}
onClick={() => {
handleMainNavIconClick();
}}
role="button"
tabIndex={0}
aria-hidden="true"
>
{isMobile ? <HumanLogoIcon /> : <HumanLogoNavbarIcon />}
</Grid>
{withNavigation ? (
<Box
sx={{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useNavigate } from 'react-router-dom';
import { useWeb3Auth } from '@/auth-web3/use-web3-auth';
import { useAuth } from '@/auth/use-auth';
import { useHomePageState } from '@/contexts/homepage-state';
import { routerPaths } from '@/router/router-paths';

export const useHandleMainNavIconClick = () => {
const navigate = useNavigate();
const { user: web3User } = useWeb3Auth();
const { user: web2Auth } = useAuth();
const { setPageView } = useHomePageState();

const handleIconClick = () => {
if (web3User) {
navigate(routerPaths.operator.profile);
return;
}

if (web2Auth) {
navigate(routerPaths.worker.profile);
return;
}
setPageView('welcome');
navigate(routerPaths.homePage);
};

return handleIconClick;
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import { AvailableJobsNetworkFilterMobile } from '@/pages/worker/jobs/components
import { AvailableJobsStatusFilterMobile } from '@/pages/worker/jobs/components/available-jobs/mobile/available-jobs-status-filter-mobile';
import { AvailableJobsJobTypeFilterMobile } from '@/pages/worker/jobs/components/available-jobs/mobile/available-jobs-job-type-filter-mobile';
import { useColorMode } from '@/hooks/use-color-mode';
import { useHandleMainNavIconClick } from '@/hooks/use-handle-main-nav-icon-click';

interface DrawerMobileProps {
setIsMobileFilterDrawerOpen: Dispatch<SetStateAction<boolean>>;
}
export function AvailableJobsDrawerMobile({
setIsMobileFilterDrawerOpen,
}: DrawerMobileProps) {
const handleMainNavIconClick = useHandleMainNavIconClick();
const { colorPalette } = useColorMode();
const { t } = useTranslation();
const { setFilterParams, filterParams } = useJobsFilterStore();
Expand Down Expand Up @@ -58,7 +60,14 @@ export function AvailableJobsDrawerMobile({
zIndex: '999999',
}}
>
<HumanLogoIcon />
<Stack
sx={{ cursor: 'pointer' }}
onClick={() => {
handleMainNavIconClick();
}}
>
<HumanLogoIcon />
</Stack>

<IconButton
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Button } from '@/components/ui/button';
import { HumanLogoIcon, SortArrow } from '@/components/ui/icons';
import { useMyJobsFilterStore } from '@/hooks/use-my-jobs-filter-store';
import { useColorMode } from '@/hooks/use-color-mode';
import { useHandleMainNavIconClick } from '@/hooks/use-handle-main-nav-icon-click';
import { MyJobsNetworkFilterMobile } from './my-jobs-network-filter-mobile';
import { MyJobsJobTypeFilterMobile } from './my-jobs-job-type-filter-mobile';
import { MyJobsStatusFilterMobile } from './my-jobs-status-filter-mobile';
Expand All @@ -20,6 +21,7 @@ interface DrawerMobileProps {
export function MyJobsDrawerMobile({
setIsMobileFilterDrawerOpen,
}: DrawerMobileProps) {
const handleMainNavIconClick = useHandleMainNavIconClick();
const { colorPalette } = useColorMode();
const { t } = useTranslation();
const { setFilterParams, filterParams } = useMyJobsFilterStore();
Expand Down Expand Up @@ -58,7 +60,15 @@ export function MyJobsDrawerMobile({
zIndex: '999999',
}}
>
<HumanLogoIcon />
<Stack
sx={{ cursor: 'pointer' }}
onClick={() => {
handleMainNavIconClick();
// setIsMobileFilterDrawerOpen(false);
}}
>
<HumanLogoIcon />
</Stack>

<IconButton
onClick={() => {
Expand Down