From aa8a18501891ae075030a056bd9cd3b14ba97205 Mon Sep 17 00:00:00 2001 From: crazywoola Date: Tue, 20 Jun 2023 13:41:29 +0800 Subject: [PATCH] feat: add interfaces --- app/chat/@sidebar/main.tsx | 19 +++++++++---------- app/chat/@sidebar/page.tsx | 6 +++++- app/chat/main.tsx | 20 +++----------------- interface/index.ts | 27 +++++++++++++++++++++++++++ service/index.ts | 2 +- 5 files changed, 45 insertions(+), 29 deletions(-) create mode 100644 interface/index.ts diff --git a/app/chat/@sidebar/main.tsx b/app/chat/@sidebar/main.tsx index 62b223c..7d06f4e 100644 --- a/app/chat/@sidebar/main.tsx +++ b/app/chat/@sidebar/main.tsx @@ -1,15 +1,13 @@ 'use client' import { FC } from 'react' +import { LocaleProps } 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' -interface ExtraProps { - locale: string -} -const Main: FC = ({ locale }) => { +const Main: FC = ({ locale }) => { return (
@@ -32,14 +30,15 @@ const Main: FC = ({ locale }) => {
-
+
{t('app.chats', locale)}
- - {}} /> - {}} /> - {}} /> - {}} /> +
+ {}} /> + {}} /> + {}} /> + {}} /> +
) diff --git a/app/chat/@sidebar/page.tsx b/app/chat/@sidebar/page.tsx index febfabd..b4f337c 100644 --- a/app/chat/@sidebar/page.tsx +++ b/app/chat/@sidebar/page.tsx @@ -1,7 +1,11 @@ import Main from './main' +import { getLocale, client } from '@/service' + +async function getData() {} const Sidebar = async () => { - return
+ const conversations = await getData() + return
} export default Sidebar diff --git a/app/chat/main.tsx b/app/chat/main.tsx index 345cd9d..05d9427 100644 --- a/app/chat/main.tsx +++ b/app/chat/main.tsx @@ -1,23 +1,9 @@ 'use client' import { FC } from 'react' +import { AppProps, LocaleProps } from '@/interface' -export interface AppProps { - opening_statement: string - suggested_questions: any[] - suggested_questions_after_answer: { - enabled: boolean - } - more_like_this: { - enabled: boolean - } - user_input_form: any[] -} -interface ExtraProps { - locale: string -} - -const Main: FC = ({ locale }) => { - return
{locale}
+const Main: FC = ({}) => { + return
} export default Main diff --git a/interface/index.ts b/interface/index.ts new file mode 100644 index 0000000..265c3a9 --- /dev/null +++ b/interface/index.ts @@ -0,0 +1,27 @@ +export interface LocaleProps { + locale: string +} + +export interface AppProps { + opening_statement: string + suggested_questions: any[] + suggested_questions_after_answer: { + enabled: boolean + } + more_like_this: { + enabled: boolean + } + user_input_form: any[] +} + +export interface ConversationProps { + id: string + inputs: any + introduction: string + name: string + status: string +} + +export interface ConversationsProps { + conversations: ConversationProps[] +} diff --git a/service/index.ts b/service/index.ts index ba5d6e3..c9636f1 100644 --- a/service/index.ts +++ b/service/index.ts @@ -5,6 +5,6 @@ dotenv.config() export const getLocale = () => { const cookieStore = cookies() - return cookieStore.get('locale')?.value + return cookieStore.get('locale')?.value || 'en' // default to english } export const client = new ChatClient(process.env.API_SECRET)