import { CodeBlock } from "@/accounts/components/CodeBlock"; import { LinkButton } from "@/base/components/LinkButton"; import { ActivityIndicator } from "@/base/components/mui/ActivityIndicator"; import { VerticallyCentered } from "@ente/shared/components/Container"; import { Stack, styled, Typography } from "@mui/material"; import { t } from "i18next"; import { useState } from "react"; import { type SetupMode } from "../../pages/two-factor/setup"; import type { TwoFactorSecret } from "../../services/user"; interface TwoFactorSetupProps { twoFactorSecret?: TwoFactorSecret; } export function TwoFactorSetup({ twoFactorSecret }: TwoFactorSetupProps) { const [setupMode, setSetupMode] = useState("qrCode"); const changeToManualMode = () => setSetupMode("manualCode"); const changeToQRMode = () => setSetupMode("qrCode"); return ( {setupMode == "qrCode" ? ( ) : ( )} ); } interface SetupManualModeProps { twoFactorSecret?: TwoFactorSecret; changeToQRMode: () => void; } function SetupManualMode({ twoFactorSecret, changeToQRMode, }: SetupManualModeProps) { return ( {t("two_factor_manual_entry_message")} {t("scan_qr_title")} ); } interface SetupQRModeProps { twoFactorSecret?: TwoFactorSecret; changeToManualMode: () => void; } function SetupQRMode({ twoFactorSecret, changeToManualMode, }: SetupQRModeProps) { return ( <> {t("two_factor_qr_help")} {!twoFactorSecret ? ( ) : ( )} {t("two_factor_manual_entry_title")} ); } const QRCode = styled("img")( ({ theme }) => ` height: 200px; width: 200px; margin: ${theme.spacing(2)}; `, ); const LoadingQRCode = styled(VerticallyCentered)( ({ theme }) => ` width: 200px; aspect-ratio:1; border: 1px solid ${theme.palette.grey.A200}; margin: ${theme.spacing(2)}; `, );