diff --git a/apps/desktop2/package.json b/apps/desktop2/package.json index 763359f7..fb531acf 100644 --- a/apps/desktop2/package.json +++ b/apps/desktop2/package.json @@ -26,6 +26,7 @@ "i18next-resources-to-backend": "^1.2.0", "nostr-tools": "^2.3.1", "react": "^18.2.0", + "react-currency-input-field": "^3.8.0", "react-dom": "^18.2.0", "react-i18next": "^14.0.5", "slate": "^0.101.5", diff --git a/apps/desktop2/src/components/balance.tsx b/apps/desktop2/src/components/balance.tsx new file mode 100644 index 00000000..5be1f4ec --- /dev/null +++ b/apps/desktop2/src/components/balance.tsx @@ -0,0 +1,51 @@ +import { useArk } from "@lume/ark"; +import { User } from "@lume/ui"; +import { getBitcoinDisplayValues } from "@lume/utils"; +import { useEffect, useMemo, useState } from "react"; +import { useTranslation } from "react-i18next"; + +export function Balance({ + recipient, + account, +}: { + recipient: string; + account: string; +}) { + const [t] = useTranslation(); + const [balance, setBalance] = useState(0); + + const ark = useArk(); + const value = useMemo(() => getBitcoinDisplayValues(balance), [balance]); + + useEffect(() => { + async function getBalance() { + const val = await ark.get_balance(); + setBalance(val); + } + + getBalance(); + }, []); + + return ( +
+
+
+
+ Your balance +
+
+ ₿ {value.bitcoinFormatted} +
+
+ + + + + +
+
+ ); +} diff --git a/apps/desktop2/src/components/login.tsx b/apps/desktop2/src/components/login.tsx index 0d8cf6f2..9d644512 100644 --- a/apps/desktop2/src/components/login.tsx +++ b/apps/desktop2/src/components/login.tsx @@ -11,19 +11,15 @@ export function LoginDialog() { const [nsec, setNsec] = useState(""); const [passphase, setPassphase] = useState(""); - const [loading, setLoading] = useState(false); const login = async () => { try { - setLoading(true); - const save = await ark.save_account(nsec, passphase); if (save) { navigate({ to: "/", search: { guest: false } }); } } catch (e) { - setLoading(false); toast.error(String(e)); } }; diff --git a/apps/desktop2/src/routes/nwc.lazy.tsx b/apps/desktop2/src/routes/nwc.lazy.tsx new file mode 100644 index 00000000..97c952ab --- /dev/null +++ b/apps/desktop2/src/routes/nwc.lazy.tsx @@ -0,0 +1,68 @@ +import { useArk } from "@lume/ark"; +import { ArrowRightIcon, ZapIcon } from "@lume/icons"; +import { Container } from "@lume/ui"; +import { createLazyFileRoute } from "@tanstack/react-router"; +import { useState } from "react"; + +export const Route = createLazyFileRoute("/nwc")({ + component: Screen, +}); + +function Screen() { + const ark = useArk(); + + const [uri, setUri] = useState(""); + const [isDone, setIsDone] = useState(false); + + const save = async () => { + const nwc = await ark.set_nwc(uri); + + if (nwc) { + setIsDone(true); + } + }; + + return ( + +
+ {!isDone ? ( + <> +
+
+ +
+
+

+ Connect bitcoin wallet{" "} + to start zapping to your favorite content and creator. +

+
+
+
+
+ +