generated from pinecone-io/pinecone-vercel-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
121 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/app/(root)/(routes)/results/components/chat-components-wrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
"use client"; | ||
import React, { useState } from "react"; | ||
import ChatComponent from "./chat-component"; | ||
|
||
interface SearchResult { | ||
id: string; | ||
caseName: string; | ||
caseNeutralCit: string; | ||
caseActionNo: string; | ||
caseDate: Date; // or string, if you are using ISO date strings | ||
caseUrl: string; | ||
createdAt: Date; // or string, for ISO date strings | ||
searchId: string; | ||
userId: string; | ||
} | ||
|
||
const ChatComponentsWrapper = ({ | ||
searchResults, | ||
searchMetadataQuery, | ||
}: { | ||
searchResults: SearchResult[]; | ||
searchMetadataQuery: string; | ||
}) => { | ||
const [activeChatId, setActiveChatId] = useState(null); | ||
|
||
const toggleIframe = (chatId: any) => { | ||
setActiveChatId(activeChatId === chatId ? null : chatId); | ||
}; | ||
|
||
return ( | ||
<div className="flex overflow-x-auto h-full w-full"> | ||
{searchResults.map((result) => ( | ||
<div | ||
key={result.id} | ||
className={`flex-none ${ | ||
activeChatId === result.id ? "w-full" : "w-1/3" | ||
} border-r h-full ${ | ||
activeChatId !== null && activeChatId !== result.id ? "hidden" : "" | ||
}`} | ||
> | ||
<ChatComponent | ||
key={result.id} | ||
data={result} | ||
query={searchMetadataQuery} | ||
isIframeShown={activeChatId === result.id} | ||
onToggleIframe={() => toggleIframe(result.id)} | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ChatComponentsWrapper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters