@@ -18,14 +18,7 @@ import {
1818 DropdownMenuTrigger ,
1919} from "@/components/ui/dropdownMenu" ;
2020import { Input } from "@/components/ui/input" ;
21- import {
22- Dialog ,
23- DialogContent ,
24- DialogDescription ,
25- DialogFooter ,
26- DialogHeader ,
27- DialogTitle ,
28- } from "@/components/ui/dialog" ;
21+ import { App } from "antd" ;
2922import {
3023 Tooltip ,
3124 TooltipContent ,
@@ -68,7 +61,6 @@ const ConversationStatusIndicator = ({
6861 return null ;
6962} ;
7063
71-
7264// Helper function - dialog classification
7365const categorizeDialogs = ( dialogs : ConversationListItem [ ] ) => {
7466 const now = new Date ( ) ;
@@ -122,16 +114,13 @@ export function ChatSidebar({
122114 userRole = USER_ROLES . USER ,
123115} : ChatSidebarProps ) {
124116 const { t } = useTranslation ( ) ;
117+ const { modal } = App . useApp ( ) ;
125118 const router = useRouter ( ) ;
126119 const { today, week, older } = categorizeDialogs ( conversationList ) ;
127120 const [ editingId , setEditingId ] = useState < number | null > ( null ) ;
128121 const [ editingTitle , setEditingTitle ] = useState ( "" ) ;
129122 const inputRef = useRef < HTMLInputElement > ( null ) ;
130123
131- // Add delete dialog status
132- const [ isDeleteDialogOpen , setIsDeleteDialogOpen ] = useState ( false ) ;
133- const [ dialogToDelete , setDialogToDelete ] = useState < number | null > ( null ) ;
134-
135124 const [ animationComplete , setAnimationComplete ] = useState ( false ) ;
136125
137126 useEffect ( ( ) => {
@@ -186,19 +175,22 @@ export function ChatSidebar({
186175
187176 // Handle delete click
188177 const handleDeleteClick = ( dialogId : number ) => {
189- setDialogToDelete ( dialogId ) ;
190- setIsDeleteDialogOpen ( true ) ;
191178 // Close dropdown menus
192179 onDropdownOpenChange ( false , null ) ;
193- } ;
194180
195- // Confirm delete
196- const confirmDelete = ( ) => {
197- if ( dialogToDelete !== null ) {
198- onDelete ( dialogToDelete ) ;
199- setIsDeleteDialogOpen ( false ) ;
200- setDialogToDelete ( null ) ;
201- }
181+ // Show confirmation modal
182+ modal . confirm ( {
183+ title : t ( "chatLeftSidebar.confirmDeletionTitle" ) ,
184+ content : t ( "chatLeftSidebar.confirmDeletionDescription" ) ,
185+ okText : t ( "common.confirm" ) ,
186+ cancelText : t ( "common.cancel" ) ,
187+ okType : "danger" ,
188+ centered : true ,
189+ maskClosable : false ,
190+ onOk : ( ) => {
191+ onDelete ( dialogId ) ;
192+ } ,
193+ } ) ;
202194 } ;
203195
204196 // Render dialog list items
@@ -439,31 +431,6 @@ export function ChatSidebar({
439431 renderCollapsedSidebar ( )
440432 ) }
441433 </ div >
442-
443- { /* Delete confirmation dialog */ }
444- < Dialog open = { isDeleteDialogOpen } onOpenChange = { setIsDeleteDialogOpen } >
445- < DialogContent className = "sm:max-w-[425px]" >
446- < DialogHeader >
447- < DialogTitle >
448- { t ( "chatLeftSidebar.confirmDeletionTitle" ) }
449- </ DialogTitle >
450- < DialogDescription >
451- { t ( "chatLeftSidebar.confirmDeletionDescription" ) }
452- </ DialogDescription >
453- </ DialogHeader >
454- < DialogFooter >
455- < Button
456- variant = "outline"
457- onClick = { ( ) => setIsDeleteDialogOpen ( false ) }
458- >
459- { t ( "chatLeftSidebar.cancel" ) }
460- </ Button >
461- < Button variant = "destructive" onClick = { confirmDelete } >
462- { t ( "chatLeftSidebar.delete" ) }
463- </ Button >
464- </ DialogFooter >
465- </ DialogContent >
466- </ Dialog >
467434 </ >
468435 ) ;
469436}
0 commit comments