From fbcfebbba1c77ff00048b2f6ebb068f03ea692b5 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Thu, 31 Jul 2025 15:14:37 +0800 Subject: [PATCH] memory edit modal --- .../memory/card/edit-modal.tsx | 78 +++++++++++++++++++ .../chat-with-history/memory/card/index.tsx | 72 ++++++++++------- .../memory/card/operation.tsx | 4 +- 3 files changed, 125 insertions(+), 29 deletions(-) create mode 100644 web/app/components/base/chat/chat-with-history/memory/card/edit-modal.tsx diff --git a/web/app/components/base/chat/chat-with-history/memory/card/edit-modal.tsx b/web/app/components/base/chat/chat-with-history/memory/card/edit-modal.tsx new file mode 100644 index 0000000000..44fc14e20b --- /dev/null +++ b/web/app/components/base/chat/chat-with-history/memory/card/edit-modal.tsx @@ -0,0 +1,78 @@ +'use client' +import React from 'react' +import { useTranslation } from 'react-i18next' +import { RiCloseLine } from '@remixicon/react' +import { Memory } from '@/app/components/base/icons/src/vender/line/others' +import Modal from '@/app/components/base/modal' +import ActionButton from '@/app/components/base/action-button' +import Badge from '@/app/components/base/badge' +import Button from '@/app/components/base/button' +import Textarea from '@/app/components/base/textarea' +import Divider from '@/app/components/base/divider' +import Toast from '@/app/components/base/toast' +import type { MemoryItem } from '../type' +import { noop } from 'lodash-es' +import cn from '@/utils/classnames' + +type Props = { + memory: MemoryItem + show: boolean + onConfirm: (info: MemoryItem) => Promise + onHide: () => void +} + +const MemoryEditModal = ({ + memory, + show = false, + onConfirm, + onHide, +}: Props) => { + const { t } = useTranslation() + const [content, setContent] = React.useState(memory.content) + + const submit = () => { + if (!content.trim()) { + Toast.notify({ type: 'error', message: 'content is required' }) + return + } + onConfirm({ ...memory, content }) + onHide() + } + + return ( + +
+ + + +
+
+
{t('share.chat.memory.editTitle')}
+
+ +
{memory.name}
+ +
+
+
+