@anker-in/campaign-ui 0.5.21 → 0.5.22

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 (95) hide show
  1. package/dist/cjs/components/credits/context/hooks/useCountries.d.ts +2 -1
  2. package/dist/cjs/components/credits/context/hooks/useCountries.js +1 -1
  3. package/dist/cjs/components/credits/context/hooks/useCountries.js.map +3 -3
  4. package/dist/cjs/components/credits/context/hooks/useShippingCountries.d.ts +2 -1
  5. package/dist/cjs/components/credits/context/hooks/useShippingCountries.js +1 -1
  6. package/dist/cjs/components/credits/context/hooks/useShippingCountries.js.map +3 -3
  7. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Address.js +1 -1
  8. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Address.js.map +3 -3
  9. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/index.js +1 -1
  10. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/index.js.map +3 -3
  11. package/dist/cjs/components/memberPopup/context/provider.js +1 -1
  12. package/dist/cjs/components/memberPopup/context/provider.js.map +2 -2
  13. package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js +1 -1
  14. package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +3 -3
  15. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivatePanel.js +1 -1
  16. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivatePanel.js.map +3 -3
  17. package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js +1 -1
  18. package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js.map +2 -2
  19. package/dist/cjs/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.d.ts +2 -1
  20. package/dist/cjs/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.js +1 -1
  21. package/dist/cjs/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.js.map +3 -3
  22. package/dist/cjs/components/memberPopup/panels/Referral/hooks/useReferralOverview.js +1 -1
  23. package/dist/cjs/components/memberPopup/panels/Referral/hooks/useReferralOverview.js.map +2 -2
  24. package/dist/cjs/components/registration/authCodeActivate/index.js +1 -1
  25. package/dist/cjs/components/registration/authCodeActivate/index.js.map +3 -3
  26. package/dist/cjs/components/registration/context/provider.d.ts +3 -1
  27. package/dist/cjs/components/registration/context/provider.js +1 -1
  28. package/dist/cjs/components/registration/context/provider.js.map +3 -3
  29. package/dist/cjs/lib/registration/hooks/useEmailValidation.d.ts +1 -1
  30. package/dist/cjs/lib/registration/hooks/useEmailValidation.js +1 -1
  31. package/dist/cjs/lib/registration/hooks/useEmailValidation.js.map +3 -3
  32. package/dist/cjs/lib/registration/hooks/useSendEmailValidation.d.ts +1 -1
  33. package/dist/cjs/lib/registration/hooks/useSendEmailValidation.js +1 -1
  34. package/dist/cjs/lib/registration/hooks/useSendEmailValidation.js.map +3 -3
  35. package/dist/cjs/lib/utils/fetcher/fetcher.d.ts +1 -1
  36. package/dist/cjs/lib/utils/fetcher/fetcher.js +1 -1
  37. package/dist/cjs/lib/utils/fetcher/fetcher.js.map +3 -3
  38. package/dist/cjs/templates/Credits.js +1 -1
  39. package/dist/cjs/templates/Credits.js.map +2 -2
  40. package/dist/esm/components/credits/context/hooks/useCountries.d.ts +2 -1
  41. package/dist/esm/components/credits/context/hooks/useCountries.js +1 -1
  42. package/dist/esm/components/credits/context/hooks/useCountries.js.map +3 -3
  43. package/dist/esm/components/credits/context/hooks/useShippingCountries.d.ts +2 -1
  44. package/dist/esm/components/credits/context/hooks/useShippingCountries.js +1 -1
  45. package/dist/esm/components/credits/context/hooks/useShippingCountries.js.map +3 -3
  46. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Address.js +1 -1
  47. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Address.js.map +3 -3
  48. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/index.js +1 -1
  49. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/index.js.map +3 -3
  50. package/dist/esm/components/memberPopup/context/provider.js +1 -1
  51. package/dist/esm/components/memberPopup/context/provider.js.map +2 -2
  52. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js +1 -1
  53. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +3 -3
  54. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivatePanel.js +1 -1
  55. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivatePanel.js.map +3 -3
  56. package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js +1 -1
  57. package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js.map +2 -2
  58. package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.d.ts +2 -1
  59. package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.js +1 -1
  60. package/dist/esm/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.js.map +3 -3
  61. package/dist/esm/components/memberPopup/panels/Referral/hooks/useReferralOverview.js +1 -1
  62. package/dist/esm/components/memberPopup/panels/Referral/hooks/useReferralOverview.js.map +2 -2
  63. package/dist/esm/components/registration/authCodeActivate/index.js +1 -1
  64. package/dist/esm/components/registration/authCodeActivate/index.js.map +3 -3
  65. package/dist/esm/components/registration/context/provider.d.ts +3 -1
  66. package/dist/esm/components/registration/context/provider.js +1 -1
  67. package/dist/esm/components/registration/context/provider.js.map +3 -3
  68. package/dist/esm/lib/registration/hooks/useEmailValidation.d.ts +1 -1
  69. package/dist/esm/lib/registration/hooks/useEmailValidation.js +1 -1
  70. package/dist/esm/lib/registration/hooks/useEmailValidation.js.map +3 -3
  71. package/dist/esm/lib/registration/hooks/useSendEmailValidation.d.ts +1 -1
  72. package/dist/esm/lib/registration/hooks/useSendEmailValidation.js +1 -1
  73. package/dist/esm/lib/registration/hooks/useSendEmailValidation.js.map +3 -3
  74. package/dist/esm/lib/utils/fetcher/fetcher.d.ts +1 -1
  75. package/dist/esm/lib/utils/fetcher/fetcher.js +1 -1
  76. package/dist/esm/lib/utils/fetcher/fetcher.js.map +3 -3
  77. package/dist/esm/templates/Credits.js +1 -1
  78. package/dist/esm/templates/Credits.js.map +2 -2
  79. package/package.json +1 -1
  80. package/src/components/credits/context/hooks/useCountries.ts +3 -3
  81. package/src/components/credits/context/hooks/useShippingCountries.ts +17 -8
  82. package/src/components/credits/creditsRedeemList/RedeemProductModal/Address.tsx +3 -1
  83. package/src/components/credits/creditsRedeemList/RedeemProductModal/index.tsx +2 -2
  84. package/src/components/memberPopup/context/provider.tsx +1 -0
  85. package/src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx +3 -3
  86. package/src/components/memberPopup/panels/EarnCredits/ActivatePanel.tsx +3 -3
  87. package/src/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.tsx +2 -2
  88. package/src/components/memberPopup/panels/EarnCredits/hooks/useUpdateProfile.ts +4 -3
  89. package/src/components/memberPopup/panels/Referral/hooks/useReferralOverview.ts +1 -1
  90. package/src/components/registration/authCodeActivate/index.tsx +3 -3
  91. package/src/components/registration/context/provider.tsx +8 -1
  92. package/src/lib/registration/hooks/useEmailValidation.ts +3 -1
  93. package/src/lib/registration/hooks/useSendEmailValidation.ts +2 -1
  94. package/src/lib/utils/fetcher/fetcher.ts +2 -1
  95. package/src/templates/Credits.tsx +5 -1
