-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConversation.tsx
More file actions
69 lines (60 loc) · 1.52 KB
/
Conversation.tsx
File metadata and controls
69 lines (60 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { useTranslation } from 'react-i18next';
import {
Alert,
Box,
CircularProgress,
Divider,
Stack,
SxProps,
Theme,
} from '@mui/material';
import { ChatbotPromptSettings } from '@/config/appSetting';
import CommentEditor from '../common/CommentEditor';
import CommentThread from '../common/CommentThread';
import { Comment } from '../common/useConversation';
import ChatbotHeader from './ChatbotHeader';
import CommentContainer from './CommentContainer';
function Conversation({
threadSx,
comments,
chatbotPrompt,
isLoading,
mode = 'read',
}: Readonly<{
chatbotPrompt?: ChatbotPromptSettings;
threadSx?: SxProps<Theme>;
isLoading?: boolean;
comments: Comment[];
mode?: 'read' | 'write';
}>) {
const { t } = useTranslation();
if (chatbotPrompt) {
const { chatbotName } = chatbotPrompt;
return (
<Box
sx={{
px: { xs: 2, sm: 10 },
maxWidth: '100ch',
m: 'auto',
height: '100%',
}}
>
<CommentContainer>
<Stack gap={3} px={2}>
<ChatbotHeader name={chatbotName} />
<Divider />
<CommentThread threadSx={threadSx} comments={comments} />
{'write' === mode && (
<CommentEditor chatbotPrompt={chatbotPrompt} />
)}
</Stack>
</CommentContainer>
</Box>
);
}
if (isLoading) {
return <CircularProgress />;
}
return <Alert severity="warning">{t('CHATBOT_CONFIGURATION_MISSING')}</Alert>;
}
export default Conversation;