From 11e0b8655b9a9fa701bf65bcb1b0e1d463bedfe1 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Thu, 11 Apr 2024 09:56:22 -0500 Subject: [PATCH] pick a federation on setup --- e2e/utils.ts | 10 +- public/i18n/en.json | 14 ++- public/i18n/es.json | 4 +- src/components/ImportNsecForm.tsx | 8 +- src/components/layout/Button.tsx | 4 +- src/router.tsx | 9 +- src/routes/settings/ManageFederations.tsx | 138 +++++++++++++--------- src/routes/setup/AddFederation.tsx | 65 ++++++++++ src/routes/setup/NewProfile.tsx | 8 +- src/routes/setup/index.ts | 1 + 10 files changed, 188 insertions(+), 73 deletions(-) create mode 100644 src/routes/setup/AddFederation.tsx diff --git a/e2e/utils.ts b/e2e/utils.ts index d4cafd33..603fd2d6 100644 --- a/e2e/utils.ts +++ b/e2e/utils.ts @@ -13,10 +13,14 @@ export async function loadHome(page: Page) { await page.locator("button:has-text('Skip for now')").click(); + await page.getByText("Pick a Federation").waitFor(); + + await page.locator("button:has-text('Skip for now')").click(); + + await page.locator(`button:has-text('Confirm')`).click(); + // Should have a balance up top now - await page.locator(`text=0 sats`).first(); - // Status light should be ready - await page.locator(`title="READY"`).first(); + await page.locator(`text=0 sats`).first().waitFor(); } export async function visitSettings(page: Page) { diff --git a/public/i18n/en.json b/public/i18n/en.json index c3ee1abf..d7235153 100644 --- a/public/i18n/en.json +++ b/public/i18n/en.json @@ -551,13 +551,14 @@ "remove": "Remove", "expires": "Expires", "federation_id": "Federation ID", - "description": "Mutiny has experimental support for the Fedimint protocol. Store funds in a federation at your own risk!", - "learn_more": "Learn more about Fedimint.", + "description": "Federations are bitcoin-based networks that make it cheaper, quicker, and easier to use bitcoin.", + "learn_more": "Learn more", "discover": "Discover Federations", "manual": "Invite Code", "created_at": "Created At", "recommended_by": "Recommended By", - "already_in_fed": "You're already in a federation!" + "already_in_fed": "You're already in a federation!", + "descriptionpart2": "Each one is ran by a group of different inviduals or companies. Discover one that you or your friends might trust below." }, "gift": { "give_sats_link": "Give sats as a gift", @@ -743,13 +744,18 @@ }, "setup": { "new_profile": { - "description": "Mutiny makes payments social." + "description": "Mutiny makes payments social.", + "title": "Create your profile" }, "skip": "Skip for now", "import_profile": "Import existing nostr profile", "import": { "title": "Import nostr profile", "description": "Login with an existing nostr account." + }, + "federation": { + "pick": "Pick a federation", + "skip_confirm": "You'll need to pay chain and channel fees to use Mutiny, and miss out on advanced features such as lightning address. You can change your mind later in the settings." } } } diff --git a/public/i18n/es.json b/public/i18n/es.json index 25e4e417..05e39539 100644 --- a/public/i18n/es.json +++ b/public/i18n/es.json @@ -495,8 +495,8 @@ "remove": "Eliminar", "expires": "Expira", "federation_id": "ID federación", - "description": "Mutiny tiene soporte experimental para el protocolo Fedimint. ¡Almacene fondos en una federación bajo su propio riesgo!", - "learn_more": "Aprenda más sobre Fedimint.", + "description": "", + "learn_more": "Aprenda más", "created_at": "Creado En", "recommended_by": "Recomendado por" }, diff --git a/src/components/ImportNsecForm.tsx b/src/components/ImportNsecForm.tsx index c8c3c344..45a60e11 100644 --- a/src/components/ImportNsecForm.tsx +++ b/src/components/ImportNsecForm.tsx @@ -6,7 +6,7 @@ import { createSignal, Show } from "solid-js"; import { Button, InfoBox, SimpleInput } from "~/components"; import { useMegaStore } from "~/state/megaStore"; -export function ImportNsecForm() { +export function ImportNsecForm(props: { setup?: boolean }) { const [state, _actions] = useMegaStore(); const navigate = useNavigate(); const [nsec, setNsec] = createSignal(""); @@ -29,7 +29,11 @@ export function ImportNsecForm() { undefined ); console.log("Changed to new npub: ", new_npub); - navigate("/"); + if (props.setup) { + navigate("/addfederation"); + } else { + navigate("/"); + } } catch (e) { console.error(e); setError("Invalid nsec"); diff --git a/src/components/layout/Button.tsx b/src/components/layout/Button.tsx index c9627ba4..c7ffb213 100644 --- a/src/components/layout/Button.tsx +++ b/src/components/layout/Button.tsx @@ -32,8 +32,10 @@ export const Button: ParentComponent = (props) => { - - {error()?.message} - - - {success()} - - - - - {i18n.t("settings.manage_federations.discover")} - + ]} + > + {(field, props) => ( + + )} + + + + {error()?.message} + + + {success()} + + + + + {i18n.t("settings.manage_federations.discover")} + + + -
- -
+ + +
@@ -247,13 +260,17 @@ function AddFederationForm(props: { refetch?: RefetchType }) { - - - + + + + + {" "} - {/* */} {i18n.t("settings.manage_federations.title")} {i18n.t("settings.manage_federations.description")}{" "} + + {i18n.t("settings.manage_federations.descriptionpart2")}{" "} + + + + {i18n.t("settings.manage_federations.learn_more")} + + diff --git a/src/routes/setup/AddFederation.tsx b/src/routes/setup/AddFederation.tsx new file mode 100644 index 00000000..3e2460e7 --- /dev/null +++ b/src/routes/setup/AddFederation.tsx @@ -0,0 +1,65 @@ +import { useNavigate } from "@solidjs/router"; +import { createSignal, Suspense } from "solid-js"; + +import { + Button, + ConfirmDialog, + DefaultMain, + ExternalLink, + MutinyWalletGuard, + VStack +} from "~/components"; +import { useI18n } from "~/i18n/context"; + +import { AddFederationForm } from "../settings"; + +export function AddFederation() { + const i18n = useI18n(); + const navigate = useNavigate(); + + const [confirmOpen, setConfirmOpen] = createSignal(false); + + async function handleSkip() { + navigate("/"); + } + + return ( + + +
+

+ {i18n.t("setup.federation.pick")} +

+

+ {i18n.t("settings.manage_federations.description")} +

+

+ {i18n.t("settings.manage_federations.descriptionpart2")} +

+ + + setConfirmOpen(false)} + > + {i18n.t("setup.federation.skip_confirm")} + + + + + + +

+ + {i18n.t("settings.manage_federations.learn_more")} + +

+
+
+
+ ); +} diff --git a/src/routes/setup/NewProfile.tsx b/src/routes/setup/NewProfile.tsx index 3850ec7c..7c554a4c 100644 --- a/src/routes/setup/NewProfile.tsx +++ b/src/routes/setup/NewProfile.tsx @@ -31,7 +31,7 @@ export function NewProfile() { ); console.log("profile", profile); localStorage.setItem("profile_setup_stage", "skipped"); - navigate("/"); + navigate("/addfederation"); setSkipping(false); } @@ -46,7 +46,7 @@ export function NewProfile() { ); console.log("profile", profile); localStorage.setItem("profile_setup_stage", "saved"); - navigate("/"); + navigate("/addfederation"); } catch (e) { console.error(e); } @@ -57,7 +57,9 @@ export function NewProfile() {
-

Create your profile

+

+ {i18n.t("setup.new_profile.title")} +

{i18n.t("setup.new_profile.description")}

diff --git a/src/routes/setup/index.ts b/src/routes/setup/index.ts index 577594d3..81866c13 100644 --- a/src/routes/setup/index.ts +++ b/src/routes/setup/index.ts @@ -2,3 +2,4 @@ export * from "./Restore"; export * from "./ImportProfile"; export * from "./NewProfile"; export * from "./Root"; +export * from "./AddFederation";