File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed
odd-platform-ui/src/components/Terms/TermSearch/TermForm Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -80,18 +80,23 @@ const TermsForm: FC<TermsFormDialogProps> = ({ btnCreateEl }) => {
80
80
} ;
81
81
82
82
const onSubmit = ( data : TermFormData ) => {
83
- const duplicateTerm = existingTerms . find (
84
- ( existingTerm : TermDetails ) =>
85
- existingTerm . name === data . name &&
86
- existingTerm . namespace . name === data . namespaceName
87
- ) ;
88
-
89
- if ( duplicateTerm ) {
90
- setError ( 'A term with the same name already exists in this namespace.' ) ;
91
- return ;
83
+ // Check if we're in create mode (no term.id present)
84
+ if ( ! term ?. id ) {
85
+ const duplicateTerm = existingTerms . find (
86
+ ( existingTerm : TermDetails ) =>
87
+ existingTerm . name === data . name &&
88
+ existingTerm . namespace . name === data . namespaceName
89
+ ) ;
90
+
91
+ if ( duplicateTerm ) {
92
+ setError ( 'A term with the same name already exists in this namespace.' ) ;
93
+ return ;
94
+ }
92
95
}
93
96
94
97
const parsedData = { ...data } ;
98
+
99
+ // Determine whether to create or update the term
95
100
( term && term . id
96
101
? dispatch ( updateTerm ( { termId : term . id , termFormData : parsedData } ) )
97
102
: dispatch ( createTerm ( { termFormData : parsedData } ) )
@@ -210,4 +215,4 @@ const TermsForm: FC<TermsFormDialogProps> = ({ btnCreateEl }) => {
210
215
) ;
211
216
} ;
212
217
213
- export default TermsForm ;
218
+ export default TermsForm ;
You can’t perform that action at this time.
0 commit comments