Skip to content

Commit 201569f

Browse files
committed
refactor:resolved PR comments
1 parent 32ac87e commit 201569f

File tree

3 files changed

+32
-32
lines changed

3 files changed

+32
-32
lines changed

api/src/services/taxonomy.service.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ const getDescendantsTerm = async ( {authtoken,taxonomyUid, termUid, region, stac
4343
for (const term of terms) {
4444
// Push current term
4545
allTerms.push({
46-
uid: term.uid,
47-
name: term.name,
48-
parent_uid: term.parent_uid,
46+
uid: term?.uid,
47+
name: term?.name,
48+
parent_uid: term?.parent_uid,
4949
});
5050

5151
// Recursively fetch deeper descendants
52-
if (term.children_count > 0) {
52+
if (term?.children_count > 0) {
5353
const nestedTerms = await getDescendantsTerm({
5454
authtoken,
5555
taxonomyUid,
56-
termUid: term.uid,
56+
termUid: term?.uid,
5757
region,
5858
stackId,
5959
});
@@ -65,7 +65,7 @@ const getDescendantsTerm = async ( {authtoken,taxonomyUid, termUid, region, stac
6565
}
6666
return allTerms;
6767
} catch (error) {
68-
console.error("🚀 ~ getDescendantsTerm ~ error:", error);
68+
logger.error("🚀 ~ getDescendantsTerm ~ error:", error);
6969
throw error;
7070

7171
}
@@ -92,25 +92,23 @@ const createTerms = async(
9292
for (const term of termsData || []) {
9393
if (term?.uid) {
9494
allTerms.push({
95-
uid: term.uid,
96-
name: term.name,
97-
parent_uid: term.parent_uid,
95+
uid: term?.uid,
96+
name: term?.name,
97+
parent_uid: term?.parent_uid,
9898
});
9999

100100
if (term?.children_count > 0) {
101101
const nestedTerms = await getDescendantsTerm({
102102
authtoken,
103103
taxonomyUid,
104-
termUid: term.uid,
104+
termUid: term?.uid,
105105
region,
106106
stackId,
107107
});
108108

109109
if (Array.isArray(nestedTerms)) {
110110
allTerms.push(...nestedTerms);
111111
}
112-
113-
console.info("🚀 ~ createTerms ~ nestedTerms:", nestedTerms);
114112
}
115113
}
116114
}
@@ -131,7 +129,7 @@ const createTerms = async(
131129
return allTerms;
132130

133131
} catch (error) {
134-
console.error("🚀 ~ createTaxonomy ~ error:", error);
132+
logger.error("🚀 ~ createTaxonomy ~ error:", error);
135133
throw error;
136134

137135
}
@@ -173,31 +171,33 @@ const createTaxonomy = async ({stackId,region,userId,current_test_stack_id} :
173171
}
174172

175173
const taxonomiesDataObject: Record<string, any> = {};
176-
res?.data?.taxonomies?.forEach(async (taxonomy: any) => {
177-
if (taxonomy?.uid) {
178-
taxonomiesDataObject[taxonomy.uid] = {
179-
uid: taxonomy?.uid,
180-
name: taxonomy?.name,
181-
description: taxonomy?.description,
182-
};
183-
const singleTaxonomy: any= {};
184-
singleTaxonomy['taxonomy']= {
185-
uid: taxonomy?.uid,
186-
name: taxonomy?.name,
187-
description: taxonomy?.description,
174+
if (res?.data?.taxonomies) {
175+
for (const taxonomy of res.data.taxonomies) {
176+
if (taxonomy?.uid) {
177+
taxonomiesDataObject[taxonomy.uid] = {
178+
uid: taxonomy?.uid,
179+
name: taxonomy?.name,
180+
description: taxonomy?.description,
181+
};
182+
const singleTaxonomy: any = {};
183+
singleTaxonomy['taxonomy'] = {
184+
uid: taxonomy?.uid,
185+
name: taxonomy?.name,
186+
description: taxonomy?.description,
187+
};
188+
singleTaxonomy['terms'] = await createTerms({ authtoken, taxonomyUid: taxonomy?.uid, region, stackId });
189+
await fs.promises.writeFile(path.join(taxonomiesPath, `${taxonomy?.uid}.json`), JSON.stringify(singleTaxonomy, null, 2));
188190
}
189-
singleTaxonomy['terms'] = await createTerms({authtoken,taxonomyUid: taxonomy?.uid,region, stackId});
190-
await fs.promises.writeFile(path.join(taxonomiesPath, `${taxonomy?.uid}.json`), JSON.stringify(singleTaxonomy, null, 2));
191191
}
192-
});
192+
}
193193

194194
const filePath = path.join(taxonomiesPath, TAXONOMIES_FILE_NAME);
195195
await fs.promises.writeFile(filePath, JSON.stringify(taxonomiesDataObject, null, 2));
196196

197197

198198

199199
} catch (error) {
200-
console.error("🚀 ~ createTaxonomy ~ error:", error);
200+
logger.error("🚀 ~ createTaxonomy ~ error:", error);
201201
throw error;
202202
}
203203

ui/src/components/ContentMapper/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ const ContentMapper = forwardRef(({ handleStepChange }: contentMapperProps, ref:
522522
value?.data_type !== 'group' &&
523523
value?.label?.includes(item?.display_name)
524524
) {
525-
setIsUpdated(true)
525+
setIsUpdated(true);
526526
updatedRows = updatedRows?.map((row: FieldMapType) => {
527527

528528
if (row?.uid === key && row?.backupFieldType === value?.value?.data_type) {

ui/src/pages/Migration/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const Migration = () => {
127127

128128
useBlockNavigation(isModalOpen);
129129

130-
useEffect(()=>{
130+
useEffect (()=>{
131131
const hasNonEmptyMapping =
132132
newMigrationData?.destination_stack?.localeMapping &&
133133
Object.entries(newMigrationData?.destination_stack?.localeMapping || {})?.every(
@@ -150,7 +150,7 @@ const Migration = () => {
150150
else{
151151
setIsSaved(false);
152152
}
153-
},[isCompleted, newMigrationData])
153+
}, [isCompleted, newMigrationData])
154154

155155
/**
156156
* Function to get exisiting content types list

0 commit comments

Comments
 (0)