2025-06-11 00:14:17 +02:00
|
|
|
import { LocalMessageNode } from '@colanode/client/types';
|
|
|
|
|
import { ContainerBreadcrumb } from '@colanode/ui/components/layouts/containers/container-breadrumb';
|
|
|
|
|
import { Message } from '@colanode/ui/components/messages/message';
|
|
|
|
|
import { MessageNotFound } from '@colanode/ui/components/messages/message-not-found';
|
2025-02-19 19:11:46 +01:00
|
|
|
import {
|
|
|
|
|
Container,
|
|
|
|
|
ContainerBody,
|
|
|
|
|
ContainerHeader,
|
2025-06-11 00:14:17 +02:00
|
|
|
} from '@colanode/ui/components/ui/container';
|
|
|
|
|
import { ConversationContext } from '@colanode/ui/contexts/conversation';
|
|
|
|
|
import { useNodeContainer } from '@colanode/ui/hooks/use-node-container';
|
|
|
|
|
import { useNodeRadar } from '@colanode/ui/hooks/use-node-radar';
|
2025-02-19 19:11:46 +01:00
|
|
|
|
|
|
|
|
interface MessageContainerProps {
|
|
|
|
|
messageId: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const MessageContainer = ({ messageId }: MessageContainerProps) => {
|
|
|
|
|
const data = useNodeContainer<LocalMessageNode>(messageId);
|
|
|
|
|
|
|
|
|
|
useNodeRadar(data.node);
|
|
|
|
|
|
|
|
|
|
if (data.isPending) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!data.node) {
|
|
|
|
|
return <MessageNotFound />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Container>
|
|
|
|
|
<ContainerHeader>
|
|
|
|
|
<ContainerBreadcrumb breadcrumb={data.breadcrumb} />
|
|
|
|
|
</ContainerHeader>
|
|
|
|
|
<ContainerBody>
|
|
|
|
|
<ConversationContext.Provider
|
|
|
|
|
value={{
|
|
|
|
|
id: data.node.id,
|
|
|
|
|
role: data.role,
|
|
|
|
|
rootId: data.node.rootId,
|
|
|
|
|
canCreateMessage: true,
|
|
|
|
|
onReply: () => {},
|
|
|
|
|
onLastMessageIdChange: () => {},
|
|
|
|
|
canDeleteMessage: () => false,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Message message={data.node} />
|
|
|
|
|
</ConversationContext.Provider>
|
|
|
|
|
</ContainerBody>
|
|
|
|
|
</Container>
|
|
|
|
|
);
|
|
|
|
|
};
|