{comment.user.name}
{comment.content}
'use client'
import React, {ReactNode, useActionState} from 'react'
import {useSession} from 'next-auth/react'
import Image from 'next/image'
import clsx from 'clsx'
import {addComment, loginWithGitHub} from '@/app/actions/comments'
import {Button} from '@/components/ui/Button'
import {GitHubIcon} from '@/components/icons/SocialIcons'
import {formatDistanceToNow} from 'date-fns'
type Comment = {
id: number
content: string
created_at: string
user: {
id: number
name: string
image: string
}
}
type CommentsListProps = {
comments: Comment[]
}
Comments.List = function List({comments}: CommentsListProps) {
return (
<>
{comments.length > 0 &&
{comment.user.name}
{comment.content}
Comments
{comments.map((comment) => (
{children}
) } type InitialState = { message: string } const initialState: InitialState = { message: '' } Comments.Form = function Form({slug}: CommentsProps) { const [state, formAction, pending] = useActionState(addComment, initialState) const {data: session} = useSession() const handleKeyDown = (e: React.KeyboardEvent