@anker-in/campaign-ui 0.5.0-beta.11 → 0.5.0-beta.13
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/cjs/components/memberPopup/MemberPopup.d.ts +1 -1
- package/dist/cjs/components/memberPopup/MemberPopup.js +1 -1
- package/dist/cjs/components/memberPopup/MemberPopup.js.map +3 -3
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/EarnCredits/index.d.ts +1 -4
- package/dist/cjs/components/memberPopup/panels/EarnCredits/index.js +1 -1
- package/dist/cjs/components/memberPopup/panels/EarnCredits/index.js.map +3 -3
- package/dist/cjs/components/memberPopup/type.d.ts +0 -1
- package/dist/cjs/components/memberPopup/type.js.map +1 -1
- package/dist/esm/components/memberPopup/MemberPopup.d.ts +1 -1
- package/dist/esm/components/memberPopup/MemberPopup.js +1 -1
- package/dist/esm/components/memberPopup/MemberPopup.js.map +3 -3
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js.map +3 -3
- package/dist/esm/components/memberPopup/panels/EarnCredits/index.d.ts +1 -4
- package/dist/esm/components/memberPopup/panels/EarnCredits/index.js +1 -1
- package/dist/esm/components/memberPopup/panels/EarnCredits/index.js.map +3 -3
- package/dist/esm/components/memberPopup/type.d.ts +0 -1
- package/dist/esm/components/memberPopup/type.js.map +1 -1
- package/package.json +1 -1
- package/src/components/memberPopup/MemberPopup.tsx +28 -30
- package/src/components/memberPopup/panels/ConsumeCredits/index.tsx +4 -4
- package/src/components/memberPopup/panels/EarnCredits/index.tsx +0 -9
- package/src/components/memberPopup/type.ts +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { lazy, Suspense, useState, useCallback, useMemo } from 'react'
|
|
3
|
+
import { lazy, Suspense, useState, useCallback, useMemo, useEffect } from 'react'
|
|
4
4
|
import { Picture } from '@anker-in/headless-ui'
|
|
5
5
|
import { type HeadlessConfig, useHeadlessContext, classNames as cn } from '@anker-in/lib'
|
|
6
6
|
import {
|
|
@@ -33,11 +33,28 @@ type MemberPopupProps = MemberPopupContextValue & {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export function MemberPopup({ copy, bottomOffset = '24px', ...providerProps }: MemberPopupProps) {
|
|
36
|
-
|
|
36
|
+
const isVisible = useMemo(() => {
|
|
37
|
+
const config = copy.pageConfig
|
|
38
|
+
if (!config) return true
|
|
39
|
+
const pathname = typeof window !== 'undefined' ? window.location.pathname : ''
|
|
40
|
+
const matches = config.pages.some(page => pathname === page || pathname.startsWith(page + '/'))
|
|
41
|
+
switch (config.scope) {
|
|
42
|
+
case MemberPopupPageScope.Include:
|
|
43
|
+
return matches
|
|
44
|
+
case MemberPopupPageScope.Exclude:
|
|
45
|
+
return !matches
|
|
46
|
+
default:
|
|
47
|
+
return true
|
|
48
|
+
}
|
|
49
|
+
}, [copy.pageConfig])
|
|
50
|
+
|
|
51
|
+
console.log('isVisible', isVisible)
|
|
52
|
+
|
|
53
|
+
return isVisible ? (
|
|
37
54
|
<MemberPopupProvider {...providerProps} earnCreditsCopy={copy.earnCredits}>
|
|
38
55
|
<MemberPopupContent copy={copy} bottomOffset={bottomOffset} />
|
|
39
56
|
</MemberPopupProvider>
|
|
40
|
-
)
|
|
57
|
+
) : null
|
|
41
58
|
}
|
|
42
59
|
|
|
43
60
|
type MemberPopupContentProps = {
|
|
@@ -59,21 +76,6 @@ function MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {
|
|
|
59
76
|
|
|
60
77
|
const currentView = viewStack[viewStack.length - 1] ?? null
|
|
61
78
|
|
|
62
|
-
const isVisible = useMemo(() => {
|
|
63
|
-
const config = copy.pageConfig
|
|
64
|
-
if (!config) return true
|
|
65
|
-
const pathname = typeof window !== 'undefined' ? window.location.pathname : ''
|
|
66
|
-
const matches = config.pages.some(page => pathname === page || pathname.startsWith(page + '/'))
|
|
67
|
-
switch (config.scope) {
|
|
68
|
-
case MemberPopupPageScope.Include:
|
|
69
|
-
return matches
|
|
70
|
-
case MemberPopupPageScope.Exclude:
|
|
71
|
-
return !matches
|
|
72
|
-
default:
|
|
73
|
-
return true
|
|
74
|
-
}
|
|
75
|
-
}, [copy.pageConfig])
|
|
76
|
-
|
|
77
79
|
const pushView = useCallback((view: ViewPayload) => {
|
|
78
80
|
setViewStack(prev => [...prev, view])
|
|
79
81
|
}, [])
|
|
@@ -82,9 +84,6 @@ function MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {
|
|
|
82
84
|
setViewStack(prev => prev.slice(0, -1))
|
|
83
85
|
}, [])
|
|
84
86
|
|
|
85
|
-
console.log('isVisible', isVisible)
|
|
86
|
-
if (!isVisible) return null
|
|
87
|
-
|
|
88
87
|
function handleAction(type: MemberPopupActionType, url?: string) {
|
|
89
88
|
switch (type) {
|
|
90
89
|
case MemberPopupActionType.ExternalLink:
|
|
@@ -178,12 +177,9 @@ function MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {
|
|
|
178
177
|
<EarnCredits
|
|
179
178
|
copy={copy.earnCredits}
|
|
180
179
|
onClose={popView}
|
|
180
|
+
isProfileCompleteSuccess={isProfileCompleteSuccess}
|
|
181
181
|
isSubscribeSuccess={isSubscribeSuccess}
|
|
182
182
|
isActivateSuccess={isActivateSuccess}
|
|
183
|
-
isProfileCompleteSuccess={isProfileCompleteSuccess}
|
|
184
|
-
onSubscribeSuccess={() => setIsSubscribeSuccess(true)}
|
|
185
|
-
onActivateSuccess={() => setIsActivateSuccess(true)}
|
|
186
|
-
onProfileCompleteSuccess={() => setIsProfileCompleteSuccess(true)}
|
|
187
183
|
/>
|
|
188
184
|
)}
|
|
189
185
|
{currentView.type === MemberPopupPanelType.ConsumeCredits && copy.consumeCredits && (
|
|
@@ -201,14 +197,14 @@ function MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {
|
|
|
201
197
|
copy={copy.earnCredits.completeProfile}
|
|
202
198
|
shopifyStoreDomain={storeDomain}
|
|
203
199
|
onClose={popView}
|
|
204
|
-
onSuccess={
|
|
200
|
+
onSuccess={() => setIsProfileCompleteSuccess(true)}
|
|
205
201
|
/>
|
|
206
202
|
)}
|
|
207
203
|
{currentView.type === MemberPopupPanelType.Subscribe && copy.activitiesSubscribe && (
|
|
208
204
|
<ActivitiesSubscribe
|
|
209
205
|
copy={copy.activitiesSubscribe}
|
|
210
206
|
email={profile?.email}
|
|
211
|
-
onSuccess={
|
|
207
|
+
onSuccess={() => setIsSubscribeSuccess(true)}
|
|
212
208
|
hideForm={isSubscribeFormHidden}
|
|
213
209
|
onHideForm={() => setIsSubscribeFormHidden(true)}
|
|
214
210
|
/>
|
|
@@ -218,14 +214,16 @@ function MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {
|
|
|
218
214
|
copy={copy.earnCredits.subscribe}
|
|
219
215
|
email={profile?.email}
|
|
220
216
|
onClose={popView}
|
|
221
|
-
onSuccess={
|
|
217
|
+
onSuccess={() => setIsSubscribeSuccess(true)}
|
|
222
218
|
/>
|
|
223
219
|
)}
|
|
224
220
|
{currentView.type === MemberPopupPanelType.Activate && copy.earnCredits && (
|
|
225
221
|
<Activate
|
|
226
222
|
copy={copy.earnCredits.authCodeActivate}
|
|
227
223
|
onClose={popView}
|
|
228
|
-
onSuccess={
|
|
224
|
+
onSuccess={() => {
|
|
225
|
+
setIsActivateSuccess(true)
|
|
226
|
+
}}
|
|
229
227
|
/>
|
|
230
228
|
)}
|
|
231
229
|
{currentView.type === MemberPopupPanelType.RedeemCoupon &&
|
|
@@ -242,7 +240,7 @@ function MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {
|
|
|
242
240
|
userId={currentView.props.userId}
|
|
243
241
|
alpcConfig={currentView.props.alpcConfig}
|
|
244
242
|
copy={copy.consumeCredits.redeemModal}
|
|
245
|
-
pointUnit={copy.consumeCredits.
|
|
243
|
+
pointUnit={copy.consumeCredits.creditUnit}
|
|
246
244
|
onClose={popView}
|
|
247
245
|
/>
|
|
248
246
|
)}
|
|
@@ -158,7 +158,7 @@ function ConsumeCredits({ copy, isActivateSuccess, onClose }: Props) {
|
|
|
158
158
|
{numberFormat(creditInfo?.available_credit || 0)}
|
|
159
159
|
</span>
|
|
160
160
|
<span className="text-[14px] font-[700] leading-[1.4] text-[#1e2024]">
|
|
161
|
-
{copy.creditUnit ?? copy.
|
|
161
|
+
{copy.creditUnit ?? copy.creditUnit ?? 'ankercredits'}
|
|
162
162
|
</span>
|
|
163
163
|
</div>
|
|
164
164
|
</div>
|
|
@@ -170,7 +170,7 @@ function ConsumeCredits({ copy, isActivateSuccess, onClose }: Props) {
|
|
|
170
170
|
{numberFormat(creditInfo?.pending_credit || 0)}
|
|
171
171
|
</span>
|
|
172
172
|
<span className="text-[14px] font-[700] leading-[1.4] text-[#1e2024]">
|
|
173
|
-
{copy.creditUnit ??
|
|
173
|
+
{copy.creditUnit ?? 'ankercredits'}
|
|
174
174
|
</span>
|
|
175
175
|
<span className="text-[14px] font-[700] leading-[1.4] text-[#1e2024]">
|
|
176
176
|
{copy.creditUnit ?? 'ankercredits'}
|
|
@@ -229,8 +229,8 @@ function ConsumeCredits({ copy, isActivateSuccess, onClose }: Props) {
|
|
|
229
229
|
</div>
|
|
230
230
|
<div className="mt-[4px] text-[14px] text-[#666]">
|
|
231
231
|
{hasProduct && item.price != null
|
|
232
|
-
? `${numberFormat(item.alpcData.consume_credits)} ${copy.
|
|
233
|
-
: `${numberFormat(item.alpcData.consume_credits)} ${copy.
|
|
232
|
+
? `${numberFormat(item.alpcData.consume_credits)} ${copy.creditUnit ?? ''} + $${Number(item.price).toFixed(2)}`
|
|
233
|
+
: `${numberFormat(item.alpcData.consume_credits)} ${copy.creditUnit ?? ''}`}
|
|
234
234
|
</div>
|
|
235
235
|
</div>
|
|
236
236
|
<div className="relative group">
|
|
@@ -27,9 +27,6 @@ type Props = {
|
|
|
27
27
|
isSubscribeSuccess?: boolean
|
|
28
28
|
isActivateSuccess?: boolean
|
|
29
29
|
isProfileCompleteSuccess?: boolean
|
|
30
|
-
onSubscribeSuccess?: () => void
|
|
31
|
-
onActivateSuccess?: () => void
|
|
32
|
-
onProfileCompleteSuccess?: () => void
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
function EarnCredits({
|
|
@@ -38,9 +35,6 @@ function EarnCredits({
|
|
|
38
35
|
isSubscribeSuccess = false,
|
|
39
36
|
isActivateSuccess = false,
|
|
40
37
|
isProfileCompleteSuccess = false,
|
|
41
|
-
onSubscribeSuccess,
|
|
42
|
-
onActivateSuccess,
|
|
43
|
-
onProfileCompleteSuccess,
|
|
44
38
|
}: Props) {
|
|
45
39
|
const { profile, openSignUpPopup, alpcConfig, creditInfo } = useMemberPopupContext()
|
|
46
40
|
const { pushView } = useViewStack()
|
|
@@ -75,7 +69,6 @@ function EarnCredits({
|
|
|
75
69
|
? () =>
|
|
76
70
|
pushView({
|
|
77
71
|
type: MemberPopupPanelType.Activate,
|
|
78
|
-
props: { onSuccess: onActivateSuccess },
|
|
79
72
|
})
|
|
80
73
|
: openSignUpPopup,
|
|
81
74
|
},
|
|
@@ -85,7 +78,6 @@ function EarnCredits({
|
|
|
85
78
|
? () =>
|
|
86
79
|
pushView({
|
|
87
80
|
type: MemberPopupPanelType.CompleteProfile,
|
|
88
|
-
props: { onSuccess: onProfileCompleteSuccess },
|
|
89
81
|
})
|
|
90
82
|
: openSignUpPopup,
|
|
91
83
|
},
|
|
@@ -95,7 +87,6 @@ function EarnCredits({
|
|
|
95
87
|
? () =>
|
|
96
88
|
pushView({
|
|
97
89
|
type: MemberPopupPanelType.SubscribeEmail,
|
|
98
|
-
props: { onSuccess: onSubscribeSuccess },
|
|
99
90
|
})
|
|
100
91
|
: openSignUpPopup,
|
|
101
92
|
},
|