@anker-in/campaign-ui 0.5.5 → 0.5.6
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/credits/context/hooks/useAlpcFetch.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useAlpcFetch.js.map +2 -2
- package/dist/cjs/components/credits/context/hooks/useCountries.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useCountries.js.map +2 -2
- package/dist/cjs/components/credits/context/hooks/useShippingCountries.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useShippingCountries.js.map +2 -2
- package/dist/cjs/components/credits/context/hooks/useSubscribed.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useSubscribed.js.map +3 -3
- 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/hooks/useRedeemCoupon.js +1 -1
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemCoupon.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemableList.js +1 -1
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemableList.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/hooks/useActivities.js +1 -1
- package/dist/cjs/components/memberPopup/panels/EarnCredits/hooks/useActivities.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/EarnCredits/hooks/useSubscribed.js +1 -1
- package/dist/cjs/components/memberPopup/panels/EarnCredits/hooks/useSubscribed.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.js +1 -1
- package/dist/cjs/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/Referral/hooks/useReferralOverview.js +1 -1
- package/dist/cjs/components/memberPopup/panels/Referral/hooks/useReferralOverview.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useAlpcFetch.js +1 -1
- package/dist/esm/components/credits/context/hooks/useAlpcFetch.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useCountries.js +1 -1
- package/dist/esm/components/credits/context/hooks/useCountries.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useShippingCountries.js +1 -1
- package/dist/esm/components/credits/context/hooks/useShippingCountries.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useSubscribed.js +1 -1
- package/dist/esm/components/credits/context/hooks/useSubscribed.js.map +3 -3
- package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js +1 -1
- package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemCoupon.js +1 -1
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemCoupon.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemableList.js +1 -1
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemableList.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 +2 -2
- package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useActivities.js +1 -1
- package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useActivities.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useSubscribed.js +1 -1
- package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useSubscribed.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.js +1 -1
- package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/Referral/hooks/useReferralOverview.js +1 -1
- package/dist/esm/components/memberPopup/panels/Referral/hooks/useReferralOverview.js.map +2 -2
- package/package.json +1 -1
- package/src/components/credits/context/hooks/useAlpcFetch.ts +2 -2
- package/src/components/credits/context/hooks/useCountries.ts +1 -0
- package/src/components/credits/context/hooks/useShippingCountries.ts +1 -0
- package/src/components/credits/context/hooks/useSubscribed.ts +2 -2
- package/src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx +1 -0
- package/src/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemCoupon.ts +4 -3
- package/src/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemableList.ts +4 -3
- package/src/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.tsx +1 -0
- package/src/components/memberPopup/panels/EarnCredits/hooks/useActivities.ts +4 -3
- package/src/components/memberPopup/panels/EarnCredits/hooks/useSubscribed.ts +1 -1
- package/src/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.ts +1 -0
- package/src/components/memberPopup/panels/Referral/hooks/useReferralOverview.ts +1 -0
package/package.json
CHANGED
|
@@ -59,7 +59,7 @@ const normalizeResponseData = (responseData: any) => {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
const fetcher = (options: FetcherOptions) => {
|
|
62
|
-
return fetch(getAlpcPath(options.locale, options.apiBaseUrl) + options.url, options.fetchOptions).then(async response => {
|
|
62
|
+
return fetch(getAlpcPath(options.locale, options.apiBaseUrl) + options.url, { credentials: 'include', ...options.fetchOptions }).then(async response => {
|
|
63
63
|
if (response.status < 300) {
|
|
64
64
|
const responseData = await response.json()
|
|
65
65
|
return normalizeResponseData(responseData)
|
|
@@ -79,7 +79,7 @@ const fetcher = (options: FetcherOptions) => {
|
|
|
79
79
|
|
|
80
80
|
if (result) {
|
|
81
81
|
// 跨区重新登录后需要替换区域标志,所以不能用最开始请求的那个链接
|
|
82
|
-
return fetch(getAlpcPath(options.locale, options.apiBaseUrl) + options.url, options.fetchOptions).then(async response => {
|
|
82
|
+
return fetch(getAlpcPath(options.locale, options.apiBaseUrl) + options.url, { credentials: 'include', ...options.fetchOptions }).then(async response => {
|
|
83
83
|
if (response.status < 300) {
|
|
84
84
|
const responseData = await response.json()
|
|
85
85
|
return normalizeResponseData(responseData)
|
|
@@ -14,6 +14,7 @@ function useShippingCountries({ shopifyStoreDomain }: { shopifyStoreDomain: stri
|
|
|
14
14
|
setLoading(true)
|
|
15
15
|
try {
|
|
16
16
|
const response = await fetch(`/api/multipass/rainbowbridge/uc/shop/shipping_zones?shop=${shopifyStoreDomain}`, {
|
|
17
|
+
credentials: 'include',
|
|
17
18
|
headers: {
|
|
18
19
|
'current-language': locale,
|
|
19
20
|
},
|
|
@@ -6,13 +6,13 @@ import { useCreditsContext } from '../provider'
|
|
|
6
6
|
import { useHeadlessContext, useSubscriptions } from '@anker-in/lib'
|
|
7
7
|
|
|
8
8
|
export const useSubscribed = () => {
|
|
9
|
-
const { profile } = useCreditsContext()
|
|
9
|
+
const { profile, apiBaseUrl } = useCreditsContext()
|
|
10
10
|
const { brand } = useHeadlessContext()
|
|
11
11
|
|
|
12
12
|
const activitiesOptions = useMemo(() => ({ page: 1, pageSize: 50 }), [])
|
|
13
13
|
|
|
14
14
|
const { activities } = useActivities(activitiesOptions)
|
|
15
|
-
const { data: subscription } = useSubscriptions({ email: profile?.email })
|
|
15
|
+
const { data: subscription } = useSubscriptions({ email: profile?.email, baseUrl: apiBaseUrl })
|
|
16
16
|
const subscriptionData = subscription?.data || subscription
|
|
17
17
|
|
|
18
18
|
const isSubscribed = useMemo(() => {
|
|
@@ -62,6 +62,7 @@ export default function ActivitiesSubscribeModal({ copy, email: initialEmail }:
|
|
|
62
62
|
try {
|
|
63
63
|
const response = await fetch('/api/multipass/rainbowbridge/activities', {
|
|
64
64
|
method: 'POST',
|
|
65
|
+
credentials: 'include',
|
|
65
66
|
headers: {
|
|
66
67
|
'Content-Type': 'application/json',
|
|
67
68
|
'current-language': locale,
|
|
@@ -22,9 +22,10 @@ export function useRedeemCoupon(config: AlpcConfig) {
|
|
|
22
22
|
return useSWRMutation<RedeemCouponResponse, Error, string, RedeemCouponParams>(
|
|
23
23
|
`/v1/credit/redeem/coupon`,
|
|
24
24
|
async (url: string, { arg }) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const response = await fetch(getAlpcPath(locale, apiBaseUrl) + url, {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
credentials: 'include',
|
|
28
|
+
headers: { 'Content-Type': 'application/json', 'current-language': locale },
|
|
28
29
|
body: JSON.stringify({
|
|
29
30
|
brand,
|
|
30
31
|
country: ALPC_COUNTRY_MAP.get(locale) || locale,
|
|
@@ -16,9 +16,10 @@ export function useRedeemableList(config: AlpcConfig) {
|
|
|
16
16
|
const { isMutating: listLoading, trigger } = useSWRMutation(
|
|
17
17
|
`/v1/credit/consume_credit_rules`,
|
|
18
18
|
async (url: string, { arg }: { arg: Record<string, any> }) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const response = await fetch(getAlpcPath(resolvedLocale, apiBaseUrl) + url, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
credentials: 'include',
|
|
22
|
+
headers: { 'Content-Type': 'application/json', 'current-language': resolvedLocale },
|
|
22
23
|
body: JSON.stringify(arg),
|
|
23
24
|
})
|
|
24
25
|
return response.json()
|
|
@@ -52,6 +52,7 @@ export default function SubscribeEmailPanel({ copy, email: initialEmail, onClose
|
|
|
52
52
|
try {
|
|
53
53
|
const response = await fetch('/api/multipass/subscribe/subscribe_emails', {
|
|
54
54
|
method: 'POST',
|
|
55
|
+
credentials: 'include',
|
|
55
56
|
headers: { 'Content-Type': 'application/json', 'current-language': locale },
|
|
56
57
|
body: JSON.stringify({
|
|
57
58
|
email,
|
|
@@ -26,9 +26,10 @@ function useActivities(
|
|
|
26
26
|
const { isMutating: isLoading, trigger } = useSWRMutation(
|
|
27
27
|
`/v1/credit/log`,
|
|
28
28
|
async (url: string, { arg }: { arg: Record<string, any> }) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
const response = await fetch(getAlpcPath(locale, apiBaseUrl) + url, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
credentials: 'include',
|
|
32
|
+
headers: { 'Content-Type': 'application/json', 'current-language': locale },
|
|
32
33
|
body: JSON.stringify(arg),
|
|
33
34
|
})
|
|
34
35
|
return response.json()
|
|
@@ -16,7 +16,7 @@ export function useSubscribed({ userId, brand, email, locale = '', apiBaseUrl }:
|
|
|
16
16
|
{ userId, brand, apiBaseUrl, locale },
|
|
17
17
|
{ page: 1, pageSize: 50 }
|
|
18
18
|
)
|
|
19
|
-
const { data: subscription } = useSubscriptions({ email })
|
|
19
|
+
const { data: subscription } = useSubscriptions({ email, baseUrl: apiBaseUrl })
|
|
20
20
|
const subscriptionData = subscription?.data || subscription
|
|
21
21
|
|
|
22
22
|
return useMemo(() => {
|
|
@@ -24,6 +24,7 @@ export function useUpdateProfile({ locale = '', appName = '' }: UseUpdateProfile
|
|
|
24
24
|
try {
|
|
25
25
|
const response = await fetch('/api/multipass/account/users/update_profile', {
|
|
26
26
|
method: 'PUT',
|
|
27
|
+
credentials: 'include',
|
|
27
28
|
headers: {
|
|
28
29
|
'Content-Type': 'application/json',
|
|
29
30
|
'current-language': locale,
|
|
@@ -22,6 +22,7 @@ export function useReferralOverview(): {
|
|
|
22
22
|
const swrFetcher = async (url: string) => {
|
|
23
23
|
const response = await fetch(url, {
|
|
24
24
|
method: 'GET',
|
|
25
|
+
credentials: 'include',
|
|
25
26
|
headers: {
|
|
26
27
|
'Content-Type': 'application/json',
|
|
27
28
|
'current-language': alpcConfig.locale,
|