import { NDKKind } from '@nostr-dev-kit/ndk'; import * as Popover from '@radix-ui/react-popover'; import { useState } from 'react'; import { ReactionIcon } from '@shared/icons'; import { useNostr } from '@utils/hooks/useNostr'; 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({ id, pubkey }: { id: string; pubkey: string }) { const [open, setOpen] = useState(false); const [reaction, setReaction] = useState(null); const { publish } = useNostr(); const getReactionImage = (content: string) => { const reaction: { img: string } = REACTIONS.find((el) => el.content === content); return reaction.img; }; const react = async (content: string) => { setReaction(content); const event = await publish({ content: content, kind: NDKKind.Reaction, tags: [ ['e', id], ['p', pubkey], ], }); if (event) { setOpen(false); } }; return (
); }