snort/src/Element/ZapButton.tsx

33 lines
928 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";
2023-02-07 13:32:32 +00:00
import SendSats from "Element/SendSats";
2023-01-19 00:03:24 +00:00
const ZapButton = ({ pubkey, svc }: { pubkey?: HexKey; svc?: string }) => {
const profile = useUserProfile(pubkey!);
const [zap, setZap] = useState(false);
const service = svc ?? (profile?.lud16 || profile?.lud06);
if (!service) return null;
2023-01-19 00:03:24 +00:00
return (
<>
<div className="zap-button" onClick={(e) => setZap(true)}>
<FontAwesomeIcon icon={faBolt} />
</div>
<SendSats
target={profile?.display_name || profile?.name}
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;