import { AlertTriangleIcon } from "lucide-react";
import ExternalLink from "src/components/ExternalLink";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "src/components/ui/tooltip";
import { Channel } from "src/types";
type ChannelWarningProps = {
channel: Channel;
};
export function ChannelWarning({ channel }: ChannelWarningProps) {
const capacityMsat = channel.localBalanceMsat + channel.remoteBalanceMsat;
let channelWarning = null;
if (channel.error) {
channelWarning = <> {channel.error} >;
} else if (channel.status === "opening") {
channelWarning = (
<>
{`Channel is currently being opened (${channel.confirmations} of ${channel.confirmationsRequired} confirmations). Once the required confirmation are reached, you will be able to send and receive on this channel.`}{" "}
>
);
} else if (channel.status === "offline") {
channelWarning = (
<>
This channel is currently offline and cannot be used to send or receive
payments.{" "}
Learn more here.
>
);
} else if (
channel.status === "online" &&
channel.localSpendableBalanceMsat > capacityMsat * 0.9
) {
channelWarning = (
<>
Receiving capacity low. You may have trouble receiving payments through
this channel.{" "}
Learn more here.
>
);
}
if (!channelWarning) {
return null;
}
return (
{channelWarning}
);
}