feat: use handleClose function

This commit is contained in:
benalleng
2023-06-21 12:49:22 -04:00
committed by Paul Miller
parent 0503c6620a
commit 54da432e39
3 changed files with 23 additions and 36 deletions

View File

@@ -247,6 +247,20 @@ export const AmountEditable: ParentComponent<{
} }
} }
function handleClose() {
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);
}
// What we're all here for in the first place: returning a value // What we're all here for in the first place: returning a value
function handleSubmit(e: SubmitEvent | MouseEvent) { function handleSubmit(e: SubmitEvent | MouseEvent) {
e.preventDefault(); e.preventDefault();
@@ -328,44 +342,12 @@ export const AmountEditable: ParentComponent<{
<div class={DIALOG_POSITIONER}> <div class={DIALOG_POSITIONER}>
<Dialog.Content <Dialog.Content
class={DIALOG_CONTENT} class={DIALOG_CONTENT}
onEscapeKeyDown={() => { onEscapeKeyDown={handleClose}
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 */} {/* TODO: figure out how to submit on enter */}
<div class="w-full flex justify-end"> <div class="w-full flex justify-end">
<button <button
onClick={() => { onClick={handleClose}
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" class="hover:bg-white/10 rounded-lg active:bg-m-blue w-8 h-8"
> >
<img src={close} alt="Close" /> <img src={close} alt="Close" />

View File

@@ -11,7 +11,12 @@ export async function checkBrowserCompatibility(): Promise<boolean> {
// Check if the browser supports WebAssembly // Check if the browser supports WebAssembly
console.debug("Checking WebAssembly"); console.debug("Checking WebAssembly");
if (typeof WebAssembly !== 'object' || !WebAssembly.validate(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00))) { if (
typeof WebAssembly !== "object" ||
!WebAssembly.validate(
Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00)
)
) {
throw new Error("WebAssembly is not supported."); throw new Error("WebAssembly is not supported.");
} }