From 0503c6620a5b1a47bf1a61bb06942fca84095ade Mon Sep 17 00:00:00 2001 From: benalleng Date: Fri, 16 Jun 2023 17:40:40 -0400 Subject: [PATCH] feat: closing on Amount choice new returns you to homepage --- pnpm-lock.yaml | 4 ++++ src/components/AmountCard.tsx | 3 +++ src/components/AmountEditable.tsx | 39 +++++++++++++++++++++++++++++-- src/routes/Receive.tsx | 1 + 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ef05bec..ec152f3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,5 +1,9 @@ lockfileVersion: '6.0' +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + dependencies: '@kobalte/core': specifier: ^0.9.6 diff --git a/src/components/AmountCard.tsx b/src/components/AmountCard.tsx index 010d8a8..5325923 100644 --- a/src/components/AmountCard.tsx +++ b/src/components/AmountCard.tsx @@ -73,6 +73,7 @@ export function AmountCard(props: { isAmountEditable?: boolean; setAmountSats?: (amount: bigint) => void; skipWarnings?: boolean; + exitRoute?: string; maxAmountSats?: bigint; }) { // Normally we want to add the fee to the amount, but for max amount we just show the max @@ -111,6 +112,7 @@ export function AmountCard(props: { : noop } skipWarnings={props.skipWarnings} + exitRoute={props.exitRoute} maxAmountSats={props.maxAmountSats} fee={props.fee} /> @@ -176,6 +178,7 @@ export function AmountCard(props: { : noop } skipWarnings={props.skipWarnings} + exitRoute={props.exitRoute} maxAmountSats={props.maxAmountSats} fee={props.fee} /> diff --git a/src/components/AmountEditable.tsx b/src/components/AmountEditable.tsx index d973ba3..fb8c294 100644 --- a/src/components/AmountEditable.tsx +++ b/src/components/AmountEditable.tsx @@ -17,6 +17,7 @@ import { DIALOG_CONTENT, DIALOG_POSITIONER } from "~/styles/dialogs"; import { InfoBox } from "./InfoBox"; import { Network } from "~/logic/mutinyWalletSetup"; import { FeesModal } from "./MoreInfoModal"; +import { useNavigate } from "@solidjs/router"; const CHARACTERS = [ "1", @@ -138,9 +139,11 @@ export const AmountEditable: ParentComponent<{ initialOpen: boolean; setAmountSats: (s: bigint) => void; skipWarnings?: boolean; + exitRoute?: string; maxAmountSats?: bigint; fee?: string; }> = (props) => { + const navigate = useNavigate(); const [isOpen, setIsOpen] = createSignal(props.initialOpen); const [state, _actions] = useMegaStore(); const [mode, setMode] = createSignal<"fiat" | "sats">("sats"); @@ -325,12 +328,44 @@ export const AmountEditable: ParentComponent<{
setIsOpen(false)} + onEscapeKeyDown={() => { + props.setAmountSats( + BigInt(props.initialAmountSats) + ); + setIsOpen(false); + setLocalSats(props.initialAmountSats); + setLocalFiat( + satsToUsd( + state.price, + parseInt(props.initialAmountSats || "0") || + 0, + false + ) + ); + props.exitRoute && navigate(props.exitRoute); + }} > {/* TODO: figure out how to submit on enter */}