All files / app/features/auth Settings.tsx

0% Statements 0/26
0% Branches 0/6
0% Functions 0/3
0% Lines 0/24

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                                                                                                                                                                                                       
import { 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 ChangeEmail from "features/auth/email/ChangeEmail";
import DoNotEmail from "features/auth/email/DoNotEmail";
import { ChangePassword } from "features/auth/password";
import Section from "features/auth/section/Section";
import Timezone from "features/auth/timezone/Timezone";
import Username from "features/auth/username/Username";
import NotificationSettings from "features/notifications/NotificationSettings";
import { useTranslation } from "i18n";
import { AUTH } from "i18n/namespaces";
 
import DeleteAccount from "./deletion/DeleteAccount";
import ManageDonations from "./donations/ManageDonations";
import LoginsLink from "./logins/LoginsLink";
import useAccountInfo from "./useAccountInfo";
import StrongVerification from "./verification/StrongVerification";
 
const TopMarginWrapper = styled("div")(({ theme }) => ({
  margin: theme.spacing(4, 0),
  "&:first-of-type": {
    marginTop: theme.spacing(2),
  },
}));
 
const MarginWrapper = styled("div")(({ theme }) => ({
  margin: theme.spacing(4, 0),
}));
 
export default function Settings() {
  const { t } = useTranslation(AUTH);
  const {
    data: accountInfo,
    error: accountInfoError,
    isLoading: isAccountInfoLoading,
  } = useAccountInfo();
 
  return (
    <>
      <HtmlMeta title={t("account_settings_page.title")} />
      <PageTitle>{t("account_settings_page.title")}</PageTitle>
      {isAccountInfoLoading ? (
        <CenteredSpinner />
      ) : accountInfoError ? (
        <Alert severity="error">{accountInfoError.message}</Alert>
      ) : accountInfo ? (
        <>
          <TopMarginWrapper>
            <NotificationSettings />
          </TopMarginWrapper>
          <MarginWrapper>
            <StrongVerification accountInfo={accountInfo!} />
          </MarginWrapper>
          <MarginWrapper>
            <ChangeEmail email={accountInfo.email} />
          </MarginWrapper>
          <MarginWrapper>
            <ChangePassword />
          </MarginWrapper>
          <MarginWrapper>
            <LoginsLink />
          </MarginWrapper>
          <MarginWrapper>
            <ManageDonations />
          </MarginWrapper>
          <MarginWrapper>
            <Username username={accountInfo.username} />
          </MarginWrapper>
          <MarginWrapper>
            <Timezone timezone={accountInfo.timezone} />
          </MarginWrapper>
          <MarginWrapper>
            <DoNotEmail />
          </MarginWrapper>
          <MarginWrapper>
            <Section
              title={t("account_settings_page.gender_section.title")}
              content={t("account_settings_page.gender_section.explanation")}
            />
          </MarginWrapper>
          <MarginWrapper>
            <Section
              title={t("account_settings_page.birth_date_section.title")}
              content={t(
                "account_settings_page.birth_date_section.explanation",
              )}
            />
          </MarginWrapper>
          <MarginWrapper>
            <DeleteAccount username={accountInfo.username} />
          </MarginWrapper>
        </>
      ) : null}
    </>
  );
}