-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathResumeButton.tsx
56 lines (47 loc) · 1.31 KB
/
ResumeButton.tsx
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
import { useNavigate } from 'react-router-dom';
import { useRecoilValue } from 'recoil';
import { toast } from 'sonner';
import { Box, Button } from '@mui/material';
import { useChatInteract } from '@chainlit/react-client';
import { Translator } from 'components/i18n';
import WaterMark from 'components/organisms/chat/inputBox/waterMark';
import { projectSettingsState } from 'state/project';
interface Props {
threadId?: string;
}
export default function ResumeButton({ threadId }: Props) {
const navigate = useNavigate();
const pSettings = useRecoilValue(projectSettingsState);
const { clear, setIdToResume } = useChatInteract();
if (!threadId || !pSettings?.threadResumable) {
return null;
}
const onClick = () => {
clear();
setIdToResume(threadId!);
toast.success('Chat resumed!');
if (!pSettings?.dataPersistence) {
navigate('/');
}
};
return (
<Box
display="flex"
flexDirection="column"
gap={1}
p={2}
sx={{
boxSizing: 'border-box',
width: '100%',
maxWidth: '48rem',
m: 'auto',
justifyContent: 'center'
}}
>
<Button id="resumeThread" onClick={onClick} variant="contained">
<Translator path="pages.ResumeButton.resumeChat" />
</Button>
<WaterMark />
</Box>
);
}