UNPKG

@plteam/chat-ui

Version:

CUI Kit is a free and open-source library for creating AI assistant chat interfaces, built with React, Material UI, and TypeScript

33 lines (32 loc) 1.63 kB
import * as React from 'react'; import Dialog from '@mui/material/Dialog'; import DialogContent from '@mui/material/DialogContent'; import DialogTitle from '@mui/material/DialogTitle'; import DialogActions from '@mui/material/DialogActions'; import { useObserverValue } from '../hooks/useObserverValue'; import Typography from '@mui/material/Typography'; import { useHistoryContext } from '../core/history/HistoryContext'; const ThreadDeleteConfirm = () => { const { slots, slotProps, locale, internal, apiRef } = useHistoryContext(); const deleteItem = useObserverValue(internal?.model.deleteItem); const handleClose = () => { if (internal) { internal.model.deleteItem.value = undefined; } }; const handleDelete = () => { if (deleteItem) { internal?.model.delete(deleteItem.id); apiRef.current?.onThreadDeleted?.({ thread: deleteItem }); } handleClose(); }; return (React.createElement(Dialog, { maxWidth: "sm", open: !!deleteItem, onClose: handleClose }, React.createElement(DialogTitle, null, locale.threadDeleteTitle), React.createElement(DialogContent, null, React.createElement(Typography, null, locale.threadDeleteContent)), React.createElement(DialogActions, null, React.createElement(slots.baseButton, { onClick: handleClose, ...slotProps.baseButton }, locale.no), React.createElement(slots.baseButton, { color: "primary", onClick: handleDelete, ...slotProps.baseButton }, locale.yes)))); }; export default ThreadDeleteConfirm;