From 415c94d5d1dd9132502a00a545e9d243137e7d47 Mon Sep 17 00:00:00 2001 From: vaibhav garg Date: Sun, 4 Dec 2022 19:02:37 +0530 Subject: [PATCH] refactor: form el for ConfirmorCancel #1617 --- src/app/screens/ConfirmKeysend/index.tsx | 68 +++++----- src/app/screens/ConfirmPayment/index.tsx | 80 +++++------ .../ConfirmRequestPermission/index.tsx | 84 ++++++------ src/app/screens/ConfirmSignMessage/index.tsx | 18 ++- src/app/screens/Enable/index.tsx | 34 +++-- src/app/screens/Keysend/index.tsx | 54 ++++---- src/app/screens/LNURLAuth/index.tsx | 20 ++- src/app/screens/LNURLChannel/index.tsx | 18 ++- src/app/screens/LNURLWithdraw/index.tsx | 18 ++- src/app/screens/MakeInvoice/index.tsx | 124 +++++++++--------- src/app/screens/Nostr/Confirm.tsx | 106 ++++++++------- src/app/screens/Nostr/ConfirmGetPublicKey.tsx | 70 +++++----- src/app/screens/Nostr/ConfirmSignMessage.tsx | 68 +++++----- 13 files changed, 420 insertions(+), 342 deletions(-) diff --git a/src/app/screens/ConfirmKeysend/index.tsx b/src/app/screens/ConfirmKeysend/index.tsx index e982f2ad09..72a4b745cb 100644 --- a/src/app/screens/ConfirmKeysend/index.tsx +++ b/src/app/screens/ConfirmKeysend/index.tsx @@ -123,45 +123,51 @@ function ConfirmKeysend() { }); } + function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + confirm(); + } + return (
{!successMessage ? ( -
- -
-
- +
+ +
+
+ +
+ + { + setRememberMe(event.target.checked); + }} + budget={budget} + onBudgetChange={(event) => setBudget(event.target.value)} />
- - { - setRememberMe(event.target.checked); - }} - budget={budget} - onBudgetChange={(event) => setBudget(event.target.value)} - />
-
- + + ) : ( diff --git a/src/app/screens/ConfirmPayment/index.tsx b/src/app/screens/ConfirmPayment/index.tsx index 0cd321552c..2e99c2f612 100644 --- a/src/app/screens/ConfirmPayment/index.tsx +++ b/src/app/screens/ConfirmPayment/index.tsx @@ -133,52 +133,58 @@ function ConfirmPayment() { }); } + function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + confirm(); + } + return (
{!successMessage ? ( -
- {navState.origin && ( - - )} -
-
- -
+
+
{navState.origin && ( - { - setRememberMe(event.target.checked); - }} - budget={budget} - onBudgetChange={(event) => setBudget(event.target.value)} + )} +
+
+ +
+ {navState.origin && ( + { + setRememberMe(event.target.checked); + }} + budget={budget} + onBudgetChange={(event) => setBudget(event.target.value)} + /> + )} +
-
-
- -

- {tComponents("only_trusted")} -

-
+
+ +

+ {tComponents("only_trusted")} +

+
+ ) : ( diff --git a/src/app/screens/ConfirmRequestPermission/index.tsx b/src/app/screens/ConfirmRequestPermission/index.tsx index c632497d79..eb24475350 100644 --- a/src/app/screens/ConfirmRequestPermission/index.tsx +++ b/src/app/screens/ConfirmRequestPermission/index.tsx @@ -35,52 +35,58 @@ const ConfirmRequestPermission: FC = () => { msg.error(USER_REJECTED_ERROR); }; + function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + enable(); + } + return (
-
- +
+
+ -
-

{t("allow", { host: origin.host })}

-
- -

- {t("enable_method", { method: requestMethod })} -

-
-
- setAlwaysAllow((prev) => !prev)} - /> - +
+

{t("allow", { host: origin.host })}

+
+ +

+ {t("enable_method", { method: requestMethod })} +

