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 | 356x 1458x 1458x 1458x 1458x 2634x 2634x 1458x 1458x 70x 1458x 1x 70x 70x 70x 70x 70x 1x 1x 1x | import { ReactElement } from "react";
import styled from "styled-components";
import { useTranslation } from "react-i18next";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Link, useLocation } from "react-router";
import { useAppDispatch, useAppSelector } from "client/utils/hooks";
import { HEADER_HEIGHT } from "client/components/Header";
import { submitUpdateEventLogIsSeen } from "client/views/login/loginThunks";
import { AboutTab } from "client/app/AppRoutes";
import { config } from "shared/config";
import { EventLogEventMessage } from "client/views/event-log/EventLogEventMessage";
export const NotificationBar = (): ReactElement | null => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const location = useLocation();
const programItems = useAppSelector(
(state) => state.allProgramItems.programItems,
);
const eventLogItems = useAppSelector((state) => state.login.eventLogItems);
const unseenEvents = eventLogItems.filter((item) => !item.isSeen);
const notificationList = unseenEvents.map((unseenEvent) => {
return (
<StyledNotification
key={`${unseenEvent.action}-${unseenEvent.createdAt}`}
data-testid="notification-bar"
>
<div>
<EventLogEventMessage
eventLogItem={unseenEvent}
programItems={programItems}
showDetails={false}
/>
<ShowAllLinkContainer>
<Link to={"/notifications"}>{t("notificationBar.showAll")}</Link>
</ShowAllLinkContainer>
</div>
<span>
<StyledFontAwesomeIcon
icon="xmark"
aria-label={t("iconAltText.closeNotification")}
onClick={() => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
dispatch(
submitUpdateEventLogIsSeen({
eventLogItemId: unseenEvent.eventLogItemId,
isSeen: true,
}),
);
}}
/>
</span>
</StyledNotification>
);
});
Iif (config.client().showAboutPageInProgress) {
if (Object.values(AboutTab).includes(location.pathname as AboutTab)) {
notificationList.push(
<StyledNotification key="about-in-progress">
{t("aboutView.inProgress")}
</StyledNotification>,
);
}
}
return <NotificationContainer>{notificationList}</NotificationContainer>;
};
const StyledNotification = styled.div`
display: flex;
justify-content: space-between;
padding: 10px;
background-color: ${(props) => props.theme.backgroundBody};
color: ${(props) => props.theme.textMain};
border-radius: 4px;
margin: 4px 0;
border: 1px solid ${(props) => props.theme.borderCardHighlight};
border-left: 5px solid ${(props) => props.theme.borderCardHighlight};
box-shadow: ${(props) => props.theme.shadowHigher};
`;
const NotificationContainer = styled.div`
position: sticky;
top: ${HEADER_HEIGHT}px;
z-index: 10;
margin: 0 8px 0 8px;
`;
const ShowAllLinkContainer = styled.div`
margin: 20px 0 0 0;
`;
const StyledFontAwesomeIcon = styled(FontAwesomeIcon)`
cursor: pointer;
`;
|