2023-01-19 11:14:41 +00:00
|
|
|
import "./ZapButton.css";
|
2023-01-19 00:03:24 +00:00
|
|
|
import { faBolt } from "@fortawesome/free-solid-svg-icons";
|
|
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
|
|
import { useState } from "react";
|
2023-03-03 11:56:03 +00:00
|
|
|
import { HexKey } from "@snort/nostr";
|
2023-02-25 21:18:36 +00:00
|
|
|
|
2023-01-27 21:38:41 +00:00
|
|
|
import { useUserProfile } from "Feed/ProfileFeed";
|
2023-02-07 13:32:32 +00:00
|
|
|
import SendSats from "Element/SendSats";
|
2023-01-19 00:03:24 +00:00
|
|
|
|
2023-02-25 21:18:36 +00:00
|
|
|
const ZapButton = ({ pubkey, lnurl }: { pubkey: HexKey; lnurl?: string }) => {
|
2023-02-07 19:47:57 +00:00
|
|
|
const profile = useUserProfile(pubkey);
|
2023-02-07 20:04:50 +00:00
|
|
|
const [zap, setZap] = useState(false);
|
2023-02-25 21:18:36 +00:00
|
|
|
const service = lnurl ?? (profile?.lud16 || profile?.lud06);
|
2023-02-07 20:04:50 +00:00
|
|
|
if (!service) return null;
|
2023-01-19 00:03:24 +00:00
|
|
|
|
2023-02-07 20:04:50 +00:00
|
|
|
return (
|
|
|
|
<>
|
2023-03-03 11:56:03 +00:00
|
|
|
<div className="zap-button" onClick={() => setZap(true)}>
|
2023-02-07 20:04:50 +00:00
|
|
|
<FontAwesomeIcon icon={faBolt} />
|
|
|
|
</div>
|
|
|
|
<SendSats
|
|
|
|
target={profile?.display_name || profile?.name}
|
2023-02-25 21:18:36 +00:00
|
|
|
lnurl={service}
|
2023-02-07 20:04:50 +00:00
|
|
|
show={zap}
|
|
|
|
onClose={() => setZap(false)}
|
|
|
|
author={pubkey}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
2023-01-19 00:03:24 +00:00
|
|
|
|
2023-01-19 11:14:41 +00:00
|
|
|
export default ZapButton;
|