import { CirclePlusIcon, HelpCircleIcon, InfoIcon, ShieldCheckIcon, SparklesIcon, TriangleAlertIcon, } from "lucide-react"; import { useRef, useState } from "react"; import AppHeader from "src/components/AppHeader"; import AppCard from "src/components/connections/AppCard"; import { CustomPagination } from "src/components/CustomPagination"; import { FormattedBitcoinAmount } from "src/components/FormattedBitcoinAmount"; import FormattedFiatAmount from "src/components/FormattedFiatAmount"; import Loading from "src/components/Loading"; import ResponsiveButton from "src/components/ResponsiveButton"; import ResponsiveLinkButton from "src/components/ResponsiveLinkButton"; import { Alert, AlertAction, AlertDescription, AlertTitle, } from "src/components/ui/alert"; import { Button } from "src/components/ui/button"; import { Card, CardContent, CardHeader, CardTitle, } from "src/components/ui/card"; import { ExternalLinkButton } from "src/components/ui/custom/external-link-button"; import { LinkButton } from "src/components/ui/custom/link-button"; import { UpgradeDialog } from "src/components/UpgradeDialog"; import { LIST_APPS_LIMIT, MAX_FREE_SUBWALLETS } from "src/constants"; import { useAlbyMe } from "src/hooks/useAlbyMe"; import { useApps } from "src/hooks/useApps"; import { useBalances } from "src/hooks/useBalances"; import { useInfo } from "src/hooks/useInfo"; import { SubwalletIntro } from "src/screens/subwallets/SubwalletIntro"; export function SubwalletList() { const { data: info } = useInfo(); const [page, setPage] = useState(1); const appsListRef = useRef(null); const { data: subwalletAppsData } = useApps( undefined, page, { subWallets: true, }, "created_at" ); const { data: albyMe, error: albyMeError } = useAlbyMe(); const { data: balances } = useBalances(); const handlePageChange = (page: number) => { setPage(page); appsListRef.current?.scrollIntoView({ behavior: "smooth", block: "start", }); }; if ( !info || !subwalletAppsData || !balances || (info.albyAccountConnected && !albyMe && !albyMeError) ) { return ; } const subwalletApps = subwalletAppsData.apps; if (!subwalletAppsData.totalCount) { return ; } const subwalletTotalAmountMsat = subwalletAppsData.totalBalanceMsat || 0; const isSufficientlyBacked = subwalletTotalAmountMsat <= balances.lightning.totalSpendableMsat; return (
{!albyMe?.subscription.plan_code && subwalletAppsData.totalCount >= MAX_FREE_SUBWALLETS ? ( ) : ( )} } /> {!albyMe?.subscription.plan_code && subwalletAppsData.totalCount >= MAX_FREE_SUBWALLETS && ( Need more Sub-wallets? Upgrade to Pro for unlimited sub-wallets. )} {!isSufficientlyBacked && ( Sub-wallets you manage are insufficiently backed There's not enough bitcoin in your lightning balance to honor all balances of sub-wallets under your management. Increase your lightning balance by opening a channel or review your channel statuses to back them up again. Deposit Bitcoin )}
Total Balance of Sub-wallets
Number of Sub-wallets
{subwalletAppsData.totalCount} /{" "} {albyMe?.subscription.plan_code ? "∞" : MAX_FREE_SUBWALLETS} {isSufficientlyBacked ? (
Fully backed
) : (
Insufficiently backed
)}

Managed Sub-wallets

{subwalletApps.map((app, index) => ( ))}
); }