@pradip1995/segment-product-card 0.3.0 → 0.3.1

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": "@pradip1995/segment-product-card",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,8 +23,8 @@
23
23
  "next": ">=15"
24
24
  },
25
25
  "dependencies": {
26
- "@pradip1995/segment-primitives": "0.3.0",
27
- "@pradip1995/segment-tokens": "0.3.0"
26
+ "@pradip1995/segment-tokens": "0.3.1",
27
+ "@pradip1995/segment-primitives": "0.3.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@pradip1995/plugin-sdk": "^0.2.0",
@@ -109,12 +109,20 @@ export default function ProductCardActions({ product, countryCode }: Props) {
109
109
  setIsAdding(true)
110
110
  setError(null)
111
111
  try {
112
- await addToCart({ variantId, quantity: qty, countryCode })
112
+ await addToCart({
113
+ variantId,
114
+ quantity: qty,
115
+ countryCode: countryCode.toLowerCase(),
116
+ })
113
117
  window.dispatchEvent(new CustomEvent("cart:item-added", { detail: { message: "Added to cart" } }))
114
118
  setShowQuickAdd(false)
115
119
  router.refresh()
116
120
  } catch (err) {
117
- setError(err instanceof Error ? err.message : "Could not add to cart")
121
+ const message = err instanceof Error ? err.message : "Could not add to cart"
122
+ setError(message)
123
+ window.dispatchEvent(
124
+ new CustomEvent("cart:item-added", { detail: { message, variant: "error" } })
125
+ )
118
126
  } finally {
119
127
  setIsAdding(false)
120
128
  }
@@ -1,3 +1,5 @@
1
+ "use client"
2
+
1
3
  import ProductCard from "./segment"
2
4
  import ProductScroll from "./product-scroll"
3
5
  import LocalizedLink from "@pradip1995/segment-primitives/localized-link"
package/src/segment.tsx CHANGED
@@ -42,9 +42,9 @@ export default function ProductCard({
42
42
  >
43
43
  <LocalizedLink href={`/products/${product.handle}`} className="product-card__link flex flex-col h-full">
44
44
  <div className="product-card__media relative aspect-[3/4] bg-surface-muted overflow-hidden rounded-lg">
45
- {product.thumbnail ? (
45
+ {product.thumbnail?.trim() ? (
46
46
  <img
47
- src={product.thumbnail}
47
+ src={product.thumbnail.trim()}
48
48
  alt={product.title || ""}
49
49
  className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"
50
50
  />