diff --git a/app/chat/@sidebar/main.tsx b/app/chat/@sidebar/main.tsx index 7d06f4e..fd096ca 100644 --- a/app/chat/@sidebar/main.tsx +++ b/app/chat/@sidebar/main.tsx @@ -1,13 +1,13 @@ 'use client' import { FC } from 'react' -import { LocaleProps } from '@/interface' +import { LocaleProps, ConversationsProps } from '@/interface' import Button from '@/components/button' import PencilSquare from '@heroicons/react/24/solid/PencilSquareIcon' import MenuItem from '@/components/menu-item' import { t } from '@/i18n' -const Main: FC = ({ locale }) => { +const Main: FC = ({ locale }) => { return (
diff --git a/app/chat/@sidebar/page.tsx b/app/chat/@sidebar/page.tsx index b4f337c..2c843e8 100644 --- a/app/chat/@sidebar/page.tsx +++ b/app/chat/@sidebar/page.tsx @@ -1,11 +1,18 @@ import Main from './main' import { getLocale, client } from '@/service' +import { ConversationsProps } from '@/interface' -async function getData() {} +async function getData() { + const { status, data } = await client.getConversations() + if (status !== 200) { + throw new Error('Failed to fetch data') + } + return data as ConversationsProps +} const Sidebar = async () => { const conversations = await getData() - return
+ return
} export default Sidebar diff --git a/app/chat/page.tsx b/app/chat/page.tsx index 4ca297b..ee6eb35 100644 --- a/app/chat/page.tsx +++ b/app/chat/page.tsx @@ -3,9 +3,6 @@ import Main from './main' async function getData() { const { status, data: appInfo } = await client.getApplicationParameters() - // The return value is *not* serialized - // You can return Date, Map, Set, etc. - // Recommendation: handle errors if (status !== 200) { // This will activate the closest `error.js` Error Boundary throw new Error('Failed to fetch data') diff --git a/interface/index.ts b/interface/index.ts index 265c3a9..ee5b14d 100644 --- a/interface/index.ts +++ b/interface/index.ts @@ -23,5 +23,7 @@ export interface ConversationProps { } export interface ConversationsProps { - conversations: ConversationProps[] + data: ConversationProps[] + has_more: boolean + limit: number }