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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | 608x 1207x 1207x 2972x 1207x 1207x 1207x 1207x 1207x 1207x 1207x 1207x 1207x 1207x 1207x 1207x 1207x 1207x 1207x 4x 1203x 39x 1164x 766x 398x 395x | import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { ReactElement } from "react";
import { useTranslation } from "react-i18next";
import { ProgramItem } from "shared/types/models/programItem";
import { isDirectSignupAlwaysOpen } from "shared/utils/isDirectSignupAlwaysOpen";
import { isLotterySignupProgramItem } from "shared/utils/isLotterySignupProgramItem";
import {
getDirectSignupEndTime,
getDirectSignupEnded,
getDirectSignupInProgress,
getDirectSignupStartTime,
getLotterySignupEndTime,
getLotterySignupInProgress,
getLotterySignupNotStarted,
getLotterySignupStartTime,
hasLotteryAlreadyRun,
tooEarlyForLotterySignup,
willNotBeLotteried,
} from "shared/utils/signupTimes";
import { useAppSelector } from "client/utils/hooks";
import { useTimeFormatters } from "client/utils/useTimeFormatters";
import { useTimeNow } from "client/utils/useTimeNow";
import { getIsInGroup } from "client/views/group/groupUtils";
interface Props {
programItem: ProgramItem;
usesKonstiSignup: boolean;
}
export const SignupHelpText = ({
programItem,
usesKonstiSignup,
}: Props): ReactElement | null => {
const { t } = useTranslation();
const { getFormattedInterval, getFormattedTime } = useTimeFormatters();
const groupCode = useAppSelector((state) => state.group.groupCode);
const isInGroup = getIsInGroup(groupCode);
// Group members can sign up to always open program items without leaving the group
const groupMemberInfo =
isDirectSignupAlwaysOpen(programItem) && isInGroup ? (
<span> {t("signup.help.signupAlwaysOpenGroupMemberInfo")}</span>
) : null;
const timeNow = useTimeNow();
// Said out loud either way: an attendee seeing a future program item offer only direct
// sign-up has no other way to know why. The two causes read differently - one is about the
// starting time changing, the other about the program item having sign-ups already.
const noLotteryAhead = willNotBeLotteried(programItem);
const noLotteryInfo = noLotteryAhead ? (
<span>
{" "}
{t(
hasLotteryAlreadyRun(programItem)
? "signup.help.lotteryAlreadyRunInfo"
: "signup.help.notInLotteryInfo",
)}
</span>
) : null;
// Cannot use programItem.signupStrategy here since it's relative to time
const isLotterySignup =
isLotterySignupProgramItem(programItem) &&
!tooEarlyForLotterySignup(programItem) &&
!noLotteryAhead;
const lotterySignupStartTime = getLotterySignupStartTime(programItem);
const lotterySignupEndTime = getLotterySignupEndTime(programItem);
const lotterySignupNotStarted = getLotterySignupNotStarted(
programItem,
timeNow,
);
const lotterySignupInProgress = getLotterySignupInProgress(
programItem,
timeNow,
);
const directSignupEndTime = getDirectSignupEndTime(programItem);
const directSignupStartTime = getDirectSignupStartTime(programItem);
const directSignupInProgress = getDirectSignupInProgress(
programItem,
timeNow,
);
const directSignupEnded = getDirectSignupEnded(programItem, timeNow);
if (directSignupEnded) {
return null;
}
if (!usesKonstiSignup) {
// A revolving door item has no sign-up instructions to look up, so say how
// to take part here instead of pointing at the program details
const messageKey = programItem.revolvingDoor
? ("signup.revolvingDoorNoKonstiSignup" as const)
: (`signup.signupType.${programItem.signupType}` as const);
return (
<p>
{t(messageKey, {
PROGRAM_TYPE: t(`programTypeIllative.${programItem.programType}`),
})}
</p>
);
}
if (!isLotterySignup) {
if (!directSignupInProgress) {
return (
<p>
<FontAwesomeIcon icon={"user-plus"} />{" "}
{t("signup.help.directSignupStartsLater")}{" "}
<b>{getFormattedTime(directSignupStartTime, timeNow)}</b>.
{groupMemberInfo}
</p>
);
}
return (
<p>
<FontAwesomeIcon icon={"user-plus"} />{" "}
{t("signup.help.directSignupOpenNow")}{" "}
<b>{getFormattedTime(directSignupEndTime, timeNow)}</b>.{noLotteryInfo}
{groupMemberInfo}
</p>
);
}
// Lottery sign-up
if (lotterySignupNotStarted) {
// Waiting for sign up to start
return (
<p>
<FontAwesomeIcon icon={"dice-three"} />{" "}
{t("signup.help.lotterySignupStartsLater")}{" "}
<b>
{getFormattedInterval(
lotterySignupStartTime,
lotterySignupEndTime,
timeNow,
)}
</b>
. {t("signup.help.directSignupStarts")}{" "}
<b>
{getFormattedInterval(
directSignupStartTime,
directSignupEndTime,
timeNow,
)}
</b>
.
</p>
);
}
if (lotterySignupInProgress) {
// Lottery sign-up happening now
return (
<p>
<FontAwesomeIcon icon={"dice-three"} />{" "}
{t("signup.help.lotterySignupOpen")}{" "}
<b>{getFormattedTime(lotterySignupEndTime, timeNow)}</b>.{" "}
{t("signup.help.directSignupStarts")}{" "}
<b>
{getFormattedInterval(
directSignupStartTime,
directSignupEndTime,
timeNow,
)}
</b>
.
</p>
);
}
return (
// Lottery sign-up ended, direct sign-up starting or started
<p>
<FontAwesomeIcon icon={"dice-three"} />{" "}
{t("signup.help.lotterySignupEnded")}{" "}
{t("signup.help.directSignupStarts")}{" "}
<b>
{getFormattedInterval(
directSignupStartTime,
directSignupEndTime,
timeNow,
)}
</b>
.
</p>
);
};
|