@pradip1995/segment-product-card 0.3.27 → 0.3.29
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 +1 -1
- package/src/product-card-actions.tsx +13 -3
- package/src/segment.tsx +14 -2
package/package.json
CHANGED
|
@@ -10,7 +10,10 @@ import {
|
|
|
10
10
|
} from "@pradip1995/commerce-core/client/actions/wishlist"
|
|
11
11
|
import type { HttpTypes } from "@medusajs/types"
|
|
12
12
|
import { isNextRedirect } from "@pradip1995/segment-primitives/is-next-redirect"
|
|
13
|
-
import LoginRequiredModal
|
|
13
|
+
import LoginRequiredModal, {
|
|
14
|
+
isAuthRequiredError,
|
|
15
|
+
promptLoginForWishlist,
|
|
16
|
+
} from "@pradip1995/segment-login-popup/required"
|
|
14
17
|
import QuickAddPanel from "./quick-add-panel"
|
|
15
18
|
import {
|
|
16
19
|
productCardActionsClass,
|
|
@@ -126,12 +129,19 @@ export default function ProductCardActions({
|
|
|
126
129
|
return
|
|
127
130
|
}
|
|
128
131
|
|
|
129
|
-
if (result.error
|
|
130
|
-
setLoginRequired(true)
|
|
132
|
+
if (isAuthRequiredError(result.error)) {
|
|
133
|
+
promptLoginForWishlist(() => setLoginRequired(true))
|
|
131
134
|
return
|
|
132
135
|
}
|
|
133
136
|
|
|
134
137
|
setError(result.error || "Could not update wishlist")
|
|
138
|
+
} catch (err) {
|
|
139
|
+
const message = err instanceof Error ? err.message : ""
|
|
140
|
+
if (isAuthRequiredError(message) || !message) {
|
|
141
|
+
promptLoginForWishlist(() => setLoginRequired(true))
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
setError(message || "Could not update wishlist")
|
|
135
145
|
} finally {
|
|
136
146
|
setWishlistLoading(false)
|
|
137
147
|
}
|
package/src/segment.tsx
CHANGED
|
@@ -5,8 +5,10 @@ import type { HttpTypes } from "@medusajs/types"
|
|
|
5
5
|
import BeautyProductCard from "./beauty-product-card"
|
|
6
6
|
import DefaultProductCard from "./default-product-card"
|
|
7
7
|
import JewelryProductCard from "./jewelry-product-card"
|
|
8
|
+
import MotionProductCard from "./motion-product-card"
|
|
9
|
+
import ShopProductCard from "./shop-product-card"
|
|
8
10
|
|
|
9
|
-
export type ProductCardVariant = "default" | "beauty" | "jewelry"
|
|
11
|
+
export type ProductCardVariant = "default" | "beauty" | "jewelry" | "motion" | "shop"
|
|
10
12
|
|
|
11
13
|
type Props = {
|
|
12
14
|
product: HttpTypes.StoreProduct
|
|
@@ -19,7 +21,15 @@ type Props = {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
function resolveProductCardVariant(variant?: ProductCardVariant): ProductCardVariant {
|
|
22
|
-
if (
|
|
24
|
+
if (
|
|
25
|
+
variant === "beauty" ||
|
|
26
|
+
variant === "default" ||
|
|
27
|
+
variant === "jewelry" ||
|
|
28
|
+
variant === "motion" ||
|
|
29
|
+
variant === "shop"
|
|
30
|
+
) {
|
|
31
|
+
return variant
|
|
32
|
+
}
|
|
23
33
|
return "default"
|
|
24
34
|
}
|
|
25
35
|
|
|
@@ -27,5 +37,7 @@ export default function ProductCard({ variant, ...props }: Props) {
|
|
|
27
37
|
const layout = resolveProductCardVariant(variant)
|
|
28
38
|
if (layout === "beauty") return <BeautyProductCard {...props} />
|
|
29
39
|
if (layout === "jewelry") return <JewelryProductCard {...props} />
|
|
40
|
+
if (layout === "motion") return <MotionProductCard {...props} />
|
|
41
|
+
if (layout === "shop") return <ShopProductCard {...props} />
|
|
30
42
|
return <DefaultProductCard {...props} />
|
|
31
43
|
}
|