forked from chatboxai/chatbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCleanWindow.tsx
More file actions
35 lines (33 loc) · 1.22 KB
/
Copy pathCleanWindow.tsx
File metadata and controls
35 lines (33 loc) · 1.22 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
import {
Button, Dialog, DialogContent, DialogActions, DialogTitle, DialogContentText,
} from '@mui/material';
import { Session } from './types'
import { useTranslation } from "react-i18next";
interface Props {
open: boolean
session: Session
save(session: Session): void
close(): void
}
export default function CleanWindow(props: Props) {
const { t } = useTranslation()
const clean = () => {
const messages = props.session.messages.filter(msg => msg.role === 'system')
props.save({ ...props.session, messages })
}
return (
<Dialog open={props.open} onClose={props.close}>
<DialogTitle>{t('clean')}</DialogTitle>
<DialogContent>
<DialogContentText>
{t('this action will permanently delete all non-system messages in')} [{props.session.name}] {t('clean alert end')}
{t('are you sure you want to continue?')}
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={props.close}>{t('cancel')}</Button>
<Button onClick={clean} color="error">{t('clean it up')}</Button>
</DialogActions>
</Dialog>
)
}