import { dbInternalGetAllMessageByDate } from '@/lib/db/functions';
import MessageGrid from '@/components/internal/MessageGrid';
import { MessageFilterParams } from '@/lib/types';

export interface MessageGridServerProps {
  messageFilter: MessageFilterParams;
}

export default async function MessageGridServer({
  messageFilter,
}: MessageGridServerProps) {
  const messages = await dbInternalGetAllMessageByDate(messageFilter);
  if (!messages.length) {
    return <p className="text-sm italic">No messages</p>;
  }
  return <MessageGrid messages={messages} />;
}
