-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathDuplicateChannelAlert.tsx
47 lines (41 loc) · 1.34 KB
/
DuplicateChannelAlert.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { AlertCircleIcon } from "lucide-react";
import ExternalLink from "src/components/ExternalLink";
import { Alert, AlertDescription, AlertTitle } from "src/components/ui/alert";
import { useChannels } from "src/hooks/useChannels";
type PeerAlertProps = {
pubkey?: string;
name?: string;
};
export function DuplicateChannelAlert({ pubkey, name }: PeerAlertProps) {
const { data: channels } = useChannels();
if (!pubkey) {
return null;
}
const matchedPeer = channels?.find((p) => p.remotePubkey === pubkey);
if (!matchedPeer) {
return null;
}
return (
<Alert variant={"destructive"}>
<AlertCircleIcon className="h-4 w-4" />
<AlertTitle>
You already have a channel with{" "}
{name && name !== "Custom" ? (
<span className="font-semibold">{name}</span>
) : (
"the selected peer"
)}
</AlertTitle>
<AlertDescription>
There are other options available rather than opening multiple channels
with the same counterparty.{" "}
<ExternalLink
to="https://guides.getalby.com/user-guide/alby-account-and-browser-extension/alby-hub/faq-alby-hub/should-i-open-multiple-channels-with-the-same-counterparty"
className="underline"
>
Learn more
</ExternalLink>
</AlertDescription>
</Alert>
);
}