@@ -3,7 +3,7 @@ import { useEffect, useState } from 'react'
3
3
  import { useHeadlessContext } from '../../../../lib'
4
4
  import { type ShippingCountry } from '../../type'
5
5
 
6
- function useCountries({ shopifyStoreDomain }: { shopifyStoreDomain: string }) {
6
+ function useCountries({ shopifyStoreDomain, apiBaseUrl }: { shopifyStoreDomain: string; apiBaseUrl?: string }) {
7
7
  const { locale = '' } = useHeadlessContext()
8
8
 
9
9
  const [isLoading, setLoading] = useState(false)
@@ -13,7 +13,7 @@ function useCountries({ shopifyStoreDomain }: { shopifyStoreDomain: string }) {
13
13
  const fetchCountries = async () => {
14
14
  setLoading(true)
15
15
  try {
16
- const response = await fetch('/api/multipass/account/countries', {
16
+ const response = await fetch(`${apiBaseUrl || ''}/api/multipass/account/countries`, {
17
17
  credentials: 'include',
18
18
  headers: {
19
19
  'current-language': locale,
@@ -39,7 +39,7 @@ function useCountries({ shopifyStoreDomain }: { shopifyStoreDomain: string }) {
39
39
  }
40
40
 
41
41
  fetchCountries()
42
- }, [locale])
42
+ }, [locale, apiBaseUrl])
43
43
 
44
44
  return {
45
45
  isLoading,
@@ -3,7 +3,13 @@ import { useEffect, useState } from 'react'
3
3
  import { useHeadlessContext } from '../../../../lib'
4
4
  import { type ShippingCountry, type ShippingZone } from '../../type'
5
5
 
6
- function useShippingCountries({ shopifyStoreDomain }: { shopifyStoreDomain: string }) {
6
+ function useShippingCountries({
7
+ shopifyStoreDomain,
8
+ apiBaseUrl,
9
+ }: {
10
+ shopifyStoreDomain: string
11
+ apiBaseUrl?: string
12
+ }) {
7
13
  const { locale = '' } = useHeadlessContext()
8
14
 
9
15
  const [isLoading, setLoading] = useState(false)
@@ -13,12 +19,15 @@ function useShippingCountries({ shopifyStoreDomain }: { shopifyStoreDomain: stri
13
19
  const fetchCountries = async () => {
14
20
  setLoading(true)
15
21
  try {
16
- const response = await fetch(`/api/multipass/rainbowbridge/uc/shop/shipping_zones?shop=${shopifyStoreDomain}`, {
17
- credentials: 'include',
18
- headers: {
19
- 'current-language': locale,
20
- },
21
- })
22
+ const response = await fetch(
23
+ `${apiBaseUrl || ''}/api/multipass/rainbowbridge/uc/shop/shipping_zones?shop=${shopifyStoreDomain}`,
24
+ {
25
+ credentials: 'include',
26
+ headers: {
27
+ 'current-language': locale,
28
+ },
29
+ }
30
+ )
22
31
  const res: any = await response.json()
23
32
 
24
33
  // 国家过滤
@@ -50,7 +59,7 @@ function useShippingCountries({ shopifyStoreDomain }: { shopifyStoreDomain: stri
50
59
  }
51
60
 
52
61
  fetchCountries()
53
- }, [locale])
62
+ }, [locale, apiBaseUrl, shopifyStoreDomain])
54
63
 
55
64
  return {
56
65
  isLoading,
@@ -1,5 +1,6 @@
1
1
  import { Button, Text } from '@anker-in/headless-ui'
2
2
  import classNames from 'classnames'
3
+ import { useCreditsContext } from '../../context/provider'
3
4
  import { AddressForm } from '../AddressForm'
4
5
  import { useHeadlessContext } from '../../../../lib'
5
6
  import type { RedeemableItem as RedeemableItemType, RedeemModalCommon } from '../../type'
@@ -35,8 +36,9 @@ export const Address = ({
35
36
  item,
36
37
  }: AddressProps) => {
37
38
  const { storeDomain, brand } = useHeadlessContext()
39
+ const { apiBaseUrl } = useCreditsContext()
38
40
  const rounded = ROUNDED_BRANDS.includes(brand)
39
- const { countries = [], isLoading: countriesLoading } = useShippingCountries({ shopifyStoreDomain: storeDomain })
41
+ const { countries = [], isLoading: countriesLoading } = useShippingCountries({ shopifyStoreDomain: storeDomain, apiBaseUrl })
40
42
 
41
43
  return (
42
44
  <div className="relative">
@@ -21,7 +21,7 @@ type RedeemProductModalProps = Omit<ModalContainerProps, 'isOpen'> & {
21
21
  }
22
22
 
23
23
  function RedeemProductModal({ item, copy, onError, ...props }: RedeemProductModalProps) {
24
- const { fetchCreditInfo, profile, pageCommon } = useCreditsContext()
24
+ const { fetchCreditInfo, profile, pageCommon, apiBaseUrl } = useCreditsContext()
25
25
  const { storeDomain } = useHeadlessContext()
26
26
 
27
27
  const { shippingAddress, shippingProduct } = copy.product
@@ -35,7 +35,7 @@ function RedeemProductModal({ item, copy, onError, ...props }: RedeemProductModa
35
35
  })
36
36
  const [disabled, setDisabled] = useState(false)
37
37
 
38
- const { countries = [], isLoading: countriesLoading } = useShippingCountries({ shopifyStoreDomain: storeDomain })
38
+ const { countries = [], isLoading: countriesLoading } = useShippingCountries({ shopifyStoreDomain: storeDomain, apiBaseUrl })
39
39
 
40
40
  const { isMutating: loading, trigger } = useRedeemProduct({
41
41
  onSuccess(responseData) {
@@ -44,6 +44,7 @@ export function MemberPopupProvider({
44
44
  <RegistrationProvider
45
45
  email={contextValue.profile?.email}
46
46
  copy={{ authCodeActivate: earnCreditsCopy?.authCodeActivate }}
47
+ apiBaseUrl={contextValue.alpcConfig?.apiBaseUrl}
47
48
  >
48
49
  <MemberPopupContext.Provider
49
50
  value={{
@@ -37,7 +37,7 @@ async function getRecaptchaToken(sitekey: string): Promise<string> {
37
37
 
38
38
  export default function ActivitiesSubscribeModal({ copy, email: initialEmail }: Props) {
39
39
  const { alpcConfig, setIsSubscribeSuccess, pageHandle } = useMemberPopupContext()
40
- const { locale } = alpcConfig
40
+ const { locale, apiBaseUrl } = alpcConfig
41
41
  const { brand: headlessBrand, storeDomain, recaptchaSitekey } = useHeadlessContext()
42
42
  const rounded = ROUNDED_BRANDS.includes(headlessBrand)
43
43
  const [policy, setPolicy] = useState(copy.policyDefaultChecked ?? false)
@@ -60,7 +60,7 @@ export default function ActivitiesSubscribeModal({ copy, email: initialEmail }:
60
60
  const { register_source } = getAdCookie()
61
61
  const recaptchaToken = await getRecaptchaToken(recaptchaSitekey || '')
62
62
  try {
63
- const response = await fetch('/api/multipass/rainbowbridge/activities', {
63
+ const response = await fetch(`${apiBaseUrl || ''}/api/multipass/rainbowbridge/activities`, {
64
64
  method: 'POST',
65
65
  credentials: 'include',
66
66
  headers: {
@@ -100,7 +100,7 @@ export default function ActivitiesSubscribeModal({ copy, email: initialEmail }:
100
100
  } finally {
101
101
  setLoading(false)
102
102
  }
103
- }, [email, policy, locale, storeDomain, copy, setIsSubscribeSuccess])
103
+ }, [email, policy, locale, storeDomain, copy, setIsSubscribeSuccess, apiBaseUrl])
104
104
 
105
105
  return (
106
106
  <div className="flex flex-col">
@@ -20,7 +20,7 @@ type Props = {
20
20
  }
21
21
 
22
22
  export default function ActivatePanel({ copy, onClose }: Props) {
23
- const { setIsActivateSuccess, fetchCreditInfo, profile } = useMemberPopupContext()
23
+ const { setIsActivateSuccess, fetchCreditInfo, profile, alpcConfig } = useMemberPopupContext()
24
24
  const { locale, brand } = useHeadlessContext()
25
25
  const { email } = useRegistration()
26
26
  const rounded = ROUNDED_BRANDS.includes(brand)
@@ -29,9 +29,9 @@ export default function ActivatePanel({ copy, onClose }: Props) {
29
29
  isMutating: isSendingEmail,
30
30
  trigger: triggerSendValidationEmail,
31
31
  data: sendEmailData,
32
- } = useSendEmailValidation()
32
+ } = useSendEmailValidation(alpcConfig.apiBaseUrl)
33
33
 
34
- const { isMutating: emailValidationLoading, trigger: triggerEmailValidation } = useEmailValidation()
34
+ const { isMutating: emailValidationLoading, trigger: triggerEmailValidation } = useEmailValidation(undefined, alpcConfig.apiBaseUrl)
35
35
 
36
36
  const [messageText, setMessageText] = useState('')
37
37
  const [messageStatus, setMessageStatus] = useState('')
@@ -26,8 +26,8 @@ export default function CompleteProfilePanel({ copy, onClose }: Props) {
26
26
  const [firstNameError, setFirstNameError] = useState('')
27
27
  const [lastNameError, setLastNameError] = useState('')
28
28
 
29
- const { updateProfile, isLoading } = useUpdateProfile({ locale, appName: alpcConfig.appName })
30
- const { countries } = useCountries({ shopifyStoreDomain: storeDomain })
29
+ const { updateProfile, isLoading } = useUpdateProfile({ locale, appName: alpcConfig.appName, apiBaseUrl: alpcConfig.apiBaseUrl })
30
+ const { countries } = useCountries({ shopifyStoreDomain: storeDomain, apiBaseUrl: alpcConfig.apiBaseUrl })
31
31
 
32
32
  useEffect(() => {
33
33
  if (profile) {
@@ -3,6 +3,7 @@ import { useCallback, useState } from 'react'
3
3
  type UseUpdateProfileConfig = {
4
4
  locale?: string
5
5
  appName?: string
6
+ apiBaseUrl?: string
6
7
  }
7
8
 
8
9
  type ProfileData = {
@@ -13,7 +14,7 @@ type ProfileData = {
13
14
  dob?: string
14
15
  }
15
16
 
16
- export function useUpdateProfile({ locale = '', appName = '' }: UseUpdateProfileConfig = {}) {
17
+ export function useUpdateProfile({ locale = '', appName = '', apiBaseUrl = '' }: UseUpdateProfileConfig = {}) {
17
18
  const [isLoading, setIsLoading] = useState(false)
18
19
  const [error, setError] = useState<string | null>(null)
19
20
 
@@ -22,7 +23,7 @@ export function useUpdateProfile({ locale = '', appName = '' }: UseUpdateProfile
22
23
  setIsLoading(true)
23
24
  setError(null)
24
25
  try {
25
- const response = await fetch('/api/multipass/account/users/update_profile', {
26
+ const response = await fetch(`${apiBaseUrl}/api/multipass/account/users/update_profile`, {
26
27
  method: 'PUT',
27
28
  credentials: 'include',
28
29
  headers: {
@@ -44,7 +45,7 @@ export function useUpdateProfile({ locale = '', appName = '' }: UseUpdateProfile
44
45
  setIsLoading(false)
45
46
  }
46
47
  },
47
- [locale, appName]
48
+ [locale, appName, apiBaseUrl]
48
49
  )
49
50
 
50
51
  return { updateProfile, isLoading, error }
@@ -17,7 +17,7 @@ export function useReferralOverview(): {
17
17
  const { profile, alpcConfig } = useMemberPopupContext()
18
18
  const isLogin = !!profile
19
19
 
20
- const swrKey = isLogin ? `/api/multipass/mktsrv/v1/referral/reward/overview/cash` : null
20
+ const swrKey = isLogin ? `${alpcConfig.apiBaseUrl || ''}/api/multipass/mktsrv/v1/referral/reward/overview/cash` : null
21
21
 
22
22
  const swrFetcher = async (url: string) => {
23
23
  const response = await fetch(url, {
@@ -16,19 +16,19 @@ import { ROUNDED_BRANDS } from '../../../constants'
16
16
 
17
17
  export const AuthCodeActivate: React.FC<AuthCodeActivateProps> = ({ copy }) => {
18
18
  const { locale, brand } = useHeadlessContext()
19
- const { email, authCodeActivate } = useRegistration()
19
+ const { email, authCodeActivate, apiBaseUrl } = useRegistration()
20
20
  const rounded = ROUNDED_BRANDS.includes(brand)
21
21
 
22
22
  const { activeToken, setActiveToken, setIsSendingActivateEmail, setIsActivateSuccess, onAuthSuccess, autoSendEmail } =
23
23
  authCodeActivate
24
24
 
25
- const { isMutating: emailValidationLoading, trigger: triggerEmailValidation } = useEmailValidation()
25
+ const { isMutating: emailValidationLoading, trigger: triggerEmailValidation } = useEmailValidation(undefined, apiBaseUrl)
26
26
 
27
27
  const {
28
28
  isMutating: isSendingEmail,
29
29
  trigger: triggerSendValidationEmail,
30
30
  data: sendEmailData,
31
- } = useSendEmailValidation()
31
+ } = useSendEmailValidation(apiBaseUrl)
32
32
 
33
33
  const [messageText, setMessageText] = useState('')
34
34
  const [messageStatus, setMessageStatus] = useState('')
@@ -4,6 +4,7 @@ import { AuthCodeActivate } from '../authCodeActivate'
4
4
  interface RegistrationContextType {
5
5
  email?: string
6
6
  copy?: any
7
+ apiBaseUrl?: string
7
8
  authCodeActivate: {
8
9
  isOpen: boolean
9
10
  open: () => void
@@ -49,7 +50,12 @@ export const useRegistration = () => {
49
50
  return context
50
51
  }
51
52
 
52
- export const RegistrationProvider = ({ children, email, copy }: PropsWithChildren<{ email?: string; copy?: any }>) => {
53
+ export const RegistrationProvider = ({
54
+ children,
55
+ email,
56
+ copy,
57
+ apiBaseUrl,
58
+ }: PropsWithChildren<{ email?: string; copy?: any; apiBaseUrl?: string }>) => {
53
59
  const [popAuthCode, setPopAuthCode] = useState(false)
54
60
  const [onAuthSuccess, setOnAuthSuccess] = useState<(() => void) | undefined>(undefined)
55
61
  const [isActivateSuccess, setIsActivateSuccess] = useState(false)
@@ -62,6 +68,7 @@ export const RegistrationProvider = ({ children, email, copy }: PropsWithChildre
62
68
  value={{
63
69
  email,
64
70
  copy,
71
+ apiBaseUrl,
65
72
  authCodeActivate: {
66
73
  activeToken,
67
74
  isOpen: popAuthCode,
@@ -8,7 +8,8 @@ export const useEmailValidation = (
8
8
  { type: 'responseError'; data: any; response: any },
9
9
  string,
10
10
  { token: string; code: string }
11
- >
11
+ >,
12
+ apiBaseUrl?: string
12
13
  ) => {
13
14
  const { locale } = useHeadlessContext()
14
15
  return useSWRMutation(
@@ -16,6 +17,7 @@ export const useEmailValidation = (
16
17
  (_, { arg: { token, code } }: { arg: { token: string; code: string } }) => {
17
18
  return fetcher({
18
19
  url: `/api/multipass/account/users/email_validation`,
20
+ baseUrl: apiBaseUrl,
19
21
  method: 'POST',
20
22
  body: { activation_code: token, verify_code: code },
21
23
  action: 'account',
@@ -5,13 +5,14 @@ import { fetcher } from '../../utils'
5
5
  // data 参数会被 stringify 后放入到邮件链接参数中
6
6
  export type RequestData = { email: string; data: any }
7
7
 
8
- export function useSendEmailValidation(): SWRMutationResponse<any, any, string, { email: string } & any> {
8
+ export function useSendEmailValidation(apiBaseUrl?: string): SWRMutationResponse<any, any, string, { email: string } & any> {
9
9
  const { appName, locale } = useHeadlessContext()
10
10
 
11
11
  return useSWRMutation('send-email-validation', (_, { arg: { email, ...rest } }: { arg: RequestData }) =>
12
12
  fetcher({
13
13
  locale,
14
14
  url: '/api/multipass/account/users/send_validation_email',
15
+ baseUrl: apiBaseUrl,
15
16
  method: 'POST',
16
17
  body: { email: email, app: appName, ...rest },
17
18
  needRecaptcha: true,
@@ -3,6 +3,7 @@ import { handleFetchResponse } from './fetchResponse'
3
3
  export const fetcher = async ({
4
4
  locale = 'en',
5
5
  url,
6
+ baseUrl,
6
7
  method = 'POST',
7
8
  headers = {},
8
9
  repeatKey,
@@ -24,7 +25,7 @@ export const fetcher = async ({
24
25
  setTimeout(() => controller.abort(), timeout)
25
26
  }
26
27
 
27
- const data = await fetch(url, {
28
+ const data = await fetch(`${baseUrl || ''}${url}`, {
28
29
  method,
29
30
  mode: 'cors',
30
31
  credentials: 'include',
@@ -150,7 +150,11 @@ export const CreditsTemplate = ({
150
150
  }: CreditsTemplateProps) => {
151
151
  return (
152
152
  <HeadlessProvider headlessConfig={headlessConfig}>
153
- <RegistrationProvider copy={siteConfig.registrationsSettings} email={userContext?.profile?.email}>
153
+ <RegistrationProvider
154
+ copy={siteConfig.registrationsSettings}
155
+ email={userContext?.profile?.email}
156
+ apiBaseUrl={userContext?.apiBaseUrl}
157
+ >
154
158
  <CreditsProvider
155
159
  profile={userContext?.profile}
156
160
  removeProfile={userContext?.removeProfile}