import { NDKEvent } from '@nostr-dev-kit/ndk'; import * as Popover from '@radix-ui/react-popover'; import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { toast } from 'sonner'; import { useNDK } from '@libs/ndk/provider'; import { ReactionIcon } from '@shared/icons'; const REACTIONS = [ { content: '👏', img: '/clapping_hands.png', }, { content: '🤪', img: '/face_with_tongue.png', }, { content: '😮', img: '/face_with_open_mouth.png', }, { content: '😢', img: '/crying_face.png', }, { content: '🤡', img: '/clown_face.png', }, ]; export function NoteReaction({ event }: { event: NDKEvent }) { const [open, setOpen] = useState(false); const [reaction, setReaction] = useState(null); const { ndk } = useNDK(); const navigate = useNavigate(); const getReactionImage = (content: string) => { const reaction: { img: string } = REACTIONS.find((el) => el.content === content); return reaction.img; }; const react = async (content: string) => { try { if (!ndk.signer) return navigate('/new/privkey'); setReaction(content); // react await event.react(content); setOpen(false); } catch (e) { toast.error(e); } }; return (
); }