import * as React from 'react' import { shareChat } from '@/app/actions' import { Button } from './ui/button' import { PromptForm } from './prompt-form' import { ButtonScrollToBottom } from './button-scroll-to-bottom' import { IconShare } from './ui/icons' import { FooterText } from './footer' import { ChatShareDialog } from './chat-share-dialog' import { useAIState, useActions, useUIState } from '@aigxion/isdk/rsc' import type { AI } from '@/lib/chat/actions' import { nanoid } from 'nanoid' import { UserMessage } from './stocks/message' export interface ChatPanelProps { id?: string title?: string input: string setInput: (value: string) => void isAtBottom: boolean scrollToBottom: () => void } export function ChatPanel({ id, title, input, setInput, isAtBottom, scrollToBottom }: ChatPanelProps) { const [aiState] = useAIState() const [messages, setMessages] = useUIState() const { submitUserMessage } = useActions() const [shareDialogOpen, setShareDialogOpen] = React.useState(false) const exampleMessages = [ { heading: 'What are the', subheading: 'trending memecoins today?', message: `What are the trending memecoins today?` }, { heading: 'What is the price of', subheading: '$DOGE right now?', message: 'What is the price of $DOGE right now?' }, { heading: 'I would like to buy', subheading: '42 $DOGE', message: `I would like to buy 42 $DOGE` }, { heading: 'What are some', subheading: `recent events about $DOGE?`, message: `What are some recent events about $DOGE?` } ] return (
{messages.length === 0 && exampleMessages.map((example, index) => (
1 && 'hidden md:block' }`} onClick={async () => { setMessages((currentMessages: any) => [ ...currentMessages, { id: nanoid(), display: {example.message} } ]) const responseMessage = await submitUserMessage( example.message ) setMessages((currentMessages: any) => [ ...currentMessages, responseMessage ]) }} >
{example.heading}
{example.subheading}
))}
{messages?.length >= 2 ? (
{id && title ? ( <> setShareDialogOpen(false)} shareChat={shareChat} chat={{ id, title, messages: aiState.messages }} /> ) : null}
) : null}
) }