From 7ce97807277561047038f1ef36f4a606903353b6 Mon Sep 17 00:00:00 2001 From: so95 Date: Sat, 2 Aug 2025 08:11:04 +0700 Subject: [PATCH 1/2] Feat: Support sort category --- .../categorize-form/dynamic-categorize.tsx | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/web/src/pages/agent/form/categorize-form/dynamic-categorize.tsx b/web/src/pages/agent/form/categorize-form/dynamic-categorize.tsx index 0807f7bfa6b..f911a04f9ba 100644 --- a/web/src/pages/agent/form/categorize-form/dynamic-categorize.tsx +++ b/web/src/pages/agent/form/categorize-form/dynamic-categorize.tsx @@ -18,7 +18,7 @@ import { PlusOutlined } from '@ant-design/icons'; import { useUpdateNodeInternals } from '@xyflow/react'; import humanId from 'human-id'; import trim from 'lodash/trim'; -import { ChevronsUpDown, X } from 'lucide-react'; +import { ChevronsUpDown,ChevronDown, ChevronUp, ChevronsUpDown, X } from 'lucide-react'; import { ChangeEventHandler, FocusEventHandler, @@ -181,7 +181,7 @@ const DynamicCategorize = ({ nodeId }: IProps) => { ); const form = useFormContext>(); const { t } = useTranslate('flow'); - const { fields, remove, append } = useFieldArray({ + const { fields, remove, append, move} = useFieldArray({ name: 'items', control: form.control, }); @@ -206,6 +206,14 @@ const DynamicCategorize = ({ nodeId }: IProps) => { }, [deleteCategorizeCaseEdges, fields, nodeId, remove], ); + const handleMove = useCallback( + (from: number, to: number) => () => { + if (to < 0 || to >= fields.length) return; + move(from, to); + if (nodeId) updateNodeInternals(nodeId); + }, + [fields.length, move, nodeId, updateNodeInternals], + ); return (
@@ -217,6 +225,26 @@ const DynamicCategorize = ({ nodeId }: IProps) => {
+ +