@@ -3,14 +3,21 @@ import TrashIcon from '../svg/TrashIcon';
3
3
import CrossIcon from '../svg/CrossIcon' ;
4
4
import { useRecoilValue } from 'recoil' ;
5
5
import { useDeleteConversationMutation } from 'librechat-data-provider' ;
6
-
6
+ import { Dialog , DialogTrigger , Label } from '~/components/ui/' ;
7
+ import DialogTemplate from '~/components/ui/DialogTemplate' ;
7
8
import store from '~/store' ;
9
+ import { useLocalize } from '~/hooks' ;
8
10
9
- export default function DeleteButton ( { conversationId, renaming, cancelHandler, retainView } ) {
11
+ export default function DeleteButton ( { conversationId, renaming, retainView, title } ) {
12
+ const localize = useLocalize ( ) ;
10
13
const currentConversation = useRecoilValue ( store . conversation ) || { } ;
11
14
const { newConversation } = store . useConversation ( ) ;
12
15
const { refreshConversations } = store . useConversations ( ) ;
13
16
17
+ const confirmDelete = ( ) => {
18
+ deleteConvoMutation . mutate ( { conversationId, source : 'button' } ) ;
19
+ } ;
20
+
14
21
const deleteConvoMutation = useDeleteConversationMutation ( conversationId ) ;
15
22
16
23
useEffect ( ( ) => {
@@ -25,15 +32,31 @@ export default function DeleteButton({ conversationId, renaming, cancelHandler,
25
32
// eslint-disable-next-line react-hooks/exhaustive-deps
26
33
} , [ deleteConvoMutation . isSuccess ] ) ;
27
34
28
- const clickHandler = ( ) => {
29
- deleteConvoMutation . mutate ( { conversationId, source : 'button' } ) ;
30
- } ;
31
-
32
- const handler = renaming ? cancelHandler : clickHandler ;
33
-
34
35
return (
35
- < button className = "p-1 hover:text-white" onClick = { handler } >
36
- { renaming ? < CrossIcon /> : < TrashIcon /> }
37
- </ button >
36
+ < Dialog >
37
+ < DialogTrigger asChild >
38
+ < button className = "p-1 hover:text-white" > { renaming ? < CrossIcon /> : < TrashIcon /> } </ button >
39
+ </ DialogTrigger >
40
+ < DialogTemplate
41
+ title = { localize ( 'com_ui_delete_conversation' ) }
42
+ className = "max-w-[450px]"
43
+ main = {
44
+ < >
45
+ < div className = "flex w-full flex-col items-center gap-2" >
46
+ < div className = "grid w-full items-center gap-2" >
47
+ < Label htmlFor = "chatGptLabel" className = "text-left text-sm font-medium" >
48
+ { localize ( 'com_ui_delete_conversation_confirm' ) } < strong > { title } </ strong >
49
+ </ Label >
50
+ </ div >
51
+ </ div >
52
+ </ >
53
+ }
54
+ selection = { {
55
+ selectHandler : confirmDelete ,
56
+ selectClasses : 'bg-red-600 hover:bg-red-700 dark:hover:bg-red-800 text-white' ,
57
+ selectText : localize ( 'com_ui_delete' ) ,
58
+ } }
59
+ />
60
+ </ Dialog >
38
61
) ;
39
62
}
0 commit comments