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 | import { Typography } from "@mui/material";
import Alert from "components/Alert";
import CenteredSpinner from "components/CenteredSpinner/CenteredSpinner";
import StyledLink from "components/StyledLink";
import { Trans, useTranslation } from "i18n";
import { AUTH } from "i18n/namespaces";
import { GetAccountInfoRes } from "proto/account_pb";
import { volunteerNotAVolunteerFormUrl } from "routes";
import { theme } from "theme";
import { useVolunteerInfo } from "./useVolunteerInfo";
import VolunteerCard from "./VolunteerCard";
import VolunteerForm from "./VolunteerForm";
type VolunteerManagementProps = {
accountInfo: GetAccountInfoRes.AsObject;
className?: string;
};
export default function VolunteerManagement({
className,
accountInfo,
}: VolunteerManagementProps) {
const { t } = useTranslation([AUTH]);
// Non-volunteer view
Iif (!accountInfo.isVolunteer) {
return (
<div className={className} id="volunteer-management">
<Typography variant="h2">
{t("auth:volunteer_management.title")}
</Typography>
<Typography variant="body1" sx={{ marginTop: theme.spacing(1) }}>
<Trans
t={t}
i18nKey="auth:volunteer_management.not_a_volunteer_message"
components={{
1: <StyledLink href={volunteerNotAVolunteerFormUrl} />,
}}
>
According to our records you are not a current or past volunteer. If
this is incorrect, please let us know by filling in{" "}
<StyledLink href={volunteerNotAVolunteerFormUrl}>
this form
</StyledLink>
.
</Trans>
</Typography>
</div>
);
}
return <VolunteerManagementContent className={className} />;
}
function VolunteerManagementContent({ className }: { className?: string }) {
const { t } = useTranslation([AUTH]);
const {
data: volunteerInfo,
error: volunteerInfoError,
isLoading: isVolunteerInfoLoading,
} = useVolunteerInfo();
Iif (isVolunteerInfoLoading) {
return (
<div className={className} id="volunteer-management">
<Typography variant="h2">
{t("auth:volunteer_management.title")}
</Typography>
<CenteredSpinner />
</div>
);
}
Iif (volunteerInfoError) {
return (
<div className={className} id="volunteer-management">
<Typography variant="h2">
{t("auth:volunteer_management.title")}
</Typography>
<Alert severity="error">{volunteerInfoError.message}</Alert>
</div>
);
}
Iif (!volunteerInfo) {
return null;
}
return (
<div className={className} id="volunteer-management">
<Typography variant="h2">
{t("auth:volunteer_management.title")}
</Typography>
<Typography variant="body1" sx={{ marginTop: theme.spacing(1) }}>
{t("auth:volunteer_management.description")}
</Typography>
<VolunteerCard volunteerInfo={volunteerInfo} />
<VolunteerForm volunteerInfo={volunteerInfo} />
</div>
);
}
|