From c160e7b97d96bcd6f78ab4c395adb192656026c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Aaron?= Date: Tue, 24 Sep 2024 23:02:15 +0200 Subject: [PATCH] fix: receiver component --- components/Receiver.tsx | 29 +++++++++++++++++++++++++++++ pages/send/ConfirmPayment.tsx | 19 ++----------------- pages/send/LNURLPay.tsx | 34 ++++++++++++---------------------- pages/send/PaymentSuccess.tsx | 12 ++---------- pages/send/Send.tsx | 8 +------- 5 files changed, 46 insertions(+), 56 deletions(-) create mode 100644 components/Receiver.tsx diff --git a/components/Receiver.tsx b/components/Receiver.tsx new file mode 100644 index 0000000..feb26c5 --- /dev/null +++ b/components/Receiver.tsx @@ -0,0 +1,29 @@ +import React from "react"; +import { View } from "react-native"; +import { Text } from "~/components/ui/text"; + +interface ReceiverProps { + originalText: string; + invoice?: string; +} + +export function Receiver({ originalText, invoice }: ReceiverProps) { + const shouldShowReceiver = + originalText !== invoice && + originalText.toLowerCase().replace("lightning:", "").includes("@"); + + if (!shouldShowReceiver) { + return null; + } + + return ( + + + To + + + {originalText.toLowerCase().replace("lightning:", "")} + + + ); +} \ No newline at end of file diff --git a/pages/send/ConfirmPayment.tsx b/pages/send/ConfirmPayment.tsx index 098730a..7e4642d 100644 --- a/pages/send/ConfirmPayment.tsx +++ b/pages/send/ConfirmPayment.tsx @@ -5,6 +5,7 @@ import React from "react"; import { View } from "react-native"; import { ZapIcon } from "~/components/Icons"; import Loading from "~/components/Loading"; +import { Receiver } from "~/components/Receiver"; import Screen from "~/components/Screen"; import { Button } from "~/components/ui/button"; import { Text } from "~/components/ui/text"; @@ -94,23 +95,7 @@ export function ConfirmPayment() { ) )} - { - /* only show "To" for lightning addresses */ originalText !== - invoice && - originalText - .toLowerCase() - .replace("lightning:", "") - .includes("@") && ( - - - To - - - {originalText.toLowerCase().replace("lightning:", "")} - - - ) - } +