@pradip1995/segment-product-card 0.3.28 → 0.3.30
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 +2 -2
- package/src/product-card-actions.tsx +15 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pradip1995/segment-product-card",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.30",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"react-dom": ">=19"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@pradip1995/segment-login-popup": "^0.1.
|
|
28
|
+
"@pradip1995/segment-login-popup": "^0.1.6",
|
|
29
29
|
"@pradip1995/segment-primitives": "^0.4.11",
|
|
30
30
|
"@pradip1995/segment-tokens": "^0.3.14"
|
|
31
31
|
},
|
|
@@ -10,7 +10,11 @@ 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
|
+
requireLoginForWishlist,
|
|
17
|
+
} from "@pradip1995/segment-login-popup/required"
|
|
14
18
|
import QuickAddPanel from "./quick-add-panel"
|
|
15
19
|
import {
|
|
16
20
|
productCardActionsClass,
|
|
@@ -101,6 +105,7 @@ export default function ProductCardActions({
|
|
|
101
105
|
const handleWishlistToggle = async (event: React.MouseEvent) => {
|
|
102
106
|
stopCardNav(event)
|
|
103
107
|
if (!product.id || wishlistLoading) return
|
|
108
|
+
if (requireLoginForWishlist()) return
|
|
104
109
|
|
|
105
110
|
setWishlistLoading(true)
|
|
106
111
|
try {
|
|
@@ -126,12 +131,19 @@ export default function ProductCardActions({
|
|
|
126
131
|
return
|
|
127
132
|
}
|
|
128
133
|
|
|
129
|
-
if (result.error
|
|
130
|
-
setLoginRequired(true)
|
|
134
|
+
if (isAuthRequiredError(result.error)) {
|
|
135
|
+
promptLoginForWishlist(() => setLoginRequired(true))
|
|
131
136
|
return
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
setError(result.error || "Could not update wishlist")
|
|
140
|
+
} catch (err) {
|
|
141
|
+
const message = err instanceof Error ? err.message : ""
|
|
142
|
+
if (isAuthRequiredError(message) || !message) {
|
|
143
|
+
promptLoginForWishlist(() => setLoginRequired(true))
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
setError(message || "Could not update wishlist")
|
|
135
147
|
} finally {
|
|
136
148
|
setWishlistLoading(false)
|
|
137
149
|
}
|