Skip to content
Open
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
48 changes: 45 additions & 3 deletions frontend/src/bundles/common/components/logo/logo.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import logoSvg from '~/assets/img/logo/logo.svg';
import logoLabelSvg from '~/assets/img/logo/logo-label.svg';
import { AppRoute } from '~/bundles/common/enums/enums.js';
import { getValidClassNames } from '~/bundles/common/helpers/helpers.js';
import { AppRoute, UserRole } from '~/bundles/common/enums/enums.js';
import {
configureString,
getValidClassNames,
} from '~/bundles/common/helpers/helpers.js';
import { type RootReducer } from '~/framework/store/store.js';

import {
useAppSelector,
useEffect,
useLocation,
useState,
} from '../../hooks/hooks.js';
import { Grid, Link } from '../components.js';
import styles from './styles.module.scss';

Expand Down Expand Up @@ -48,11 +58,43 @@ const Logo: React.FC<Properties> = ({
isCollapsed = false,
hasLink = false,
}) => {
const { pathname } = useLocation();
const role = useAppSelector(
(state: RootReducer) => state.auth.currentUser?.role,
);
const [isProfileDisabled, setIsProfileDisabled] = useState<boolean>(true);

let logoLink = '';

switch (role) {
case UserRole.TALENT: {
logoLink = configureString('/:role/my/profile', { role });
break;
}
case UserRole.EMPLOYER: {
logoLink = AppRoute.CANDIDATES;
break;
}
case UserRole.ADMIN: {
logoLink = AppRoute.ADMIN_VERIFICATIONS_PANEL;
break;
}
default: {
break;
}
}

useEffect(() => {
pathname.includes('onboarding') && !pathname.includes('preview')
? setIsProfileDisabled(true)
: setIsProfileDisabled(false);
}, [pathname]);

return (
<Grid container alignItems="center" justifyContent="center">
{hasLink ? (
<Link
to={AppRoute.ROOT}
to={isProfileDisabled ? AppRoute.SAME_PAGE : logoLink}
className={getValidClassNames(styles.logo, className)}
>
<BaseLogo isCollapsed={isCollapsed} />
Expand Down