snort/packages/app/src/Element/ZapButton.tsx

38 lines
1.0 KiB
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";
2023-02-25 21:18:36 +00:00
import { useLongPress } from "use-long-press";
import { useUserProfile } from "Feed/ProfileFeed";
2023-02-11 20:05:46 +00:00
import { HexKey } from "@snort/nostr";
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);
const [zap, setZap] = useState(false);
2023-02-25 21:18:36 +00:00
const service = lnurl ?? (profile?.lud16 || profile?.lud06);
const longPress = useLongPress(() => {
console.debug("long press");
});
if (!service) return null;
2023-01-19 00:03:24 +00:00
return (
<>
2023-02-25 21:18:36 +00:00
<div className="zap-button" {...longPress()}>
<FontAwesomeIcon icon={faBolt} />
</div>
<SendSats
target={profile?.display_name || profile?.name}
2023-02-25 21:18:36 +00:00
lnurl={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;