Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | 520x 198x 395x 395x 198x 395x 198x 1x 1021x 1021x 1021x 1021x 1021x 1x 1x 1x 3x 3x 1x 3x 3x | import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { ReactElement } from "react";
import { useTranslation } from "react-i18next";
import { NavLink } from "react-router";
import styled from "styled-components";
import { config } from "shared/config";
import { EventSignupStrategy } from "shared/config/eventConfigTypes";
import { AppRoute } from "client/app/routes";
import { isAdmin, isAdminOrHelper, isUser } from "client/utils/checkUserGroup";
import { useAppSelector } from "client/utils/hooks";
export const LoggedInUserNavigation = (props: {
onSelect: () => void;
}): ReactElement => {
const { t } = useTranslation();
const userGroup = useAppSelector((state) => state.login.userGroup);
const eventLogItems = useAppSelector((state) => state.login.eventLogItems);
const unseenEvents = eventLogItems.filter((item) => !item.isSeen);
const signupStrategy = useAppSelector((state) => state.admin.signupStrategy);
const directSignup = signupStrategy === EventSignupStrategy.DIRECT;
return (
<StyledRoutes>
<RouterLink onClick={props.onSelect} to={AppRoute.PROGRAM}>
{t("pages.program")}
</RouterLink>
{!directSignup && isUser(userGroup) && (
<RouterLink onClick={props.onSelect} to={AppRoute.NOTIFICATIONS}>
{t("pages.notifications")}
{unseenEvents.length > 0 && (
<EventNumberContainer
className="fa-layers fa-fw"
aria-label={t("iconAltText.newNotifications")}
>
<EventNumberIcon icon="circle" className="fa-stack-1x" />
<EventNumber className="fa-stack-1x">
{unseenEvents.length}
</EventNumber>
</EventNumberContainer>
)}
</RouterLink>
)}
{isUser(userGroup) && config.event().enableGroups && (
<RouterLink
onClick={props.onSelect}
to={AppRoute.PROFILE}
data-testid={"link-profile"}
>
{t("pages.profileAndGroup")}
</RouterLink>
)}
{isUser(userGroup) && !config.event().enableGroups && (
<RouterLink
onClick={props.onSelect}
to={AppRoute.PROFILE}
data-testid={"link-profile"}
>
{t("pages.profile")}
</RouterLink>
)}
{isAdminOrHelper(userGroup) && (
<>
<RouterLink onClick={props.onSelect} to={AppRoute.HELPER}>
{t("button.helper")}
</RouterLink>
<RouterLink onClick={props.onSelect} to={AppRoute.PROFILE}>
{t("pages.profile")}
</RouterLink>
</>
)}
{isAdmin(userGroup) && (
<RouterLink onClick={props.onSelect} to={AppRoute.ADMIN}>
{t("pages.admin")}
</RouterLink>
)}
<RouterLink onClick={props.onSelect} to={AppRoute.ABOUT}>
{t("pages.help")}
</RouterLink>
<RouterLink onClick={props.onSelect} to={AppRoute.LOGOUT}>
{t("button.logout")}
</RouterLink>
</StyledRoutes>
);
};
const RouterLink = styled(NavLink)`
position: relative;
display: inline-block;
padding: 10px 12px 10px 12px;
font-size: ${(props) => props.theme.fontSizeLink};
text-decoration: none;
color: ${(props) => props.theme.textMain};
border-bottom: 1px solid ${(props) => props.theme.borderNavigation};
/* Touch devices emulate :hover on tap and keep it active after the tap,
so only style hover when the device can actually hover */
@media (hover: hover) {
&:hover,
&:focus {
background: ${(props) => props.theme.backgroundHover};
}
}
&:focus,
&.active {
background: ${(props) => props.theme.backgroundSelected};
}
`;
const StyledRoutes = styled.div`
display: flex;
flex-direction: column;
`;
const EventNumberContainer = styled.span`
margin: 0 0 0 6px;
vertical-align: text-bottom;
`;
const EventNumberIcon = styled(FontAwesomeIcon)`
color: ${(props) => props.theme.iconDefault};
font-size: ${(props) => props.theme.iconSizeLarge};
`;
const EventNumber = styled.span`
color: ${(props) => props.theme.buttonPrimaryText};
font-size: ${(props) => props.theme.iconSizeSmall};
left: 7px;
top: 1px;
`;
|