mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2025-12-19 07:14:22 +01:00
Display individual fedimint balances
This commit is contained in:
committed by
benthecarman
parent
d9ada684fa
commit
c680ab2805
@@ -6,9 +6,19 @@ import {
|
|||||||
SubmitHandler
|
SubmitHandler
|
||||||
} from "@modular-forms/solid";
|
} from "@modular-forms/solid";
|
||||||
import { useSearchParams } from "@solidjs/router";
|
import { useSearchParams } from "@solidjs/router";
|
||||||
import { createSignal, For, onMount, Show } from "solid-js";
|
import {
|
||||||
|
createResource,
|
||||||
|
createSignal,
|
||||||
|
For,
|
||||||
|
Match,
|
||||||
|
onMount,
|
||||||
|
Show,
|
||||||
|
Suspense,
|
||||||
|
Switch
|
||||||
|
} from "solid-js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
AmountSats,
|
||||||
BackLink,
|
BackLink,
|
||||||
Button,
|
Button,
|
||||||
ConfirmDialog,
|
ConfirmDialog,
|
||||||
@@ -130,7 +140,10 @@ function AddFederationForm() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function FederationListItem(props: { fed: MutinyFederationIdentity }) {
|
function FederationListItem(props: {
|
||||||
|
fed: MutinyFederationIdentity;
|
||||||
|
balance?: bigint;
|
||||||
|
}) {
|
||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
const [state, actions] = useMegaStore();
|
const [state, actions] = useMegaStore();
|
||||||
|
|
||||||
@@ -165,6 +178,16 @@ function FederationListItem(props: { fed: MutinyFederationIdentity }) {
|
|||||||
<Show when={props.fed.welcome_message}>
|
<Show when={props.fed.welcome_message}>
|
||||||
<p>{props.fed.welcome_message}</p>
|
<p>{props.fed.welcome_message}</p>
|
||||||
</Show>
|
</Show>
|
||||||
|
<Show when={props.balance !== undefined}>
|
||||||
|
<KeyValue
|
||||||
|
key={i18n.t("activity.transaction_details.balance")}
|
||||||
|
>
|
||||||
|
<AmountSats
|
||||||
|
amountSats={props.balance}
|
||||||
|
denominationSize={"sm"}
|
||||||
|
/>
|
||||||
|
</KeyValue>
|
||||||
|
</Show>
|
||||||
<Show when={props.fed.federation_expiry_timestamp}>
|
<Show when={props.fed.federation_expiry_timestamp}>
|
||||||
<KeyValue
|
<KeyValue
|
||||||
key={i18n.t("settings.manage_federations.expires")}
|
key={i18n.t("settings.manage_federations.expires")}
|
||||||
@@ -201,6 +224,17 @@ export function ManageFederations() {
|
|||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
const [state, _actions] = useMegaStore();
|
const [state, _actions] = useMegaStore();
|
||||||
|
|
||||||
|
const [balances] = createResource(async () => {
|
||||||
|
try {
|
||||||
|
const balances =
|
||||||
|
await state.mutiny_wallet?.get_federation_balances();
|
||||||
|
return balances?.balances || [];
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MutinyWalletGuard>
|
<MutinyWalletGuard>
|
||||||
<SafeArea>
|
<SafeArea>
|
||||||
@@ -220,9 +254,33 @@ export function ManageFederations() {
|
|||||||
</NiceP>
|
</NiceP>
|
||||||
<AddFederationForm />
|
<AddFederationForm />
|
||||||
<VStack>
|
<VStack>
|
||||||
|
<Suspense>
|
||||||
|
<Switch>
|
||||||
|
<Match when={balances()}>
|
||||||
<For each={state.federations ?? []}>
|
<For each={state.federations ?? []}>
|
||||||
{(fed) => <FederationListItem fed={fed} />}
|
{(fed) => (
|
||||||
|
<FederationListItem
|
||||||
|
fed={fed}
|
||||||
|
balance={
|
||||||
|
balances()?.find(
|
||||||
|
(b) =>
|
||||||
|
b.identity_federation_id ===
|
||||||
|
fed.federation_id
|
||||||
|
)?.balance
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</For>
|
</For>
|
||||||
|
</Match>
|
||||||
|
<Match when={true}>
|
||||||
|
<For each={state.federations ?? []}>
|
||||||
|
{(fed) => (
|
||||||
|
<FederationListItem fed={fed} />
|
||||||
|
)}
|
||||||
|
</For>
|
||||||
|
</Match>
|
||||||
|
</Switch>
|
||||||
|
</Suspense>
|
||||||
</VStack>
|
</VStack>
|
||||||
</DefaultMain>
|
</DefaultMain>
|
||||||
<NavBar activeTab="settings" />
|
<NavBar activeTab="settings" />
|
||||||
|
|||||||
Reference in New Issue
Block a user