@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.
Files changed (61) hide show
  1. package/dist/cjs/components/credits/context/hooks/useAlpcFetch.js +1 -1
  2. package/dist/cjs/components/credits/context/hooks/useAlpcFetch.js.map +2 -2
  3. package/dist/cjs/components/credits/context/hooks/useCountries.js +1 -1
  4. package/dist/cjs/components/credits/context/hooks/useCountries.js.map +2 -2
  5. package/dist/cjs/components/credits/context/hooks/useShippingCountries.js +1 -1
  6. package/dist/cjs/components/credits/context/hooks/useShippingCountries.js.map +2 -2
  7. package/dist/cjs/components/credits/context/hooks/useSubscribed.js +1 -1
  8. package/dist/cjs/components/credits/context/hooks/useSubscribed.js.map +3 -3
  9. package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js +1 -1
  10. package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +2 -2
  11. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemCoupon.js +1 -1
  12. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemCoupon.js.map +2 -2
  13. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemableList.js +1 -1
  14. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemableList.js.map +2 -2
  15. package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js +1 -1
  16. package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js.map +2 -2
  17. package/dist/cjs/components/memberPopup/panels/EarnCredits/hooks/useActivities.js +1 -1
  18. package/dist/cjs/components/memberPopup/panels/EarnCredits/hooks/useActivities.js.map +2 -2
  19. package/dist/cjs/components/memberPopup/panels/EarnCredits/hooks/useSubscribed.js +1 -1
  20. package/dist/cjs/components/memberPopup/panels/EarnCredits/hooks/useSubscribed.js.map +2 -2
  21. package/dist/cjs/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.js +1 -1
  22. package/dist/cjs/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.js.map +2 -2
  23. package/dist/cjs/components/memberPopup/panels/Referral/hooks/useReferralOverview.js +1 -1
  24. package/dist/cjs/components/memberPopup/panels/Referral/hooks/useReferralOverview.js.map +2 -2
  25. package/dist/esm/components/credits/context/hooks/useAlpcFetch.js +1 -1
  26. package/dist/esm/components/credits/context/hooks/useAlpcFetch.js.map +2 -2
  27. package/dist/esm/components/credits/context/hooks/useCountries.js +1 -1
  28. package/dist/esm/components/credits/context/hooks/useCountries.js.map +2 -2
  29. package/dist/esm/components/credits/context/hooks/useShippingCountries.js +1 -1
  30. package/dist/esm/components/credits/context/hooks/useShippingCountries.js.map +2 -2
  31. package/dist/esm/components/credits/context/hooks/useSubscribed.js +1 -1
  32. package/dist/esm/components/credits/context/hooks/useSubscribed.js.map +3 -3
  33. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js +1 -1
  34. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +2 -2
  35. package/dist/esm/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemCoupon.js +1 -1
  36. package/dist/esm/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemCoupon.js.map +2 -2
  37. package/dist/esm/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemableList.js +1 -1
  38. package/dist/esm/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemableList.js.map +2 -2
  39. package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js +1 -1
  40. package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js.map +2 -2
  41. package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useActivities.js +1 -1
  42. package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useActivities.js.map +2 -2
  43. package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useSubscribed.js +1 -1
  44. package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useSubscribed.js.map +2 -2
  45. package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.js +1 -1
  46. package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.js.map +2 -2
  47. package/dist/esm/components/memberPopup/panels/Referral/hooks/useReferralOverview.js +1 -1
  48. package/dist/esm/components/memberPopup/panels/Referral/hooks/useReferralOverview.js.map +2 -2
  49. package/package.json +1 -1
  50. package/src/components/credits/context/hooks/useAlpcFetch.ts +2 -2
  51. package/src/components/credits/context/hooks/useCountries.ts +1 -0
  52. package/src/components/credits/context/hooks/useShippingCountries.ts +1 -0
  53. package/src/components/credits/context/hooks/useSubscribed.ts +2 -2
  54. package/src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx +1 -0
  55. package/src/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemCoupon.ts +4 -3
  56. package/src/components/memberPopup/panels/ConsumeCredits/hooks/useRedeemableList.ts +4 -3
  57. package/src/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.tsx +1 -0
  58. package/src/components/memberPopup/panels/EarnCredits/hooks/useActivities.ts +4 -3
  59. package/src/components/memberPopup/panels/EarnCredits/hooks/useSubscribed.ts +1 -1
  60. package/src/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.ts +1 -0
  61. package/src/components/memberPopup/panels/Referral/hooks/useReferralOverview.ts +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anker-in/campaign-ui",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "description": "Campaign UI components and utilities for Anker projects",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -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 useCountries({ shopifyStoreDomain }: { shopifyStoreDomain: string }) {
14
14
  setLoading(true)
15
15
  try {
16
16
  const response = await fetch('/api/multipass/account/countries', {
17
+ credentials: 'include',
17
18
  headers: {
18
19
  'current-language': locale,
19
20
  },
@@ -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
- const response = await fetch(getAlpcPath(locale, apiBaseUrl) + url, {
26
- method: 'POST',
27
- headers: { 'Content-Type': 'application/json', 'current-language': locale },
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
- const response = await fetch(getAlpcPath(resolvedLocale, apiBaseUrl) + url, {
20
- method: 'POST',
21
- headers: { 'Content-Type': 'application/json', 'current-language': resolvedLocale },
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
- const response = await fetch(getAlpcPath(locale, apiBaseUrl) + url, {
30
- method: 'POST',
31
- headers: { 'Content-Type': 'application/json', 'current-language': locale },
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,