hey-pharmacist-ecommerce 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hey-pharmacist-ecommerce",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Multi-tenant e-commerce package for Next.js",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -39,7 +39,12 @@ export function mapSessionData(sessionData: TUserSessionData): { user: User; tok
39
39
  */
40
40
  export function mapProduct(backendProduct: ExtendedProductDTO): Product {
41
41
  const images = backendProduct.productMedia?.map((media) => media.file) || [];
42
-
42
+
43
+ // Extract category name from the parentCategories object
44
+ const categoryName = typeof backendProduct.parentCategories?.[0] === 'object'
45
+ ? (backendProduct.parentCategories[0] as any)?.name || ''
46
+ : backendProduct.parentCategories?.[0] || '';
47
+
43
48
  return {
44
49
  id: backendProduct.id || backendProduct._id || '',
45
50
  name: backendProduct.name || '',
@@ -47,7 +52,7 @@ export function mapProduct(backendProduct: ExtendedProductDTO): Product {
47
52
  price: backendProduct.finalPrice || 0,
48
53
  compareAtPrice: backendProduct.isDiscounted ? backendProduct.priceBeforeDiscount : undefined,
49
54
  images: images.filter(Boolean),
50
- category: backendProduct.parentCategories?.[0] || '',
55
+ category: categoryName,
51
56
  inStock: (backendProduct.inventoryCount || 0) > 0,
52
57
  stock: backendProduct.inventoryCount,
53
58
  sku: backendProduct.sku,