hey-pharmacist-ecommerce 1.0.3 → 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/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import React15, { createContext, forwardRef, useContext, useEffect, useState, useCallback } from 'react';
2
3
  import globalAxios3 from 'axios';
3
4
  import { Toaster, toast } from 'sonner';
@@ -1878,6 +1879,7 @@ function mapSessionData(sessionData) {
1878
1879
  }
1879
1880
  function mapProduct(backendProduct) {
1880
1881
  const images = backendProduct.productMedia?.map((media) => media.file) || [];
1882
+ const categoryName = typeof backendProduct.parentCategories?.[0] === "object" ? backendProduct.parentCategories[0]?.name || "" : backendProduct.parentCategories?.[0] || "";
1881
1883
  return {
1882
1884
  id: backendProduct.id || backendProduct._id || "",
1883
1885
  name: backendProduct.name || "",
@@ -1885,7 +1887,7 @@ function mapProduct(backendProduct) {
1885
1887
  price: backendProduct.finalPrice || 0,
1886
1888
  compareAtPrice: backendProduct.isDiscounted ? backendProduct.priceBeforeDiscount : void 0,
1887
1889
  images: images.filter(Boolean),
1888
- category: backendProduct.parentCategories?.[0] || "",
1890
+ category: categoryName,
1889
1891
  inStock: (backendProduct.inventoryCount || 0) > 0,
1890
1892
  stock: backendProduct.inventoryCount,
1891
1893
  sku: backendProduct.sku,