'use client'; import { PropsWithChildren } from 'react'; import Link from 'next/link'; import { useParams, usePathname, useRouter } from 'next/navigation'; import { cn } from '@/lib/utils'; import { ChatEntity } from '@/lib/types'; import Image from 'next/image'; import clsx from 'clsx'; import Img from '../ui/Img'; import { format } from 'date-fns'; import { cleanInputMessage } from '@/lib/messageUtils'; // import { format } from 'date-fns'; type ChatCardProps = PropsWithChildren<{ chat: ChatEntity; isAdminView?: boolean; }>; export const ChatCardLayout: React.FC< PropsWithChildren<{ link: string; classNames?: clsx.ClassValue }> > = ({ link, children, classNames }) => { return ( {children} ); }; const ChatCard: React.FC = ({ chat, isAdminView }) => { const { id: chatIdFromParam } = useParams(); const { id, url, messages, user, updatedAt } = chat; const firstMessage = cleanInputMessage(messages?.[0]?.content ?? ''); const title = firstMessage ? firstMessage.length > 50 ? firstMessage.slice(0, 50) + '...' : firstMessage : '(No messages yet)'; return (
{`chat-${id}-card-image`}

{title}

{updatedAt ? format(Number(updatedAt), 'yyyy-MM-dd') : '-'}

{isAdminView &&

{user}

}
); }; export default ChatCard;