import { Match, ParentComponent, Show, Switch, createMemo } from "solid-js"; import { Card, VStack } from "~/components/layout"; import { useMegaStore } from "~/state/megaStore"; import { satsToUsd } from "~/utils/conversions"; import { AmountEditable } from "./AmountEditable"; const KeyValue: ParentComponent<{ key: string, gray?: boolean }> = (props) => { return (
{props.key}
{props.children}
) } export const InlineAmount: ParentComponent<{ amount: string, sign?: string, fiat?: boolean }> = (props) => { const prettyPrint = createMemo(() => { const parsed = Number(props.amount); if (isNaN(parsed)) { return props.amount; } else { return parsed.toLocaleString(); } }) return (
{props.sign ? `${props.sign} ` : ""}{props.fiat ? "$" : ""}{prettyPrint()} {props.fiat ? "USD" : "SATS"}
) } function USDShower(props: { amountSats: string, fee?: string }) { const [state, _] = useMegaStore() const amountInUsd = () => satsToUsd(state.price, add(props.amountSats, props.fee), true) return (
≈ {amountInUsd()} USD
) } function add(a: string, b?: string) { return Number(a || 0) + Number(b || 0) } export function AmountCard(props: { amountSats: string, fee?: string, initialOpen?: boolean, isAmountEditable?: boolean, setAmountSats?: (amount: bigint) => void }) { return (
}> { }} />

}> { }} />
) }