diff --git a/src/components/InfoModal.tsx b/src/components/InfoModal.tsx
index cd63487..b1604ab 100644
--- a/src/components/InfoModal.tsx
+++ b/src/components/InfoModal.tsx
@@ -50,7 +50,7 @@ export default function ModalInfo({barcode}: ModalInfoProps) {
selectedImages: [],
brands: res.data.product.brands || null,
editors_tags: res.data.product.editors_tags || null,
- categories: res.data.product.categories || null,
+ categories: [],
ingrediants: [],
}
// loop through the images and build the url
@@ -81,6 +81,15 @@ export default function ModalInfo({barcode}: ModalInfoProps) {
}
}
}
+ // loop through the categories and keep only the text
+ const categories = res.data.product.categories_hierarchy
+ if (categories) {
+ for (const key in categories) {
+ if (categories[key]) {
+ usedData.categories.push(categories[key]);
+ }
+ }
+ }
setTicketInfo(usedData);
setIsLoaded(true);
}).catch((err) => {
@@ -125,9 +134,28 @@ export default function ModalInfo({barcode}: ModalInfoProps) {
Brands : {ticketInfo?.brands}
-
- Categories : {ticketInfo?.categories}
-
+
+
+ Categories :
+
+ {ticketInfo?.categories ? (
+
+
+ {ticketInfo.categories.map((category: string, index: number) => (
+
+
+ {category}
+
+
+ ))}
+
+
+ ) : (
+
+ No categories found
+
+ )}
+
Selected Images :
@@ -154,26 +182,28 @@ export default function ModalInfo({barcode}: ModalInfoProps) {
No selected images found
)}
-
- Ingrediants :
-
- {ticketInfo?.ingrediants ? (
-
-
- {ticketInfo.ingrediants.map((ingrediant: string, index: number) => (
-
-
- {ingrediant}
-
-
- ))}
-
-
- ) : (
+
- No ingrediants found
+ Ingrediants :
- )}
+ {ticketInfo?.ingrediants ? (
+
+
+ {ticketInfo.ingrediants.map((ingrediant: string, index: number) => (
+
+
+ {ingrediant}
+
+
+ ))}
+
+
+ ) : (
+
+ No ingrediants found
+
+ )}
+
Images :