+
+
+ setAlwaysAllow((prev) => !prev)} + /> + +
-
-
- -
+
+ +
+
); diff --git a/src/app/screens/ConfirmSignMessage/index.tsx b/src/app/screens/ConfirmSignMessage/index.tsx index 7c8c5b2440..b41e6d8c87 100644 --- a/src/app/screens/ConfirmSignMessage/index.tsx +++ b/src/app/screens/ConfirmSignMessage/index.tsx @@ -65,6 +65,11 @@ function ConfirmSignMessage() { } } + function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + confirm(); + } + return (
@@ -101,12 +106,13 @@ function ConfirmSignMessage() {
*/}
- +
+ +
) : ( diff --git a/src/app/screens/Enable/index.tsx b/src/app/screens/Enable/index.tsx index 78b2cd1664..b238252c95 100644 --- a/src/app/screens/Enable/index.tsx +++ b/src/app/screens/Enable/index.tsx @@ -74,6 +74,11 @@ function Enable(props: Props) { } }, [enable, props.origin.domain, props.origin.host]); + function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + enable(); + } + return (
@@ -100,20 +105,21 @@ function Enable(props: Props) {
diff --git a/src/app/screens/Keysend/index.tsx b/src/app/screens/Keysend/index.tsx index ce29446fad..057fb4c5da 100644 --- a/src/app/screens/Keysend/index.tsx +++ b/src/app/screens/Keysend/index.tsx @@ -89,6 +89,11 @@ function Keysend() { navigate(-1); } + function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + confirm(); + } + return (
-
- {destination && } - -
- setAmountSat(e.target.value)} - value={amountSat} - fiatValue={fiatAmount} +
+
+ {destination && } + - +
+ setAmountSat(e.target.value)} + value={amountSat} + fiatValue={fiatAmount} + /> + +
-
- + + ) : ( diff --git a/src/app/screens/LNURLAuth/index.tsx b/src/app/screens/LNURLAuth/index.tsx index 2a690b5129..00d6d0cab2 100644 --- a/src/app/screens/LNURLAuth/index.tsx +++ b/src/app/screens/LNURLAuth/index.tsx @@ -88,6 +88,11 @@ function LNURLAuth() { navigate(-1); } + function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + confirm(); + } + return (
@@ -118,13 +123,14 @@ function LNURLAuth() {
- +
+ +

{tComponents("only_trusted")} diff --git a/src/app/screens/LNURLChannel/index.tsx b/src/app/screens/LNURLChannel/index.tsx index 24b92fcb42..307aa9f277 100644 --- a/src/app/screens/LNURLChannel/index.tsx +++ b/src/app/screens/LNURLChannel/index.tsx @@ -96,6 +96,11 @@ function LNURLChannel() { } } + function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + confirm(); + } + return (

@@ -118,12 +123,13 @@ function LNURLChannel() {
- +
+ +

{tComponents("only_trusted")} diff --git a/src/app/screens/LNURLWithdraw/index.tsx b/src/app/screens/LNURLWithdraw/index.tsx index 31e0fcc26b..23c4ac1c74 100644 --- a/src/app/screens/LNURLWithdraw/index.tsx +++ b/src/app/screens/LNURLWithdraw/index.tsx @@ -143,6 +143,11 @@ function LNURLWithdraw() { navigate(-1); } + function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + confirm(); + } + return (

@@ -161,12 +166,13 @@ function LNURLWithdraw() { {renderAmount()}
- +
+ + ) : ( diff --git a/src/app/screens/MakeInvoice/index.tsx b/src/app/screens/MakeInvoice/index.tsx index db3758ffd3..9a33cfb072 100644 --- a/src/app/screens/MakeInvoice/index.tsx +++ b/src/app/screens/MakeInvoice/index.tsx @@ -97,74 +97,80 @@ function MakeInvoice() { msg.error(USER_REJECTED_ERROR); } + function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + confirm(); + } + return (
-
- - -
-
- {amountEditable ? ( -
- handleValueChange(e.target.value)} - fiatValue={fiatValue} +
+
+ + +
+
+ {amountEditable ? ( +
+ handleValueChange(e.target.value)} + fiatValue={fiatValue} + /> + +
+ ) : ( +
+
{t("amount.label")}
+
{invoiceAttributes.amount}
+
+ )} + + {error &&

{error}

} +
+ +
+ {memoEditable ? ( + - -
- ) : ( -
-
{t("amount.label")}
-
{invoiceAttributes.amount}
-
- )} - - {error &&

{error}

} + ) : ( +
+
{t("memo.label")}
+
{invoiceAttributes.memo}
+
+ )} +
+
-
- {memoEditable ? ( - - ) : ( -
-
{t("memo.label")}
-
{invoiceAttributes.memo}
-
- )} -
+
+ + +

+ {tComponents("confirm_or_cancel.only_trusted")} +

-
- -
- - -

- {tComponents("confirm_or_cancel.only_trusted")} -

-
+
); diff --git a/src/app/screens/Nostr/Confirm.tsx b/src/app/screens/Nostr/Confirm.tsx index 746a9ea4fe..51f8f55131 100644 --- a/src/app/screens/Nostr/Confirm.tsx +++ b/src/app/screens/Nostr/Confirm.tsx @@ -47,64 +47,70 @@ function NostrConfirm() { msg.error(USER_REJECTED_ERROR); } + function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + confirm(); + } + return (
-
- -
-

{t("allow", { host: origin.host })}

-

- - {description} - {details && ( - <> -
- {details} - - )} -

-
+
+
+ +
+

{t("allow", { host: origin.host })}

+

+ + {description} + {details && ( + <> +
+ {details} + + )} +

+
-
- { - setRememberPermission(event.target.checked); - }} +
+ { + setRememberPermission(event.target.checked); + }} + /> + +
+
+
+ - + {t("block_and_ignore", { host: origin.host })} +
-
- +
); diff --git a/src/app/screens/Nostr/ConfirmGetPublicKey.tsx b/src/app/screens/Nostr/ConfirmGetPublicKey.tsx index f5691f2a6c..1af7b8a85c 100644 --- a/src/app/screens/Nostr/ConfirmGetPublicKey.tsx +++ b/src/app/screens/Nostr/ConfirmGetPublicKey.tsx @@ -45,6 +45,11 @@ function NostrConfirmGetPublicKey() { msg.error(USER_REJECTED_ERROR); } + function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + confirm(); + } + return (
@@ -66,39 +71,40 @@ function NostrConfirmGetPublicKey() {
-
- { - setRememberPermission(event.target.checked); - }} - /> - -
+
+
+ { + setRememberPermission(event.target.checked); + }} + /> + +
- + +
); diff --git a/src/app/screens/Nostr/ConfirmSignMessage.tsx b/src/app/screens/Nostr/ConfirmSignMessage.tsx index 5b30feacb3..20cec6c4ae 100644 --- a/src/app/screens/Nostr/ConfirmSignMessage.tsx +++ b/src/app/screens/Nostr/ConfirmSignMessage.tsx @@ -60,44 +60,50 @@ function ConfirmSignMessage() { } } + function handleSubmit(event: React.FormEvent) { + event.preventDefault(); + confirm(); + } + return (
{!successMessage ? ( -
- - -
- { - setRememberPermission(event.target.checked); - }} +
+
+ - + +
+ { + setRememberPermission(event.target.checked); + }} + /> + +
-
- + + ) : (