From f1fb388949ed6ed1ba15b2c58dc90c409a0daaaf Mon Sep 17 00:00:00 2001 From: im-adithya Date: Fri, 19 Jul 2024 12:46:48 +0530 Subject: [PATCH] chore: add alerts to wallet screen --- frontend/src/screens/wallet/Receive.tsx | 2 +- frontend/src/screens/wallet/Send.tsx | 5 ++-- frontend/src/screens/wallet/index.tsx | 36 ++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/frontend/src/screens/wallet/Receive.tsx b/frontend/src/screens/wallet/Receive.tsx index c6d84ec1..aa69c268 100644 --- a/frontend/src/screens/wallet/Receive.tsx +++ b/frontend/src/screens/wallet/Receive.tsx @@ -128,7 +128,7 @@ export default function Receive() { description="Create a lightning invoice that can be paid by any bitcoin lightning wallet" /> {hasChannelManagement && - parseInt(amount || "0") * 1000 > + parseInt(amount || "0") * 1000 >= 0.8 * balances.lightning.totalReceivable && ( diff --git a/frontend/src/screens/wallet/Send.tsx b/frontend/src/screens/wallet/Send.tsx index e8e32d7e..f8adb185 100644 --- a/frontend/src/screens/wallet/Send.tsx +++ b/frontend/src/screens/wallet/Send.tsx @@ -120,9 +120,8 @@ export default function Send() { title="Send" description="Pay a lightning invoice created by any bitcoin lightning wallet" /> - {invoiceDetails && - hasChannelManagement && - invoiceDetails.satoshi * 1000 > + {hasChannelManagement && + (invoiceDetails?.satoshi || 0) * 1000 >= 0.8 * balances.lightning.totalSpendable && ( diff --git a/frontend/src/screens/wallet/index.tsx b/frontend/src/screens/wallet/index.tsx index eb35a6d8..0bb09225 100644 --- a/frontend/src/screens/wallet/index.tsx +++ b/frontend/src/screens/wallet/index.tsx @@ -1,10 +1,20 @@ -import { ArrowDownIcon, ArrowUpIcon, CreditCard } from "lucide-react"; +import { + AlertTriangle, + ArrowDownIcon, + ArrowUpIcon, + CreditCard, +} from "lucide-react"; import { Link } from "react-router-dom"; import AppHeader from "src/components/AppHeader"; import BreezRedeem from "src/components/BreezRedeem"; import ExternalLink from "src/components/ExternalLink"; import Loading from "src/components/Loading"; import TransactionsList from "src/components/TransactionsList"; +import { + Alert, + AlertDescription, + AlertTitle, +} from "src/components/ui/alert.tsx"; import { Button } from "src/components/ui/button"; import { useBalances } from "src/hooks/useBalances"; import { useInfo } from "src/hooks/useInfo"; @@ -20,6 +30,30 @@ function Wallet() { return ( <> + {!balances.lightning.totalSpendable && ( + + + Low spending balance + + You won't be able to make payments until you{" "} + + increase your spending balance. + + + + )} + {!balances.lightning.totalReceivable && ( + + + Low receiving capacity + + You won't be able to receive payments until you{" "} + + increase your receiving capacity. + + + + )}