38 lines
948 B
TypeScript
38 lines
948 B
TypeScript
import block from 'bem-css-modules';
|
|
import React, { ReactNode } from 'react';
|
|
|
|
import { IChat } from '@docuservix/models/chat';
|
|
|
|
import styles from './Chat.module.css';
|
|
import { Header } from './Header';
|
|
import { Input } from './Input';
|
|
import { Messages } from './Messages';
|
|
|
|
const b = block(styles, 'Chat');
|
|
|
|
interface ChatProps {
|
|
dialog: IChat;
|
|
typing?: boolean;
|
|
statusMessage?: string;
|
|
onSend?: (text: string) => void;
|
|
}
|
|
|
|
export function Chat({ dialog, typing, statusMessage, onSend }: ChatProps): ReactNode {
|
|
const { messages } = dialog;
|
|
|
|
return (
|
|
<div className={b()}>
|
|
<Header />
|
|
<Messages
|
|
messages={messages}
|
|
typing={typing}
|
|
/>
|
|
{statusMessage && <div className={b('statusMessage')}>{statusMessage}</div>}
|
|
<Input
|
|
loading={typing}
|
|
onSend={onSend}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|