import { NostrEvent } from '@nostr-dev-kit/ndk' import { ZapPopUp } from 'components/Zap' import { useAppSelector, useNDKContext, useBodyScrollDisable, useDidMount } from 'hooks' import { useState } from 'react' import { toast } from 'react-toastify' import { abbreviateNumber } from 'utils' export const Zap = (props: NostrEvent) => { const [isOpen, setIsOpen] = useState(false) const [totalZappedAmount, setTotalZappedAmount] = useState(0) const [hasZapped, setHasZapped] = useState(false) const userState = useAppSelector((state) => state.user) const { getTotalZapAmount } = useNDKContext() useBodyScrollDisable(isOpen) useDidMount(() => { getTotalZapAmount( props.pubkey, props.id!, undefined, userState.user?.pubkey as string ) .then((res) => { setTotalZappedAmount(res.accumulatedZapAmount) setHasZapped(res.hasZapped) }) .catch((err) => { toast.error(err.message || err) }) }) return ( <>
setIsOpen(true)} >

{abbreviateNumber(totalZappedAmount)}

{isOpen && ( setIsOpen(false)} setTotalZapAmount={setTotalZappedAmount} setHasZapped={setHasZapped} /> )} ) }