import React, { useState } from 'react'
import Tooltip from './tooltip.js'
import styles from './reactButton.module.css'
import reactions from '../data/reactions.json'
function ExistingReacts({ existingReacts, onClick, uid }) {
return (
React
{existingReacts &&
Object.keys(existingReacts).map((key) => {
const currReact = existingReacts[key]
const react = reactions[key]
if (!react) {
return null
}
return (
{
e.stopPropagation()
onClick(key, currReact.includes(uid))
}}
>
{react.emoji} {currReact.length}
)
})}
)
}
function RenderEmojis({ onClick }) {
const [search, setSearch] = useState('')
return (
<>
{
setSearch(event.target.value)
}}
/>
{Object.keys(reactions).map((key) => {
const reaction = reactions[key]
if (!key.includes(search.toLowerCase())) {
return null
}
return (
{
onClick(key)
}}
>
{reaction.emoji}
)
})}
>
)
}
export default function ReactButton({ onClick, existingReacts, uid }) {
const [opened, setOpened] = useState(false)
return (
{
setOpened(true)
}}
onMouseEnter={() => {}}
onMouseLeave={() => {
setOpened(false)
}}
>
(
{
onClick(key, isDelete)
setOpened(false)
}}
existingReacts={existingReacts}
/>
)}
>
{
// setOpened(false)
onClick(e)
}}
/>
)
}