snort/src/Element/ZapButton.tsx

28 lines
878 B
TypeScript
Raw Normal View History

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";
import { useUserProfile } from "Feed/ProfileFeed";
2023-01-20 11:11:50 +00:00
import { HexKey } from "Nostr";
import LNURLTip from "Element/LNURLTip";
2023-01-19 00:03:24 +00:00
const ZapButton = ({ pubkey, svc }: { pubkey?: HexKey, svc?: string }) => {
const profile = useUserProfile(pubkey!)
2023-01-19 00:03:24 +00:00
const [zap, setZap] = useState(false);
const service = svc ?? (profile?.lud16 || profile?.lud06);
2023-01-19 00:03:24 +00:00
if (!service) return null;
2023-01-19 00:03:24 +00:00
return (
<>
2023-01-19 11:14:41 +00:00
<div className="zap-button" onClick={(e) => setZap(true)}>
2023-01-19 00:03:24 +00:00
<FontAwesomeIcon icon={faBolt} />
2023-01-18 23:31:34 +00:00
</div>
2023-02-03 22:10:02 +00:00
<LNURLTip svc={service} 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;