'use client'; import { useState } from 'react'; import timeAgo from '../lib/time-ago'; import styles from './comment.module.css'; export default function Comment({ user, text, date, comments, commentsCount }) { const [toggled, setToggled] = useState(false); const toggle = () => setToggled(!toggled); return (
{user} {timeAgo(new Date(date))} ago{' '} {toggled ? `[+${(commentsCount || 0) + 1}]` : '[-]'}
{toggled ? null : [
,
{comments.map((comment) => ( ))}
, ]}
); }