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 | 520x 2129x 2129x 2129x 2129x 3924x 3924x 2129x 2129x 139x 3x 2129x 2129x 2014x 1x 1x | import { ReactElement } from "react";
import { useTranslation } from "react-i18next";
import { Link, useLocation } from "react-router";
import styled from "styled-components";
import { config } from "shared/config";
import { AboutTab } from "client/app/routes";
import { DismissibleBanner } from "client/components/DismissibleBanner";
import { RaisedCard } from "client/components/RaisedCard";
import { HighlightStyle } from "client/components/componentStyles";
import { useAppDispatch, useAppSelector } from "client/utils/hooks";
import { EventLogEventMessage } from "client/views/event-log/EventLogEventMessage";
import { submitUpdateEventLogIsSeen } from "client/views/login/loginThunks";
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 (
<DismissibleBanner
key={`${unseenEvent.action}-${unseenEvent.createdAt}`}
data-testid="notification-bar"
icon="bell"
highlightStyle={HighlightStyle.INFO}
dismissAriaLabel={t("iconAltText.closeNotification")}
onDismiss={() => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
dispatch(
submitUpdateEventLogIsSeen({
eventLogItemId: unseenEvent.eventLogItemId,
isSeen: true,
}),
);
}}
>
<div>
<EventLogEventMessage
eventLogItem={unseenEvent}
programItems={programItems}
showDetails={false}
/>
<ShowAllLinkContainer>
<Link to={"/notifications"}>{t("notificationBar.showAll")}</Link>
</ShowAllLinkContainer>
</div>
</DismissibleBanner>
);
});
Iif (config.client().showAboutPageInProgress) {
if (Object.values(AboutTab).includes(location.pathname as AboutTab)) {
// Nothing to dismiss here, so it renders as a plain notice card
notificationList.push(
<InProgressNotice
key="about-in-progress"
isHighlighted={true}
highlightStyle={HighlightStyle.INFO}
>
{t("aboutView.inProgress")}
</InProgressNotice>,
);
}
}
if (notificationList.length === 0) {
return null;
}
return <div>{notificationList}</div>;
};
const InProgressNotice = styled(RaisedCard)`
margin: 4px 0;
padding: 10px;
`;
const ShowAllLinkContainer = styled.div`
margin: 20px 0 0 0;
`;
|