@anker-in/campaign-ui 0.5.0-beta.24 → 0.5.0-beta.26
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/panels/ActivitiesSubscribePanel.js +1 -1
- package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js +1 -1
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js.map +3 -3
- package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivatePanel.js +1 -1
- package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivatePanel.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js +1 -1
- package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js +1 -1
- package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js.map +2 -2
- 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/panels/Referral/index.js +1 -1
- package/dist/cjs/components/memberPopup/panels/Referral/index.js.map +2 -2
- package/dist/cjs/components/memberPopup/type.d.ts +3 -0
- package/dist/cjs/components/memberPopup/type.js +1 -1
- package/dist/cjs/components/memberPopup/type.js.map +1 -1
- package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js +1 -1
- package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +3 -3
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js +1 -1
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js.map +2 -2
- 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/ActivatePanel.js +1 -1
- package/dist/esm/components/memberPopup/panels/EarnCredits/ActivatePanel.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js +1 -1
- package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js +1 -1
- package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js.map +3 -3
- 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/panels/Referral/index.js +1 -1
- package/dist/esm/components/memberPopup/panels/Referral/index.js.map +3 -3
- package/dist/esm/components/memberPopup/type.d.ts +3 -0
- package/dist/esm/components/memberPopup/type.js.map +1 -1
- package/package.json +2 -1
- package/src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx +2 -9
- package/src/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.tsx +3 -20
- package/src/components/memberPopup/panels/ConsumeCredits/index.tsx +34 -16
- package/src/components/memberPopup/panels/EarnCredits/ActivatePanel.tsx +1 -1
- package/src/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.tsx +2 -2
- package/src/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.tsx +16 -15
- package/src/components/memberPopup/panels/EarnCredits/index.tsx +9 -17
- package/src/components/memberPopup/panels/Referral/index.tsx +5 -7
- package/src/components/memberPopup/type.ts +3 -0
- package/src/components/memberPopup/panels/EarnCredits/CompleteProfileModal.tsx +0 -191
|
@@ -165,6 +165,7 @@ export type ConsumeCreditsopy = {
|
|
|
165
165
|
comingSoonLabel?: string
|
|
166
166
|
creditUnit?: string
|
|
167
167
|
off?: string
|
|
168
|
+
giftCard?: string
|
|
168
169
|
imageMapping?: {
|
|
169
170
|
[key in ConsumeCreditsItemType]?: { url: string }
|
|
170
171
|
}
|
|
@@ -198,6 +199,8 @@ export type RedeemCouponModalCopy = {
|
|
|
198
199
|
successDesc: string
|
|
199
200
|
successButton: string
|
|
200
201
|
successButtonUrl?: string
|
|
202
|
+
copyLabel?: string
|
|
203
|
+
copiedLabel?: string
|
|
201
204
|
}
|
|
202
205
|
|
|
203
206
|
// ─── Referral Copy ───────────────────────────────────
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from 'react'
|
|
2
|
-
import { Button, Text } from '@anker-in/headless-ui'
|
|
3
|
-
import { classNames as cn } from '@anker-in/lib'
|
|
4
|
-
import { CreditsModalContainer } from '../../../credits/modal/ModalContainer'
|
|
5
|
-
import type { CompleteProfileCopy } from '../../type'
|
|
6
|
-
import { useUpdateProfile } from './hooks/useUpdateProfile'
|
|
7
|
-
import useCountries from '../../../credits/context/hooks/useCountries'
|
|
8
|
-
import { useMemberPopupContext } from '../../context/provider'
|
|
9
|
-
|
|
10
|
-
type Props = {
|
|
11
|
-
isOpen: boolean
|
|
12
|
-
onClose: () => void
|
|
13
|
-
onSuccess?: () => void
|
|
14
|
-
copy: CompleteProfileCopy
|
|
15
|
-
shopifyStoreDomain?: string
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function CompleteProfileModal({ isOpen, onClose, onSuccess, copy, shopifyStoreDomain = '' }: Props) {
|
|
19
|
-
const { profile, fetchCreditInfo, alpcConfig } = useMemberPopupContext()
|
|
20
|
-
const { locale } = alpcConfig
|
|
21
|
-
|
|
22
|
-
const [firstName, setFirstName] = useState('')
|
|
23
|
-
const [lastName, setLastName] = useState('')
|
|
24
|
-
const [phone, setPhone] = useState('')
|
|
25
|
-
const [birthDay, setBirthDay] = useState('')
|
|
26
|
-
const [country, setCountry] = useState('')
|
|
27
|
-
const [firstNameError, setFirstNameError] = useState('')
|
|
28
|
-
const [lastNameError, setLastNameError] = useState('')
|
|
29
|
-
|
|
30
|
-
const { updateProfile, isLoading } = useUpdateProfile({ locale, appName: alpcConfig.appName })
|
|
31
|
-
const { countries } = useCountries({ shopifyStoreDomain })
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (profile) {
|
|
35
|
-
setFirstName(profile.first_name ?? '')
|
|
36
|
-
setLastName(profile.last_name ?? '')
|
|
37
|
-
setPhone(profile.phone_number ?? '')
|
|
38
|
-
setBirthDay(profile.dob ?? '')
|
|
39
|
-
setCountry(profile.country?.id ?? '')
|
|
40
|
-
}
|
|
41
|
-
}, [profile])
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (countries.length > 0 && !country) {
|
|
45
|
-
setCountry(countries[0].id)
|
|
46
|
-
}
|
|
47
|
-
}, [countries])
|
|
48
|
-
|
|
49
|
-
const validate = useCallback(() => {
|
|
50
|
-
let hasError = false
|
|
51
|
-
if (!firstName.trim()) {
|
|
52
|
-
setFirstNameError(copy.required)
|
|
53
|
-
hasError = true
|
|
54
|
-
} else {
|
|
55
|
-
setFirstNameError('')
|
|
56
|
-
}
|
|
57
|
-
if (!lastName.trim()) {
|
|
58
|
-
setLastNameError(copy.required)
|
|
59
|
-
hasError = true
|
|
60
|
-
} else {
|
|
61
|
-
setLastNameError('')
|
|
62
|
-
}
|
|
63
|
-
return hasError
|
|
64
|
-
}, [firstName, lastName, copy.required])
|
|
65
|
-
|
|
66
|
-
const handleSubmit = useCallback(async () => {
|
|
67
|
-
if (validate()) return
|
|
68
|
-
const success = await updateProfile({
|
|
69
|
-
first_name: firstName.trim(),
|
|
70
|
-
last_name: lastName.trim(),
|
|
71
|
-
phone_number: phone,
|
|
72
|
-
country,
|
|
73
|
-
dob: birthDay,
|
|
74
|
-
})
|
|
75
|
-
if (success) {
|
|
76
|
-
fetchCreditInfo(profile?.user_id)
|
|
77
|
-
onSuccess?.()
|
|
78
|
-
onClose()
|
|
79
|
-
}
|
|
80
|
-
}, [validate, updateProfile, firstName, lastName, phone, country, birthDay, fetchCreditInfo, profile, onSuccess, onClose])
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<CreditsModalContainer
|
|
84
|
-
isOpen={isOpen}
|
|
85
|
-
onClose={onClose}
|
|
86
|
-
title={copy.title}
|
|
87
|
-
titleClassName="!h-auto !border-b-0 !pb-0"
|
|
88
|
-
className="w-[540px] md:h-auto"
|
|
89
|
-
useAnimation
|
|
90
|
-
animationClassName="md:translate-y-[100vh]"
|
|
91
|
-
>
|
|
92
|
-
<div className="flex flex-col gap-[20px]">
|
|
93
|
-
{copy.subtitle && (
|
|
94
|
-
<Text className="text-[14px] text-[#1d1d1f]" html={copy.subtitle} />
|
|
95
|
-
)}
|
|
96
|
-
|
|
97
|
-
<div>
|
|
98
|
-
<label className="block text-[14px] font-semibold text-[#1d1d1f]">{copy.email}</label>
|
|
99
|
-
<input
|
|
100
|
-
className="mt-[8px] h-[46px] w-full rounded-[4px] border border-[#d8d8d8] bg-[#f5f5f5] px-[12px] text-[14px] text-[#999]"
|
|
101
|
-
value={profile?.email ?? ''}
|
|
102
|
-
disabled
|
|
103
|
-
/>
|
|
104
|
-
</div>
|
|
105
|
-
|
|
106
|
-
<div>
|
|
107
|
-
<label className="block text-[14px] font-semibold text-[#1d1d1f]">
|
|
108
|
-
{copy.firstName} <span className="text-[#f84d4f]">*</span>
|
|
109
|
-
</label>
|
|
110
|
-
<input
|
|
111
|
-
className={cn(
|
|
112
|
-
'mt-[8px] h-[46px] w-full rounded-[4px] border px-[12px] text-[14px] outline-none',
|
|
113
|
-
firstNameError ? 'border-[#f84d4f]' : 'border-[#d8d8d8]'
|
|
114
|
-
)}
|
|
115
|
-
value={firstName}
|
|
116
|
-
onChange={e => { setFirstName(e.target.value); setFirstNameError('') }}
|
|
117
|
-
/>
|
|
118
|
-
{firstNameError && <Text className="mt-[4px] text-[12px] text-[#f84d4f]" html={firstNameError} />}
|
|
119
|
-
</div>
|
|
120
|
-
|
|
121
|
-
<div>
|
|
122
|
-
<label className="block text-[14px] font-semibold text-[#1d1d1f]">
|
|
123
|
-
{copy.lastName} <span className="text-[#f84d4f]">*</span>
|
|
124
|
-
</label>
|
|
125
|
-
<input
|
|
126
|
-
className={cn(
|
|
127
|
-
'mt-[8px] h-[46px] w-full rounded-[4px] border px-[12px] text-[14px] outline-none',
|
|
128
|
-
lastNameError ? 'border-[#f84d4f]' : 'border-[#d8d8d8]'
|
|
129
|
-
)}
|
|
130
|
-
value={lastName}
|
|
131
|
-
onChange={e => { setLastName(e.target.value); setLastNameError('') }}
|
|
132
|
-
/>
|
|
133
|
-
{lastNameError && <Text className="mt-[4px] text-[12px] text-[#f84d4f]" html={lastNameError} />}
|
|
134
|
-
</div>
|
|
135
|
-
|
|
136
|
-
<div>
|
|
137
|
-
<label className="block text-[14px] font-semibold text-[#1d1d1f]">{copy.birthday}</label>
|
|
138
|
-
<input
|
|
139
|
-
className="mt-[8px] h-[46px] w-full rounded-[4px] border border-[#d8d8d8] px-[12px] text-[14px] outline-none"
|
|
140
|
-
type="date"
|
|
141
|
-
value={birthDay}
|
|
142
|
-
onChange={e => setBirthDay(e.target.value)}
|
|
143
|
-
/>
|
|
144
|
-
</div>
|
|
145
|
-
|
|
146
|
-
<div>
|
|
147
|
-
<label className="block text-[14px] font-semibold text-[#1d1d1f]">{copy.phone}</label>
|
|
148
|
-
<input
|
|
149
|
-
className="mt-[8px] h-[46px] w-full rounded-[4px] border border-[#d8d8d8] px-[12px] text-[14px] outline-none"
|
|
150
|
-
value={phone}
|
|
151
|
-
onChange={e => setPhone(e.target.value)}
|
|
152
|
-
/>
|
|
153
|
-
</div>
|
|
154
|
-
|
|
155
|
-
<div>
|
|
156
|
-
<label className="block text-[14px] font-semibold text-[#1d1d1f]">{copy.country}</label>
|
|
157
|
-
<select
|
|
158
|
-
className="mt-[8px] h-[46px] w-full rounded-[4px] border border-[#d8d8d8] px-[12px] text-[14px] outline-none"
|
|
159
|
-
value={country}
|
|
160
|
-
onChange={e => setCountry(e.target.value)}
|
|
161
|
-
>
|
|
162
|
-
{countries.map((c: { id: string; name: string }) => (
|
|
163
|
-
<option key={c.id} value={c.id}>{c.name}</option>
|
|
164
|
-
))}
|
|
165
|
-
</select>
|
|
166
|
-
</div>
|
|
167
|
-
|
|
168
|
-
<div className="flex gap-[12px]">
|
|
169
|
-
<Button
|
|
170
|
-
variant="secondary"
|
|
171
|
-
size="lg"
|
|
172
|
-
className="flex-1"
|
|
173
|
-
onClick={onClose}
|
|
174
|
-
disabled={isLoading}
|
|
175
|
-
>
|
|
176
|
-
{copy.cancel}
|
|
177
|
-
</Button>
|
|
178
|
-
<Button
|
|
179
|
-
variant="primary"
|
|
180
|
-
size="lg"
|
|
181
|
-
className="flex-1"
|
|
182
|
-
loading={isLoading}
|
|
183
|
-
onClick={handleSubmit}
|
|
184
|
-
>
|
|
185
|
-
{copy.save}
|
|
186
|
-
</Button>
|
|
187
|
-
</div>
|
|
188
|
-
</div>
|
|
189
|
-
</CreditsModalContainer>
|
|
190
|
-
)
|
|
191
|
-
}
|