Refactor to use ai/rsc (#253)

This commit is contained in:
Jeremy 2024-03-14 20:00:52 +03:00 committed by GitHub
parent 69ca8fcc22
commit e85ba803dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
66 changed files with 2799 additions and 740 deletions

View file

@ -1,10 +1,14 @@
import { type Metadata } from 'next'
import { notFound } from 'next/navigation'
import { notFound, redirect } from 'next/navigation'
import { formatDate } from '@/lib/utils'
import { getSharedChat } from '@/app/actions'
import { ChatList } from '@/components/chat-list'
import { FooterText } from '@/components/footer'
import { AI, UIState, getUIStateFromAIState } from '@/lib/chat/actions'
export const runtime = 'edge'
export const preferredRegion = 'home'
interface SharePageProps {
params: {
@ -29,11 +33,13 @@ export default async function SharePage({ params }: SharePageProps) {
notFound()
}
const uiState: UIState = getUIStateFromAIState(chat)
return (
<>
<div className="flex-1 space-y-6">
<div className="px-4 py-6 border-b bg-background md:px-6 md:py-8">
<div className="max-w-2xl mx-auto md:px-6">
<div className="border-b bg-background px-4 py-6 md:px-6 md:py-8">
<div className="mx-auto max-w-2xl">
<div className="space-y-1 md:-mx-8">
<h1 className="text-2xl font-bold">{chat.title}</h1>
<div className="text-sm text-muted-foreground">
@ -42,7 +48,9 @@ export default async function SharePage({ params }: SharePageProps) {
</div>
</div>
</div>
<ChatList messages={chat.messages} />
<AI>
<ChatList messages={uiState} />
</AI>
</div>
<FooterText className="py-8" />
</>