All files / app/features/auth/verification VerifyPostalPage.tsx

100% Statements 16/16
80% Branches 8/10
100% Functions 2/2
100% Lines 16/16

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 431x 1x 1x 1x 1x 1x 1x 1x   1x 1x   2x 4x 4x 4x 4x             4x                                      
import Alert from "components/Alert";
import CenteredSpinner from "components/CenteredSpinner/CenteredSpinner";
import HtmlMeta from "components/HtmlMeta";
import useAccountInfo from "features/auth/useAccountInfo";
import { useTranslation } from "i18n";
import { AUTH } from "i18n/namespaces";
import { useRouter } from "next/router";
import stringOrFirstString from "utils/stringOrFirstString";
 
import PostalVerificationSection from "./PostalVerificationSection";
import { DataUseSection, PageWidth, paperBackground } from "./VerificationPage";
 
export default function VerifyPostalPage() {
  const { t } = useTranslation(AUTH);
  const router = useRouter();
  const { data: accountInfo, error: accountInfoError, isLoading: isAccountInfoLoading } = useAccountInfo();
  const code = stringOrFirstString(router.query.c)?.toUpperCase() ?? "";
 
  return (
    <>
      <HtmlMeta title={t("verification_page.postal.header")} />
      {paperBackground}
      <PageWidth
        sx={(theme) => ({
          paddingBlock: theme.spacing(3, 4),
          display: "flex",
          flexDirection: "column",
          gap: 4,
        })}
      >
        {isAccountInfoLoading || !router.isReady ? (
          <CenteredSpinner />
        ) : accountInfoError ? (
          <Alert severity="error">{accountInfoError.message}</Alert>
        ) : accountInfo ? (
          <PostalVerificationSection hasDonated={accountInfo.hasDonated} initialCode={code} />
        ) : null}
        <DataUseSection />
      </PageWidth>
    </>
  );
}