feat: closing on Amount choice new returns you to homepage

This commit is contained in:
benalleng
2023-06-16 17:40:40 -04:00
committed by Paul Miller
parent c5bf39cfd4
commit 0503c6620a
4 changed files with 45 additions and 2 deletions

4
pnpm-lock.yaml generated
View File

@@ -1,5 +1,9 @@
lockfileVersion: '6.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
dependencies:
'@kobalte/core':
specifier: ^0.9.6

View File

@@ -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}
/>

View File

@@ -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<{
<div class={DIALOG_POSITIONER}>
<Dialog.Content
class={DIALOG_CONTENT}
onEscapeKeyDown={() => 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 */}
<div class="w-full flex justify-end">
<button
onClick={() => setIsOpen(false)}
onClick={() => {
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);
}}
class="hover:bg-white/10 rounded-lg active:bg-m-blue w-8 h-8"
>
<img src={close} alt="Close" />

View File

@@ -323,6 +323,7 @@ export default function Receive() {
amountSats={amount() || "0"}
setAmountSats={setAmount}
isAmountEditable
exitRoute={amount() ? "/receive" : "/"}
/>
<Card title="Private tags">