2023-11-05 01:16:45 +01:00
|
|
|
import { useMemo } from "react";
|
2023-11-27 20:19:03 +01:00
|
|
|
import { useTranslation } from "react-i18next";
|
2023-11-05 01:16:45 +01:00
|
|
|
|
|
|
|
import { genMnemonic } from "@/backend/accounts/crypto";
|
2023-11-26 16:04:23 +01:00
|
|
|
import { Button } from "@/components/buttons/Button";
|
|
|
|
import { PassphraseDisplay } from "@/components/form/PassphraseDisplay";
|
2023-11-17 14:45:13 +01:00
|
|
|
import { Icon, Icons } from "@/components/Icon";
|
|
|
|
import {
|
|
|
|
LargeCard,
|
|
|
|
LargeCardButtons,
|
|
|
|
LargeCardText,
|
|
|
|
} from "@/components/layout/LargeCard";
|
2023-11-05 01:16:45 +01:00
|
|
|
|
|
|
|
interface PassphraseGeneratePartProps {
|
|
|
|
onNext?: (mnemonic: string) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function PassphraseGeneratePart(props: PassphraseGeneratePartProps) {
|
|
|
|
const mnemonic = useMemo(() => genMnemonic(), []);
|
2023-11-27 20:19:03 +01:00
|
|
|
const { t } = useTranslation();
|
2023-11-05 01:16:45 +01:00
|
|
|
|
|
|
|
return (
|
2023-11-17 14:45:13 +01:00
|
|
|
<LargeCard>
|
2023-11-27 20:19:03 +01:00
|
|
|
<LargeCardText
|
|
|
|
title={t("auth.generate.title")}
|
|
|
|
icon={<Icon icon={Icons.USER} />}
|
|
|
|
>
|
|
|
|
{t("auth.generate.description")}
|
2023-11-17 14:45:13 +01:00
|
|
|
</LargeCardText>
|
2023-11-24 21:54:44 +01:00
|
|
|
<PassphraseDisplay mnemonic={mnemonic} />
|
2023-11-17 14:45:13 +01:00
|
|
|
|
|
|
|
<LargeCardButtons>
|
|
|
|
<Button theme="purple" onClick={() => props.onNext?.(mnemonic)}>
|
2023-11-30 23:37:07 +01:00
|
|
|
{t("auth.generate.next")}
|
2023-11-17 14:45:13 +01:00
|
|
|
</Button>
|
|
|
|
</LargeCardButtons>
|
|
|
|
</LargeCard>
|
2023-11-05 01:16:45 +01:00
|
|
|
);
|
|
|
|
}
|