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 | 356x 6x 6x 6x 6x 6x 6x 6x 6x 356x 1x 1x 1x 1x 6x 1x 1x 3x 1x 3x | import { ReactElement, useEffect, useState } from "react";
import styled from "styled-components";
import { useTranslation } from "react-i18next";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { capitalize } from "remeda";
import {
formattedCurrentTime,
getTime,
getWeekdayAndTime,
} from "shared/utils/timeFormatter";
import { config } from "shared/config";
import { ProgramItem } from "shared/types/models/programItem";
import { RaisedCard } from "client/components/RaisedCard";
interface Props {
programItem: ProgramItem;
isSignedUp: boolean;
username: string;
}
export const Admission = ({
programItem,
isSignedUp,
username,
}: Props): ReactElement => {
const { t } = useTranslation();
const { eventName, eventYear } = config.event();
const formatTime = (): string => {
// Note that the dash should be an en dash
return `${capitalize(getWeekdayAndTime(programItem.startTime))}–${getTime(programItem.endTime)}`;
};
const [currentTime, setCurrentTime] = useState(new Date());
useEffect(() => {
const interval = setInterval(() => {
setCurrentTime(new Date());
}, 1000);
return () => {
clearInterval(interval);
};
}, []);
return (
<RaisedCard>
<TextContainer>
<Text>
{eventName} {eventYear}
</Text>
<TimeText>{formattedCurrentTime(currentTime)}</TimeText>
<BoldText>{programItem.title}</BoldText>
<Text>{formatTime()}</Text>
{isSignedUp && (
<>
<AdmissionIcon icon="circle-check" />
<Text>
{t("admissionView.admission")}
<b>{username}</b>.
</Text>
</>
)}
{!isSignedUp && (
<>
<NoAdmissionIcon icon="ban" />
<Text>{t("admissionView.noAdmission")}</Text>
</>
)}
</TextContainer>
</RaisedCard>
);
};
const textSize = "28px";
const TextContainer = styled.div`
text-align: center;
`;
const BoldText = styled.p`
font-size: ${textSize};
font-weight: 600;
margin-bottom: -16px;
`;
const Text = styled.p`
font-size: ${textSize};
`;
const TimeText = styled.p`
font-size: ${textSize};
margin-top: -16px;
color: ${(props) => props.theme.textSecondary};
`;
const StyledIcon = styled(FontAwesomeIcon)`
font-size: 48px;
`;
const AdmissionIcon = styled(StyledIcon)`
color: ${(props) => props.theme.iconDefault};
`;
const NoAdmissionIcon = styled(StyledIcon)`
color: ${(props) => props.theme.errorColorIcon};
`;
|