From 79f4fcb2d153d5686ab40529a29170dd6b4d27b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Aaron?= Date: Mon, 11 Mar 2024 14:15:21 +0100 Subject: [PATCH] fix: remove nostr setup, replace component with existing one --- src/app/components/CardButton/Group.tsx | 4 +- src/app/components/CardButton/index.tsx | 28 ++-- src/app/components/ExtensionKeyCard/index.tsx | 30 ----- src/app/router/Options/Options.tsx | 2 - .../screens/Accounts/GenerateMnemonic/new.tsx | 43 +++--- .../Accounts/NostrSetup/NostrSetup.tsx | 122 ------------------ src/i18n/locales/en/translation.json | 16 +-- 7 files changed, 34 insertions(+), 211 deletions(-) delete mode 100644 src/app/components/ExtensionKeyCard/index.tsx delete mode 100644 src/app/screens/Accounts/NostrSetup/NostrSetup.tsx diff --git a/src/app/components/CardButton/Group.tsx b/src/app/components/CardButton/Group.tsx index c8f6f3ba9f..14ff127419 100644 --- a/src/app/components/CardButton/Group.tsx +++ b/src/app/components/CardButton/Group.tsx @@ -3,5 +3,7 @@ export type Props = { }; export default function CardButtonGroup({ children }: Props) { - return
{children}
; + return ( +
{children}
+ ); } diff --git a/src/app/components/CardButton/index.tsx b/src/app/components/CardButton/index.tsx index 4a752515a0..c4a9272e74 100644 --- a/src/app/components/CardButton/index.tsx +++ b/src/app/components/CardButton/index.tsx @@ -3,34 +3,30 @@ import React from "react"; export type Props = { title: string; description: string; - icon: IconType; + icon: React.ComponentType<{ + className?: string; + }>; onClick: () => void; }; -interface IconTypeProps { - className: string; -} - -type IconType = (props: IconTypeProps) => JSX.Element; - export default function CardButton({ title, description, - icon, + icon: Icon, onClick, }: Props) { return ( -
- {React.createElement(icon, { - className: "w-8 h-8 text-gray-700 dark:text-white", - })} -

+ +

{title}

-

{description}

-

+

+ {description} +

+ ); } diff --git a/src/app/components/ExtensionKeyCard/index.tsx b/src/app/components/ExtensionKeyCard/index.tsx deleted file mode 100644 index d2657cdc1e..0000000000 --- a/src/app/components/ExtensionKeyCard/index.tsx +++ /dev/null @@ -1,30 +0,0 @@ -export type ExtensionKeyCardProps = { - title: string; - description: string; - icon: React.ReactNode; - onClick: () => void; -}; - -export function ExtensionKeyCard({ - icon, - title, - description, - onClick, -}: ExtensionKeyCardProps) { - return ( - - ); -} diff --git a/src/app/router/Options/Options.tsx b/src/app/router/Options/Options.tsx index ab56d721a1..85d38ad323 100644 --- a/src/app/router/Options/Options.tsx +++ b/src/app/router/Options/Options.tsx @@ -31,7 +31,6 @@ import GenerateMnemonic from "~/app/screens/Accounts/GenerateMnemonic"; import NewMnemonic from "~/app/screens/Accounts/GenerateMnemonic/new"; import ImportMnemonic from "~/app/screens/Accounts/ImportMnemonic"; import NostrSettings from "~/app/screens/Accounts/NostrSettings"; -import NostrSetup from "~/app/screens/Accounts/NostrSetup/NostrSetup"; import LNURLRedeem from "~/app/screens/LNURLRedeem"; import OnChainReceive from "~/app/screens/OnChainReceive"; @@ -94,7 +93,6 @@ function Options() { } /> } /> } /> - } /> { @@ -62,27 +62,20 @@ function MnemonicExplanation() { />
- - } - onClick={async () => { - setIsCardSelected("backup"); - }} - /> - - - } - onClick={async () => { - setIsCardSelected("import"); - }} - /> + + setSelectedCard("backup")} + /> + setSelectedCard("import")} + /> +
@@ -91,7 +84,7 @@ function MnemonicExplanation() { primary flex onClick={() => - cardSelected == "backup" + selectedCard == "backup" ? hasMnemonic ? navigate("../secret-key/backup") : navigate("../secret-key/generate") diff --git a/src/app/screens/Accounts/NostrSetup/NostrSetup.tsx b/src/app/screens/Accounts/NostrSetup/NostrSetup.tsx deleted file mode 100644 index 97e26abc03..0000000000 --- a/src/app/screens/Accounts/NostrSetup/NostrSetup.tsx +++ /dev/null @@ -1,122 +0,0 @@ -import { - KeyIcon, - MnemonicIcon, - ReceiveIcon, - TwoKeysIcon, -} from "@bitcoin-design/bitcoin-icons-react/outline"; -import Container from "@components/Container"; -import { useEffect, useState } from "react"; -import { Trans, useTranslation } from "react-i18next"; -import { useNavigate, useParams } from "react-router-dom"; -import CardButton from "~/app/components/CardButton"; -import CardButtonGroup from "~/app/components/CardButton/Group"; -import { ContentBox } from "~/app/components/ContentBox"; -import Hyperlink from "~/app/components/Hyperlink"; -import toast from "~/app/components/Toast"; -import api from "~/common/lib/api"; - -function NostrSetup() { - const { t } = useTranslation("translation", { - keyPrefix: "accounts.account_view.nostr.setup", - }); - const navigate = useNavigate(); - const [step, setStep] = useState<"start" | "import">("start"); - const { id } = useParams() as { id: string }; - - useEffect(() => { - (async () => { - try { - const account = await api.getAccount(id); - if (account.nostrEnabled) { - // do not allow user to setup nostr if they already have a key - navigate(`/accounts/${id}`); - } - } catch (e) { - console.error(e); - if (e instanceof Error) toast.error(`Error: ${e.message}`); - } - })(); - }, [id, navigate]); - - return ( -
- - - {step === "start" && ( - <> -

- {t("title")} -

-

- {t("description")} -

-

- , - ]} - /> -

- - - navigate("../secret-key/new")} - /> - setStep("import")} - /> - - - )} - {step === "import" && ( - <> -

- {t("import.title")} -

- - - navigate("../nostr/settings")} - /> - navigate("../secret-key/import")} - /> - - - )} -
- , - ]} - /> -
-
-
-
- ); -} - -export default NostrSetup; diff --git a/src/i18n/locales/en/translation.json b/src/i18n/locales/en/translation.json index 0aac5cf490..6cc055949e 100644 --- a/src/i18n/locales/en/translation.json +++ b/src/i18n/locales/en/translation.json @@ -485,21 +485,7 @@ "new": { "label": "Create a new Nostr account", "description": "Generate a Master Key with a pair of new Nostr keys." - }, - "import": { - "label": "Import a Nostr account", - "description": "Use an existing Nostr private key or derive it from your Master Key", - "title": "How would you like to import your Nostr account?", - "private_key": { - "label": "Use Nostr private key", - "description": "Paste your Nostr private key to import it to Alby" - }, - "recovery_phrase": { - "label": "Use recovery phrase", - "description": "Use Master key recovery phrase to import your Nostr keys" - } - }, - "new_to_nostr": "New to Nostr? <0>Learn more" + } }, "private_key": { "title": "Manage your Nostr private key",