diff --git a/public/logo.png b/public/logo.png new file mode 100644 index 0000000..5cd9e65 Binary files /dev/null and b/public/logo.png differ diff --git a/src/app/ask/page.tsx b/src/app/ask/page.tsx index 73e776b..2be2498 100644 --- a/src/app/ask/page.tsx +++ b/src/app/ask/page.tsx @@ -1,15 +1,28 @@ 'use client'; import { useChat } from 'ai/react'; -import { useState } from 'react'; +import { useState, useEffect, Suspense } from 'react'; import NavBar from '../component/navbar'; +import { useSearchParams } from 'next/navigation'; - -export default function Home() { +// Create a separate component for the content +const ChatContent = () => { const [waitingForAI, setWaitingForAI] = useState(false); - const { messages, input, handleInputChange, handleSubmit } = useChat(); - + const searchParams = useSearchParams(); + const analysisData = searchParams?.get('data') ?? ''; + + const { messages, input, handleInputChange, handleSubmit } = useChat({ + initialMessages: analysisData ? [ + { + id: 'analysis', + role: 'system', + content: analysisData + } + ] : [] + }); + if (!searchParams) return null; + return (
@@ -29,9 +42,7 @@ export default function Home() { {messages.length == 0 && (
- - + - +
) } @@ -60,11 +71,12 @@ export default function Home() {
+
); -} +}; + +// Main page component with Suspense +const ChatPage = () => { + return ( + Loading...
}> + + + ); +}; + +export default ChatPage; diff --git a/src/app/component/navbar.tsx b/src/app/component/navbar.tsx index d66004d..d6637e0 100644 --- a/src/app/component/navbar.tsx +++ b/src/app/component/navbar.tsx @@ -6,22 +6,21 @@ const NavBar: React.FC = () => { return ( );