mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-27 21:58:51 +01:00
* chore: bump vite, vitejs/plugin-react, mark client package as esm, move react-query as a peer dep in data-provider * chore: import changes due to new data-provider export strategy, also fix type imports where applicable * chore: export react-query services as separate to avoid react dependencies in /api/ * chore: suppress sourcemap warnings and polyfill node:path which is used by filenamify TODO: replace filenamify with an alternative and REMOVE polyfill * chore: /api/ changes to support `librechat-data-provider` * refactor: rewrite Dockerfile.multi in light of /api/ changes to support `librechat-data-provider` * chore: remove volume mapping to node_modules directories in default compose file * chore: remove schemas from /api/ as is no longer needed with use of `librechat-data-provider` * fix(ci): jest `librechat-data-provider/react-query` module resolution
58 lines
2 KiB
TypeScript
58 lines
2 KiB
TypeScript
import { useParams } from 'react-router-dom';
|
|
import { useDeleteConversationMutation } from 'librechat-data-provider/react-query';
|
|
import { useLocalize, useConversations, useConversation } from '~/hooks';
|
|
import { Dialog, DialogTrigger, Label } from '~/components/ui';
|
|
import DialogTemplate from '~/components/ui/DialogTemplate';
|
|
import { TrashIcon, CrossIcon } from '~/components/svg';
|
|
|
|
export default function DeleteButton({ conversationId, renaming, retainView, title }) {
|
|
const localize = useLocalize();
|
|
const { newConversation } = useConversation();
|
|
const { refreshConversations } = useConversations();
|
|
const { conversationId: currentConvoId } = useParams();
|
|
const deleteConvoMutation = useDeleteConversationMutation(conversationId);
|
|
|
|
const confirmDelete = () => {
|
|
deleteConvoMutation.mutate(
|
|
{ conversationId, source: 'button' },
|
|
{
|
|
onSuccess: () => {
|
|
if (currentConvoId == conversationId) {
|
|
newConversation();
|
|
}
|
|
|
|
refreshConversations();
|
|
retainView();
|
|
},
|
|
},
|
|
);
|
|
};
|
|
|
|
return (
|
|
<Dialog>
|
|
<DialogTrigger asChild>
|
|
<button className="p-1 hover:text-white">{renaming ? <CrossIcon /> : <TrashIcon />}</button>
|
|
</DialogTrigger>
|
|
<DialogTemplate
|
|
title={localize('com_ui_delete_conversation')}
|
|
className="max-w-[450px]"
|
|
main={
|
|
<>
|
|
<div className="flex w-full flex-col items-center gap-2">
|
|
<div className="grid w-full items-center gap-2">
|
|
<Label htmlFor="chatGptLabel" className="text-left text-sm font-medium">
|
|
{localize('com_ui_delete_conversation_confirm')} <strong>{title}</strong>
|
|
</Label>
|
|
</div>
|
|
</div>
|
|
</>
|
|
}
|
|
selection={{
|
|
selectHandler: confirmDelete,
|
|
selectClasses: 'bg-red-600 hover:bg-red-700 dark:hover:bg-red-800 text-white',
|
|
selectText: localize('com_ui_delete'),
|
|
}}
|
|
/>
|
|
</Dialog>
|
|
);
|
|
}
|