@@ -3,7 +3,7 @@ import { showFlag } from '@forge/bridge';
3
3
import { useAppContext } from './useAppContext' ;
4
4
import { createMRWithCompassYML , createSingleComponent , getGroupProjects } from '../services/invokes' ;
5
5
import { getComponentTypeOptionForBuiltInType , sleep } from '../components/utils' ;
6
- import { ImportableProject } from '../types' ;
6
+ import { ImportableProject , ProjectReadyForImport } from '../types' ;
7
7
import { DEFAULT_COMPONENT_TYPE_ID } from '../constants' ;
8
8
import { useComponentTypes } from './useComponentTypes' ;
9
9
import { useImportAllCaCContext } from './useImportAllCaCContext' ;
@@ -121,7 +121,18 @@ export const useImportAll = (): {
121
121
const { data, errors } = await getGroupProjects ( groupId , page , locationGroupId , undefined , MAX_PER_PAGE ) ;
122
122
123
123
if ( data && data . projects . length ) {
124
- const projectsToImport = data . projects . map ( ( project ) => {
124
+ const uniqueProjectsForImport = data . projects . reduce < ProjectReadyForImport [ ] > (
125
+ ( uniqueProjects , currentProject ) => {
126
+ const isUniqueProject = ! uniqueProjects . some ( ( uniqueProject ) => uniqueProject . id === currentProject . id ) ;
127
+ if ( isUniqueProject ) {
128
+ uniqueProjects . push ( currentProject ) ;
129
+ }
130
+ return uniqueProjects ;
131
+ } ,
132
+ [ ] ,
133
+ ) ;
134
+
135
+ const projectsToImport = uniqueProjectsForImport . map ( ( project ) => {
125
136
const componentType = componentTypes . find ( ( t ) => t . id === project . typeId ) ;
126
137
const typeOption = componentType
127
138
? { label : componentType . name , value : componentType . id }
0 commit comments