-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chat): implement comparison different versions of conversations …
- Loading branch information
1 parent
b60af4b
commit 5691525
Showing
10 changed files
with
281 additions
and
182 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, { useCallback } from 'react'; | ||
|
||
import { getPublicItemIdWithoutVersion } from '@/src/utils/server/api'; | ||
|
||
import { Conversation } from '@/src/types/chat'; | ||
import { PublicVersionOption } from '@/src/types/publication'; | ||
|
||
import { ConversationRow } from '../Common/ReplaceConfirmationModal/Components'; | ||
import { PublicVersionSelector } from './Publish/PublicVersionSelector'; | ||
|
||
import { ConversationInfo } from '@epam/ai-dial-shared'; | ||
|
||
interface ConversationCompareItemProps { | ||
conv: ConversationInfo; | ||
comparableConversations: ConversationInfo[]; | ||
selectedConversation?: Conversation; | ||
conversations: ConversationInfo[]; | ||
onConversationSelect: (conversation: ConversationInfo) => void; | ||
} | ||
|
||
export function ConversationCompareItem({ | ||
conv, | ||
comparableConversations, | ||
selectedConversation, | ||
conversations, | ||
onConversationSelect, | ||
}: ConversationCompareItemProps) { | ||
const handleConversationSelect = useCallback(() => { | ||
const selectedConversation = comparableConversations.find( | ||
(comparableConversation) => conv.id === comparableConversation.id, | ||
); | ||
|
||
if (selectedConversation) { | ||
onConversationSelect(selectedConversation); | ||
} | ||
}, [comparableConversations, conv.id, onConversationSelect]); | ||
|
||
const handleVersionChange = useCallback( | ||
(_: string, newVersion: PublicVersionOption) => { | ||
const selectedConversation = conversations.find( | ||
(conv) => conv.id === newVersion.id, | ||
); | ||
|
||
if (selectedConversation) { | ||
onConversationSelect(selectedConversation); | ||
} | ||
}, | ||
[conversations, onConversationSelect], | ||
); | ||
|
||
return ( | ||
<div | ||
key={conv.id} | ||
className="flex cursor-pointer items-center justify-between gap-4 rounded pr-[14px] hover:bg-accent-primary-alpha" | ||
data-qa="conversation-row" | ||
onClick={handleConversationSelect} | ||
> | ||
<div className="w-full truncate"> | ||
<ConversationRow | ||
featureContainerClassNames="!w-full" | ||
itemComponentClassNames="group hover:bg-transparent !pl-3 !h-[34px]" | ||
item={conv} | ||
/> | ||
</div> | ||
|
||
{conv.publicationInfo?.version && ( | ||
<PublicVersionSelector | ||
btnClassNames="cursor-pointer h-[34px] flex items-center" | ||
publicVersionGroupId={getPublicItemIdWithoutVersion( | ||
conv.publicationInfo.version, | ||
conv.id, | ||
)} | ||
excludeEntityId={selectedConversation?.id} | ||
onChangeSelectedVersion={handleVersionChange} | ||
/> | ||
)} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.