import { ExternalLinkIcon, HandCoinsIcon, MoreHorizontalIcon, ScaleIcon, Trash2Icon, } from "lucide-react"; import React from "react"; import { useSearchParams } from "react-router"; import { CloseChannelDialogContent } from "src/components/CloseChannelDialogContent"; import ExternalLink from "src/components/ExternalLink"; import { RebalanceChannelDialogContent } from "src/components/RebalanceChannelDialogContent"; import { RoutingFeeDialogContent } from "src/components/RoutingFeeDialogContent"; import { AlertDialog, AlertDialogTrigger, } from "src/components/ui/alert-dialog"; import { Button } from "src/components/ui/button.tsx"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "src/components/ui/dropdown-menu.tsx"; import { useInfo } from "src/hooks/useInfo"; import { Channel } from "src/types"; type ChannelDropdownMenuProps = { alias: string; channel: Channel; hasMultipleChannels: boolean; }; export function ChannelDropdownMenu({ alias, channel, hasMultipleChannels, }: ChannelDropdownMenuProps) { const { data: info } = useInfo(); const [searchParams] = useSearchParams(); const [dialog, setDialog] = React.useState< "closeChannel" | "routingFee" | "rebalance" >(); React.useEffect(() => { // when opening the swap dialog, close existing dialog if (searchParams.has("swap", "true")) { setDialog(undefined); } }, [searchParams]); return ( { if (!open) { setDialog(undefined); } }} > {channel.status == "online" && channel.remoteBalanceMsat > channel.localSpendableBalanceMsat && hasMultipleChannels && ( setDialog("rebalance")}> Rebalance In )} View Funding Transaction View Node on amboss.space {channel.public && ( setDialog("routingFee")}> Set Routing Fee )} setDialog("closeChannel")} > Close Channel {dialog === "closeChannel" && ( )} {dialog === "routingFee" && } {dialog === "rebalance" && ( setDialog(undefined)} /> )} ); }