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 | import { Backdrop, styled } from "@mui/material";
import Alert from "components/Alert";
import CenteredSpinner from "components/CenteredSpinner/CenteredSpinner";
import HtmlMeta from "components/HtmlMeta";
import PageTitle from "components/PageTitle";
import Redirect from "components/Redirect";
import TextBody from "components/TextBody";
import { useAuthContext } from "features/auth/AuthProvider";
import CommunityGuidelinesSection from "features/auth/jail/CommunityGuidelinesSection";
import LocationSection from "features/auth/jail/LocationSection";
import TOSSection from "features/auth/jail/TOSSection";
import { useTranslation } from "i18n";
import { AUTH } from "i18n/namespaces";
import { JailInfoRes } from "proto/jail_pb";
import React, { useEffect, useState } from "react";
import { loginRoute } from "routes";
import { service } from "service";
import ActivenessProbeSection from "./ActivenessProbeSection";
import ModNoteSection from "./ModNoteSection";
const StyledContainer = styled("div")(({ theme }) => ({
marginBottom: theme.spacing(4),
}));
export default function Jail() {
const { t } = useTranslation(AUTH);
const { authState, authActions } = useAuthContext();
const isJailed = authState.jailed;
const authError = authState.error;
const authLoading = authState.loading;
const isAuthenticated = authState.authenticated;
const [loading, setLoading] = useState(false);
const [jailInfo, setJailInfo] = useState<null | JailInfoRes.AsObject>(null);
useEffect(() => {
(async () => {
//just in case the store is stale
authActions.updateJailStatus();
setLoading(true);
setJailInfo(await service.jail.getJailInfo());
setLoading(false);
})();
}, [authActions]);
const updateJailed = () => {
authActions.updateJailStatus();
};
if (!isAuthenticated) return <Redirect to={loginRoute} />;
return (
<>
{!isJailed && <Redirect to="/" />}
<HtmlMeta title={t("jail.title")} />
<PageTitle>{t("jail.title")}</PageTitle>
{authError && <Alert severity="error">{authError}</Alert>}
<StyledContainer>
<TextBody>{t("jail.description")}</TextBody>
</StyledContainer>
<Backdrop open={loading || authLoading}>
<CenteredSpinner />
</Backdrop>
{jailInfo?.hasNotAcceptedTos && (
<StyledContainer>
<TOSSection updateJailed={updateJailed} />
</StyledContainer>
)}
{jailInfo?.hasPendingModNotes && (
<StyledContainer>
<ModNoteSection
updateJailed={updateJailed}
pendingModNotes={jailInfo.pendingModNotesList}
/>
</StyledContainer>
)}
{jailInfo?.hasNotAcceptedCommunityGuidelines && (
<StyledContainer>
<CommunityGuidelinesSection updateJailed={updateJailed} />
</StyledContainer>
)}
{jailInfo?.needsToUpdateLocation && (
<StyledContainer>
<LocationSection updateJailed={updateJailed} />
</StyledContainer>
)}
{jailInfo?.hasPendingActivenessProbe && (
<StyledContainer>
<ActivenessProbeSection updateJailed={updateJailed} />
</StyledContainer>
)}
</>
);
}
|