@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
@@ -1,6 +1,7 @@
1
1
  import { type ShippingCountry } from '../../type';
2
- declare function useCountries({ shopifyStoreDomain }: {
2
+ declare function useCountries({ shopifyStoreDomain, apiBaseUrl }: {
3
3
  shopifyStoreDomain: string;
4
+ apiBaseUrl?: string;
4
5
  }): {
5
6
  isLoading: boolean;
6
7
  countries: ShippingCountry[];
@@ -1,2 +1,2 @@
1
- "use strict";var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var s in e)a(t,s,{get:e[s],enumerable:!0})},d=(t,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of m(e))!C.call(t,o)&&o!==s&&a(t,o,{get:()=>e[o],enumerable:!(n=h(e,o))||n.enumerable});return t};var g=t=>d(a({},"__esModule",{value:!0}),t);var x={};y(x,{default:()=>w});module.exports=g(x);var r=require("react"),p=require("../../../../lib");function S({shopifyStoreDomain:t}){const{locale:e=""}=(0,p.useHeadlessContext)(),[s,n]=(0,r.useState)(!1),[o,c]=(0,r.useState)([]);return(0,r.useEffect)(()=>{(async()=>{n(!0);try{let i=(await(await fetch("/api/multipass/account/countries",{credentials:"include",headers:{"current-language":e}})).json())?.data?.data||[];i=i.sort((l,f)=>l.name.localeCompare(f.name)),console.log("fetch shipsToCountries",i),c(i)}catch(u){c([]),console.error(u)}finally{n(!1)}})()},[e]),{isLoading:s,countries:o}}var w=S;
1
+ "use strict";var a=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var s in e)a(t,s,{get:e[s],enumerable:!0})},d=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of C(e))!g.call(t,o)&&o!==s&&a(t,o,{get:()=>e[o],enumerable:!(r=m(e,o))||r.enumerable});return t};var S=t=>d(a({},"__esModule",{value:!0}),t);var D={};y(D,{default:()=>x});module.exports=S(D);var n=require("react"),p=require("../../../../lib");function w({shopifyStoreDomain:t,apiBaseUrl:e}){const{locale:s=""}=(0,p.useHeadlessContext)(),[r,o]=(0,n.useState)(!1),[l,c]=(0,n.useState)([]);return(0,n.useEffect)(()=>{(async()=>{o(!0);try{let i=(await(await fetch(`${e||""}/api/multipass/account/countries`,{credentials:"include",headers:{"current-language":s}})).json())?.data?.data||[];i=i.sort((f,h)=>f.name.localeCompare(h.name)),console.log("fetch shipsToCountries",i),c(i)}catch(u){c([]),console.error(u)}finally{o(!1)}})()},[s,e]),{isLoading:r,countries:l}}var x=w;
2
2
  //# sourceMappingURL=useCountries.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/credits/context/hooks/useCountries.ts"],
4
- "sourcesContent": ["import { useEffect, useState } from 'react'\n\nimport { useHeadlessContext } from '../../../../lib'\nimport { type ShippingCountry } from '../../type'\n\nfunction useCountries({ shopifyStoreDomain }: { shopifyStoreDomain: string }) {\n const { locale = '' } = useHeadlessContext()\n\n const [isLoading, setLoading] = useState(false)\n const [countries, setCountries] = useState<ShippingCountry[]>([])\n\n useEffect(() => {\n const fetchCountries = async () => {\n setLoading(true)\n try {\n const response = await fetch('/api/multipass/account/countries', {\n credentials: 'include',\n headers: {\n 'current-language': locale,\n },\n })\n const res: any = await response.json()\n\n let shipsToCountries: ShippingCountry[] = res?.data?.data || []\n\n // \u5B57\u6BCD\u987A\u5E8F\u6392\u5E8F\n shipsToCountries = shipsToCountries.sort((a, b) => {\n return a.name.localeCompare(b.name)\n })\n\n console.log('fetch shipsToCountries', shipsToCountries)\n setCountries(shipsToCountries)\n } catch (e) {\n setCountries([])\n console.error(e)\n } finally {\n setLoading(false)\n }\n }\n\n fetchCountries()\n }, [locale])\n\n return {\n isLoading,\n countries,\n }\n}\n\nexport default useCountries\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,iBAEpCC,EAAmC,2BAGnC,SAASC,EAAa,CAAE,mBAAAC,CAAmB,EAAmC,CAC5E,KAAM,CAAE,OAAAC,EAAS,EAAG,KAAI,sBAAmB,EAErC,CAACC,EAAWC,CAAU,KAAI,YAAS,EAAK,EACxC,CAACC,EAAWC,CAAY,KAAI,YAA4B,CAAC,CAAC,EAEhE,sBAAU,IAAM,EACS,SAAY,CACjCF,EAAW,EAAI,EACf,GAAI,CASF,IAAIG,GAFa,MANA,MAAM,MAAM,mCAAoC,CAC/D,YAAa,UACb,QAAS,CACP,mBAAoBL,CACtB,CACF,CAAC,GAC+B,KAAK,IAEU,MAAM,MAAQ,CAAC,EAG9DK,EAAmBA,EAAiB,KAAK,CAACC,EAAGC,IACpCD,EAAE,KAAK,cAAcC,EAAE,IAAI,CACnC,EAED,QAAQ,IAAI,yBAA0BF,CAAgB,EACtDD,EAAaC,CAAgB,CAC/B,OAASG,EAAG,CACVJ,EAAa,CAAC,CAAC,EACf,QAAQ,MAAMI,CAAC,CACjB,QAAE,CACAN,EAAW,EAAK,CAClB,CACF,GAEe,CACjB,EAAG,CAACF,CAAM,CAAC,EAEJ,CACL,UAAAC,EACA,UAAAE,CACF,CACF,CAEA,IAAOT,EAAQI",
6
- "names": ["useCountries_exports", "__export", "useCountries_default", "__toCommonJS", "import_react", "import_lib", "useCountries", "shopifyStoreDomain", "locale", "isLoading", "setLoading", "countries", "setCountries", "shipsToCountries", "a", "b", "e"]
4
+ "sourcesContent": ["import { useEffect, useState } from 'react'\n\nimport { useHeadlessContext } from '../../../../lib'\nimport { type ShippingCountry } from '../../type'\n\nfunction useCountries({ shopifyStoreDomain, apiBaseUrl }: { shopifyStoreDomain: string; apiBaseUrl?: string }) {\n const { locale = '' } = useHeadlessContext()\n\n const [isLoading, setLoading] = useState(false)\n const [countries, setCountries] = useState<ShippingCountry[]>([])\n\n useEffect(() => {\n const fetchCountries = async () => {\n setLoading(true)\n try {\n const response = await fetch(`${apiBaseUrl || ''}/api/multipass/account/countries`, {\n credentials: 'include',\n headers: {\n 'current-language': locale,\n },\n })\n const res: any = await response.json()\n\n let shipsToCountries: ShippingCountry[] = res?.data?.data || []\n\n // \u5B57\u6BCD\u987A\u5E8F\u6392\u5E8F\n shipsToCountries = shipsToCountries.sort((a, b) => {\n return a.name.localeCompare(b.name)\n })\n\n console.log('fetch shipsToCountries', shipsToCountries)\n setCountries(shipsToCountries)\n } catch (e) {\n setCountries([])\n console.error(e)\n } finally {\n setLoading(false)\n }\n }\n\n fetchCountries()\n }, [locale, apiBaseUrl])\n\n return {\n isLoading,\n countries,\n }\n}\n\nexport default useCountries\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,iBAEpCC,EAAmC,2BAGnC,SAASC,EAAa,CAAE,mBAAAC,EAAoB,WAAAC,CAAW,EAAwD,CAC7G,KAAM,CAAE,OAAAC,EAAS,EAAG,KAAI,sBAAmB,EAErC,CAACC,EAAWC,CAAU,KAAI,YAAS,EAAK,EACxC,CAACC,EAAWC,CAAY,KAAI,YAA4B,CAAC,CAAC,EAEhE,sBAAU,IAAM,EACS,SAAY,CACjCF,EAAW,EAAI,EACf,GAAI,CASF,IAAIG,GAFa,MANA,MAAM,MAAM,GAAGN,GAAc,EAAE,mCAAoC,CAClF,YAAa,UACb,QAAS,CACP,mBAAoBC,CACtB,CACF,CAAC,GAC+B,KAAK,IAEU,MAAM,MAAQ,CAAC,EAG9DK,EAAmBA,EAAiB,KAAK,CAACC,EAAGC,IACpCD,EAAE,KAAK,cAAcC,EAAE,IAAI,CACnC,EAED,QAAQ,IAAI,yBAA0BF,CAAgB,EACtDD,EAAaC,CAAgB,CAC/B,OAASG,EAAG,CACVJ,EAAa,CAAC,CAAC,EACf,QAAQ,MAAMI,CAAC,CACjB,QAAE,CACAN,EAAW,EAAK,CAClB,CACF,GAEe,CACjB,EAAG,CAACF,EAAQD,CAAU,CAAC,EAEhB,CACL,UAAAE,EACA,UAAAE,CACF,CACF,CAEA,IAAOV,EAAQI",
6
+ "names": ["useCountries_exports", "__export", "useCountries_default", "__toCommonJS", "import_react", "import_lib", "useCountries", "shopifyStoreDomain", "apiBaseUrl", "locale", "isLoading", "setLoading", "countries", "setCountries", "shipsToCountries", "a", "b", "e"]
7
7
  }
@@ -1,6 +1,7 @@
1
1
  import { type ShippingCountry } from '../../type';
2
- declare function useShippingCountries({ shopifyStoreDomain }: {
2
+ declare function useShippingCountries({ shopifyStoreDomain, apiBaseUrl, }: {
3
3
  shopifyStoreDomain: string;
4
+ apiBaseUrl?: string;
4
5
  }): {
5
6
  isLoading: boolean;
6
7
  countries: ShippingCountry[];
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var C=(o,e)=>{for(var t in e)p(o,t,{get:e[t],enumerable:!0})},m=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of S(e))!y.call(o,s)&&s!==t&&p(o,s,{get:()=>e[s],enumerable:!(n=g(e,s))||n.enumerable});return o};var w=o=>m(p({},"__esModule",{value:!0}),o);var x={};C(x,{default:()=>b});module.exports=w(x);var a=require("react"),d=require("../../../../lib");function E({shopifyStoreDomain:o}){const{locale:e=""}=(0,d.useHeadlessContext)(),[t,n]=(0,a.useState)(!1),[s,u]=(0,a.useState)([]);return(0,a.useEffect)(()=>{(async()=>{n(!0);try{const f=await(await fetch(`/api/multipass/rainbowbridge/uc/shop/shipping_zones?shop=${o}`,{credentials:"include",headers:{"current-language":e}})).json();let i=[];const l=new Set;(f?.data?.data||f?.data||[]).forEach(c=>{c.countries.forEach(r=>{l.has(r.code)||(l.add(r.code),i.push(r))})}),i=i.sort((c,r)=>c.code.localeCompare(r.code)),console.log("fetch shipsToCountries",i),u(i)}catch(h){u([]),console.error(h)}finally{n(!1)}})()},[e]),{isLoading:t,countries:s}}var b=E;
1
+ "use strict";var p=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var m=(o,e)=>{for(var t in e)p(o,t,{get:e[t],enumerable:!0})},w=(o,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of S(e))!y.call(o,s)&&s!==t&&p(o,s,{get:()=>e[s],enumerable:!(a=C(e,s))||a.enumerable});return o};var E=o=>w(p({},"__esModule",{value:!0}),o);var L={};m(L,{default:()=>x});module.exports=E(L);var r=require("react"),f=require("../../../../lib");function b({shopifyStoreDomain:o,apiBaseUrl:e}){const{locale:t=""}=(0,f.useHeadlessContext)(),[a,s]=(0,r.useState)(!1),[g,u]=(0,r.useState)([]);return(0,r.useEffect)(()=>{(async()=>{s(!0);try{const l=await(await fetch(`${e||""}/api/multipass/rainbowbridge/uc/shop/shipping_zones?shop=${o}`,{credentials:"include",headers:{"current-language":t}})).json();let n=[];const d=new Set;(l?.data?.data||l?.data||[]).forEach(c=>{c.countries.forEach(i=>{d.has(i.code)||(d.add(i.code),n.push(i))})}),n=n.sort((c,i)=>c.code.localeCompare(i.code)),console.log("fetch shipsToCountries",n),u(n)}catch(h){u([]),console.error(h)}finally{s(!1)}})()},[t,e,o]),{isLoading:a,countries:g}}var x=b;
2
2
  //# sourceMappingURL=useShippingCountries.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/credits/context/hooks/useShippingCountries.ts"],
4
- "sourcesContent": ["import { useEffect, useState } from 'react'\n\nimport { useHeadlessContext } from '../../../../lib'\nimport { type ShippingCountry, type ShippingZone } from '../../type'\n\nfunction useShippingCountries({ shopifyStoreDomain }: { shopifyStoreDomain: string }) {\n const { locale = '' } = useHeadlessContext()\n\n const [isLoading, setLoading] = useState(false)\n const [countries, setCountries] = useState<ShippingCountry[]>([])\n\n useEffect(() => {\n const fetchCountries = async () => {\n setLoading(true)\n try {\n const response = await fetch(`/api/multipass/rainbowbridge/uc/shop/shipping_zones?shop=${shopifyStoreDomain}`, {\n credentials: 'include',\n headers: {\n 'current-language': locale,\n },\n })\n const res: any = await response.json()\n\n // \u56FD\u5BB6\u8FC7\u6EE4\n let shipsToCountries: ShippingCountry[] = []\n const countrySet = new Set()\n const shippingZones = res?.data?.data || res?.data || []\n shippingZones.forEach((shippingZoneItem: ShippingZone) => {\n shippingZoneItem.countries.forEach(shippingZoneCountryItem => {\n if (!countrySet.has(shippingZoneCountryItem.code)) {\n countrySet.add(shippingZoneCountryItem.code)\n shipsToCountries.push(shippingZoneCountryItem)\n }\n })\n })\n\n // \u5B57\u6BCD\u987A\u5E8F\u6392\u5E8F\n shipsToCountries = shipsToCountries.sort((a, b) => {\n return a.code.localeCompare(b.code)\n })\n\n console.log('fetch shipsToCountries', shipsToCountries)\n setCountries(shipsToCountries)\n } catch (e) {\n setCountries([])\n console.error(e)\n } finally {\n setLoading(false)\n }\n }\n\n fetchCountries()\n }, [locale])\n\n return {\n isLoading,\n countries,\n }\n}\n\nexport default useShippingCountries\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,iBAEpCC,EAAmC,2BAGnC,SAASC,EAAqB,CAAE,mBAAAC,CAAmB,EAAmC,CACpF,KAAM,CAAE,OAAAC,EAAS,EAAG,KAAI,sBAAmB,EAErC,CAACC,EAAWC,CAAU,KAAI,YAAS,EAAK,EACxC,CAACC,EAAWC,CAAY,KAAI,YAA4B,CAAC,CAAC,EAEhE,sBAAU,IAAM,EACS,SAAY,CACjCF,EAAW,EAAI,EACf,GAAI,CAOF,MAAMG,EAAW,MANA,MAAM,MAAM,4DAA4DN,CAAkB,GAAI,CAC7G,YAAa,UACb,QAAS,CACP,mBAAoBC,CACtB,CACF,CAAC,GAC+B,KAAK,EAGrC,IAAIM,EAAsC,CAAC,EAC3C,MAAMC,EAAa,IAAI,KACDF,GAAK,MAAM,MAAQA,GAAK,MAAQ,CAAC,GACzC,QAASG,GAAmC,CACxDA,EAAiB,UAAU,QAAQC,GAA2B,CACvDF,EAAW,IAAIE,EAAwB,IAAI,IAC9CF,EAAW,IAAIE,EAAwB,IAAI,EAC3CH,EAAiB,KAAKG,CAAuB,EAEjD,CAAC,CACH,CAAC,EAGDH,EAAmBA,EAAiB,KAAK,CAACI,EAAGC,IACpCD,EAAE,KAAK,cAAcC,EAAE,IAAI,CACnC,EAED,QAAQ,IAAI,yBAA0BL,CAAgB,EACtDF,EAAaE,CAAgB,CAC/B,OAASM,EAAG,CACVR,EAAa,CAAC,CAAC,EACf,QAAQ,MAAMQ,CAAC,CACjB,QAAE,CACAV,EAAW,EAAK,CAClB,CACF,GAEe,CACjB,EAAG,CAACF,CAAM,CAAC,EAEJ,CACL,UAAAC,EACA,UAAAE,CACF,CACF,CAEA,IAAOT,EAAQI",
6
- "names": ["useShippingCountries_exports", "__export", "useShippingCountries_default", "__toCommonJS", "import_react", "import_lib", "useShippingCountries", "shopifyStoreDomain", "locale", "isLoading", "setLoading", "countries", "setCountries", "res", "shipsToCountries", "countrySet", "shippingZoneItem", "shippingZoneCountryItem", "a", "b", "e"]
4
+ "sourcesContent": ["import { useEffect, useState } from 'react'\n\nimport { useHeadlessContext } from '../../../../lib'\nimport { type ShippingCountry, type ShippingZone } from '../../type'\n\nfunction useShippingCountries({\n shopifyStoreDomain,\n apiBaseUrl,\n}: {\n shopifyStoreDomain: string\n apiBaseUrl?: string\n}) {\n const { locale = '' } = useHeadlessContext()\n\n const [isLoading, setLoading] = useState(false)\n const [countries, setCountries] = useState<ShippingCountry[]>([])\n\n useEffect(() => {\n const fetchCountries = async () => {\n setLoading(true)\n try {\n const response = await fetch(\n `${apiBaseUrl || ''}/api/multipass/rainbowbridge/uc/shop/shipping_zones?shop=${shopifyStoreDomain}`,\n {\n credentials: 'include',\n headers: {\n 'current-language': locale,\n },\n }\n )\n const res: any = await response.json()\n\n // \u56FD\u5BB6\u8FC7\u6EE4\n let shipsToCountries: ShippingCountry[] = []\n const countrySet = new Set()\n const shippingZones = res?.data?.data || res?.data || []\n shippingZones.forEach((shippingZoneItem: ShippingZone) => {\n shippingZoneItem.countries.forEach(shippingZoneCountryItem => {\n if (!countrySet.has(shippingZoneCountryItem.code)) {\n countrySet.add(shippingZoneCountryItem.code)\n shipsToCountries.push(shippingZoneCountryItem)\n }\n })\n })\n\n // \u5B57\u6BCD\u987A\u5E8F\u6392\u5E8F\n shipsToCountries = shipsToCountries.sort((a, b) => {\n return a.code.localeCompare(b.code)\n })\n\n console.log('fetch shipsToCountries', shipsToCountries)\n setCountries(shipsToCountries)\n } catch (e) {\n setCountries([])\n console.error(e)\n } finally {\n setLoading(false)\n }\n }\n\n fetchCountries()\n }, [locale, apiBaseUrl, shopifyStoreDomain])\n\n return {\n isLoading,\n countries,\n }\n}\n\nexport default useShippingCountries\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,iBAEpCC,EAAmC,2BAGnC,SAASC,EAAqB,CAC5B,mBAAAC,EACA,WAAAC,CACF,EAGG,CACD,KAAM,CAAE,OAAAC,EAAS,EAAG,KAAI,sBAAmB,EAErC,CAACC,EAAWC,CAAU,KAAI,YAAS,EAAK,EACxC,CAACC,EAAWC,CAAY,KAAI,YAA4B,CAAC,CAAC,EAEhE,sBAAU,IAAM,EACS,SAAY,CACjCF,EAAW,EAAI,EACf,GAAI,CAUF,MAAMG,EAAW,MATA,MAAM,MACrB,GAAGN,GAAc,EAAE,4DAA4DD,CAAkB,GACjG,CACE,YAAa,UACb,QAAS,CACP,mBAAoBE,CACtB,CACF,CACF,GACgC,KAAK,EAGrC,IAAIM,EAAsC,CAAC,EAC3C,MAAMC,EAAa,IAAI,KACDF,GAAK,MAAM,MAAQA,GAAK,MAAQ,CAAC,GACzC,QAASG,GAAmC,CACxDA,EAAiB,UAAU,QAAQC,GAA2B,CACvDF,EAAW,IAAIE,EAAwB,IAAI,IAC9CF,EAAW,IAAIE,EAAwB,IAAI,EAC3CH,EAAiB,KAAKG,CAAuB,EAEjD,CAAC,CACH,CAAC,EAGDH,EAAmBA,EAAiB,KAAK,CAACI,EAAGC,IACpCD,EAAE,KAAK,cAAcC,EAAE,IAAI,CACnC,EAED,QAAQ,IAAI,yBAA0BL,CAAgB,EACtDF,EAAaE,CAAgB,CAC/B,OAASM,EAAG,CACVR,EAAa,CAAC,CAAC,EACf,QAAQ,MAAMQ,CAAC,CACjB,QAAE,CACAV,EAAW,EAAK,CAClB,CACF,GAEe,CACjB,EAAG,CAACF,EAAQD,EAAYD,CAAkB,CAAC,EAEpC,CACL,UAAAG,EACA,UAAAE,CACF,CACF,CAEA,IAAOV,EAAQI",
6
+ "names": ["useShippingCountries_exports", "__export", "useShippingCountries_default", "__toCommonJS", "import_react", "import_lib", "useShippingCountries", "shopifyStoreDomain", "apiBaseUrl", "locale", "isLoading", "setLoading", "countries", "setCountries", "res", "shipsToCountries", "countrySet", "shippingZoneItem", "shippingZoneCountryItem", "a", "b", "e"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var D=Object.create;var a=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var k=(e,o)=>{for(var d in o)a(e,d,{get:o[d],enumerable:!0})},p=(e,o,d,m)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of B(o))!P.call(e,s)&&s!==d&&a(e,s,{get:()=>o[s],enumerable:!(m=T(o,s))||m.enumerable});return e};var l=(e,o,d)=>(d=e!=null?D(I(e)):{},p(o||!e||!e.__esModule?a(d,"default",{value:e,enumerable:!0}):d,e)),L=e=>p(a({},"__esModule",{value:!0}),e);var E={};k(E,{Address:()=>S});module.exports=L(E);var t=require("react/jsx-runtime"),r=require("@anker-in/headless-ui"),i=l(require("classnames")),x=require("../AddressForm"),c=require("../../../../lib"),u=require("./ProductInfo"),f=l(require("../../context/hooks/useShippingCountries")),v=require("../../../../constants");const S=({copy:e,shippingAddress:o,setAddress:d,validateAddress:m,validateErrors:s,shippingProduct:n,loading:b,address:g,disabled:y,handlePayment:N,item:R})=>{const{storeDomain:h,brand:A}=(0,c.useHeadlessContext)(),F=v.ROUNDED_BRANDS.includes(A),{countries:C=[],isLoading:w}=(0,f.default)({shopifyStoreDomain:h});return(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:(0,i.default)("max-h-[500px] overflow-y-auto px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]"),children:(0,t.jsxs)("div",{children:[o&&(0,t.jsx)(r.Text,{className:"mb-5 text-[16px] font-bold",html:o}),e?.product?.addressForm&&(0,t.jsx)(x.AddressForm,{onChange:d,validate:m,errors:s,form:e.product.addressForm,countries:C,countriesLoading:w})]})}),(0,t.jsxs)("div",{className:"sticky bottom-0 flex flex-col items-center justify-center bg-white px-[48px] py-[24px] l:px-[16px]",children:[(0,t.jsxs)("div",{className:(0,i.default)("flex w-full items-center bg-[#F5F5F7] p-[16px]",!F&&"rounded-none"),children:[n&&(0,t.jsx)(r.Text,{className:"mb-5 text-[16px] font-bold",html:n}),(0,t.jsx)(u.ProductInfo,{item:R,copy:e})]}),(0,t.jsx)(r.Button,{loading:b||!g,variant:"primary",className:"mx-auto mt-[16px] w-[444px] md:mt-[12px] md:w-full",onClick:N,disabled:y,children:e.product.paymentButton})]})]})};
1
+ "use strict";var T=Object.create;var a=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var S=(e,o)=>{for(var s in o)a(e,s,{get:o[s],enumerable:!0})},p=(e,o,s,m)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of P(o))!L.call(e,d)&&d!==s&&a(e,d,{get:()=>o[d],enumerable:!(m=I(o,d))||m.enumerable});return e};var l=(e,o,s)=>(s=e!=null?T(k(e)):{},p(o||!e||!e.__esModule?a(s,"default",{value:e,enumerable:!0}):s,e)),E=e=>p(a({},"__esModule",{value:!0}),e);var U={};S(U,{Address:()=>M});module.exports=E(U);var t=require("react/jsx-runtime"),r=require("@anker-in/headless-ui"),i=l(require("classnames")),x=require("../../context/provider"),c=require("../AddressForm"),u=require("../../../../lib"),f=require("./ProductInfo"),v=l(require("../../context/hooks/useShippingCountries")),b=require("../../../../constants");const M=({copy:e,shippingAddress:o,setAddress:s,validateAddress:m,validateErrors:d,shippingProduct:n,loading:g,address:y,disabled:N,handlePayment:R,item:h})=>{const{storeDomain:A,brand:C}=(0,u.useHeadlessContext)(),{apiBaseUrl:F}=(0,x.useCreditsContext)(),w=b.ROUNDED_BRANDS.includes(C),{countries:B=[],isLoading:D}=(0,v.default)({shopifyStoreDomain:A,apiBaseUrl:F});return(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:(0,i.default)("max-h-[500px] overflow-y-auto px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]"),children:(0,t.jsxs)("div",{children:[o&&(0,t.jsx)(r.Text,{className:"mb-5 text-[16px] font-bold",html:o}),e?.product?.addressForm&&(0,t.jsx)(c.AddressForm,{onChange:s,validate:m,errors:d,form:e.product.addressForm,countries:B,countriesLoading:D})]})}),(0,t.jsxs)("div",{className:"sticky bottom-0 flex flex-col items-center justify-center bg-white px-[48px] py-[24px] l:px-[16px]",children:[(0,t.jsxs)("div",{className:(0,i.default)("flex w-full items-center bg-[#F5F5F7] p-[16px]",!w&&"rounded-none"),children:[n&&(0,t.jsx)(r.Text,{className:"mb-5 text-[16px] font-bold",html:n}),(0,t.jsx)(f.ProductInfo,{item:h,copy:e})]}),(0,t.jsx)(r.Button,{loading:g||!y,variant:"primary",className:"mx-auto mt-[16px] w-[444px] md:mt-[12px] md:w-full",onClick:R,disabled:N,children:e.product.paymentButton})]})]})};
2
2
  //# sourceMappingURL=Address.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/credits/creditsRedeemList/RedeemProductModal/Address.tsx"],
4
- "sourcesContent": ["import { Button, Text } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { AddressForm } from '../AddressForm'\nimport { useHeadlessContext } from '../../../../lib'\nimport type { RedeemableItem as RedeemableItemType, RedeemModalCommon } from '../../type'\nimport { ProductInfo } from './ProductInfo'\nimport useShippingCountries from '../../context/hooks/useShippingCountries'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype AddressProps = {\n copy: RedeemModalCommon\n shippingAddress: string\n setAddress: (address: Record<string, any>) => void\n validateAddress: (address: Record<string, any>) => boolean\n validateErrors: { key: string; message: string }[]\n item: RedeemableItemType\n loading: boolean\n address: Record<string, any> | undefined\n disabled: boolean\n handlePayment: () => void\n shippingProduct: string\n}\n\nexport const Address = ({\n copy,\n shippingAddress,\n setAddress,\n validateAddress,\n validateErrors,\n shippingProduct,\n loading,\n address,\n disabled,\n handlePayment,\n item,\n}: AddressProps) => {\n const { storeDomain, brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const { countries = [], isLoading: countriesLoading } = useShippingCountries({ shopifyStoreDomain: storeDomain })\n\n return (\n <div className=\"relative\">\n <div className={classNames('max-h-[500px] overflow-y-auto px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]')}>\n <div>\n {shippingAddress && <Text className=\"mb-5 text-[16px] font-bold\" html={shippingAddress}></Text>}\n {copy?.product?.addressForm && (\n <AddressForm\n onChange={setAddress}\n validate={validateAddress}\n errors={validateErrors}\n form={copy.product.addressForm}\n countries={countries}\n countriesLoading={countriesLoading}\n ></AddressForm>\n )}\n </div>\n </div>\n <div className=\"sticky bottom-0 flex flex-col items-center justify-center bg-white px-[48px] py-[24px] l:px-[16px]\">\n <div className={classNames('flex w-full items-center bg-[#F5F5F7] p-[16px]', !rounded && 'rounded-none')}>\n {shippingProduct && <Text className=\"mb-5 text-[16px] font-bold\" html={shippingProduct}></Text>}\n <ProductInfo item={item} copy={copy} />\n </div>\n <Button\n loading={loading || !address}\n variant=\"primary\"\n className=\"mx-auto mt-[16px] w-[444px] md:mt-[12px] md:w-full\"\n onClick={handlePayment}\n disabled={disabled}\n >\n {copy.product.paymentButton}\n </Button>\n </div>\n </div>\n )\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA2CQ,IAAAI,EAAA,6BA3CRC,EAA6B,iCAC7BC,EAAuB,yBACvBC,EAA4B,0BAC5BC,EAAmC,2BAEnCC,EAA4B,yBAC5BC,EAAiC,uDACjCC,EAA+B,iCAgBxB,MAAMT,EAAU,CAAC,CACtB,KAAAU,EACA,gBAAAC,EACA,WAAAC,EACA,gBAAAC,EACA,eAAAC,EACA,gBAAAC,EACA,QAAAC,EACA,QAAAC,EACA,SAAAC,EACA,cAAAC,EACA,KAAAC,CACF,IAAoB,CAClB,KAAM,CAAE,YAAAC,EAAa,MAAAC,CAAM,KAAI,sBAAmB,EAC5CC,EAAU,iBAAe,SAASD,CAAK,EACvC,CAAE,UAAAE,EAAY,CAAC,EAAG,UAAWC,CAAiB,KAAI,EAAAC,SAAqB,CAAE,mBAAoBL,CAAY,CAAC,EAEhH,SACE,QAAC,OAAI,UAAU,WACb,oBAAC,OAAI,aAAW,EAAAM,SAAW,iFAAiF,EAC1G,oBAAC,OACE,UAAAhB,MAAmB,OAAC,QAAK,UAAU,6BAA6B,KAAMA,EAAiB,EACvFD,GAAM,SAAS,gBACd,OAAC,eACC,SAAUE,EACV,SAAUC,EACV,OAAQC,EACR,KAAMJ,EAAK,QAAQ,YACnB,UAAWc,EACX,iBAAkBC,EACnB,GAEL,EACF,KACA,QAAC,OAAI,UAAU,qGACb,qBAAC,OAAI,aAAW,EAAAE,SAAW,iDAAkD,CAACJ,GAAW,cAAc,EACpG,UAAAR,MAAmB,OAAC,QAAK,UAAU,6BAA6B,KAAMA,EAAiB,KACxF,OAAC,eAAY,KAAMK,EAAM,KAAMV,EAAM,GACvC,KACA,OAAC,UACC,QAASM,GAAW,CAACC,EACrB,QAAQ,UACR,UAAU,qDACV,QAASE,EACT,SAAUD,EAET,SAAAR,EAAK,QAAQ,cAChB,GACF,GACF,CAEJ",
6
- "names": ["Address_exports", "__export", "Address", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_classnames", "import_AddressForm", "import_lib", "import_ProductInfo", "import_useShippingCountries", "import_constants", "copy", "shippingAddress", "setAddress", "validateAddress", "validateErrors", "shippingProduct", "loading", "address", "disabled", "handlePayment", "item", "storeDomain", "brand", "rounded", "countries", "countriesLoading", "useShippingCountries", "classNames"]
4
+ "sourcesContent": ["import { Button, Text } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { useCreditsContext } from '../../context/provider'\nimport { AddressForm } from '../AddressForm'\nimport { useHeadlessContext } from '../../../../lib'\nimport type { RedeemableItem as RedeemableItemType, RedeemModalCommon } from '../../type'\nimport { ProductInfo } from './ProductInfo'\nimport useShippingCountries from '../../context/hooks/useShippingCountries'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype AddressProps = {\n copy: RedeemModalCommon\n shippingAddress: string\n setAddress: (address: Record<string, any>) => void\n validateAddress: (address: Record<string, any>) => boolean\n validateErrors: { key: string; message: string }[]\n item: RedeemableItemType\n loading: boolean\n address: Record<string, any> | undefined\n disabled: boolean\n handlePayment: () => void\n shippingProduct: string\n}\n\nexport const Address = ({\n copy,\n shippingAddress,\n setAddress,\n validateAddress,\n validateErrors,\n shippingProduct,\n loading,\n address,\n disabled,\n handlePayment,\n item,\n}: AddressProps) => {\n const { storeDomain, brand } = useHeadlessContext()\n const { apiBaseUrl } = useCreditsContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const { countries = [], isLoading: countriesLoading } = useShippingCountries({ shopifyStoreDomain: storeDomain, apiBaseUrl })\n\n return (\n <div className=\"relative\">\n <div className={classNames('max-h-[500px] overflow-y-auto px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]')}>\n <div>\n {shippingAddress && <Text className=\"mb-5 text-[16px] font-bold\" html={shippingAddress}></Text>}\n {copy?.product?.addressForm && (\n <AddressForm\n onChange={setAddress}\n validate={validateAddress}\n errors={validateErrors}\n form={copy.product.addressForm}\n countries={countries}\n countriesLoading={countriesLoading}\n ></AddressForm>\n )}\n </div>\n </div>\n <div className=\"sticky bottom-0 flex flex-col items-center justify-center bg-white px-[48px] py-[24px] l:px-[16px]\">\n <div className={classNames('flex w-full items-center bg-[#F5F5F7] p-[16px]', !rounded && 'rounded-none')}>\n {shippingProduct && <Text className=\"mb-5 text-[16px] font-bold\" html={shippingProduct}></Text>}\n <ProductInfo item={item} copy={copy} />\n </div>\n <Button\n loading={loading || !address}\n variant=\"primary\"\n className=\"mx-auto mt-[16px] w-[444px] md:mt-[12px] md:w-full\"\n onClick={handlePayment}\n disabled={disabled}\n >\n {copy.product.paymentButton}\n </Button>\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA6CQ,IAAAI,EAAA,6BA7CRC,EAA6B,iCAC7BC,EAAuB,yBACvBC,EAAkC,kCAClCC,EAA4B,0BAC5BC,EAAmC,2BAEnCC,EAA4B,yBAC5BC,EAAiC,uDACjCC,EAA+B,iCAgBxB,MAAMV,EAAU,CAAC,CACtB,KAAAW,EACA,gBAAAC,EACA,WAAAC,EACA,gBAAAC,EACA,eAAAC,EACA,gBAAAC,EACA,QAAAC,EACA,QAAAC,EACA,SAAAC,EACA,cAAAC,EACA,KAAAC,CACF,IAAoB,CAClB,KAAM,CAAE,YAAAC,EAAa,MAAAC,CAAM,KAAI,sBAAmB,EAC5C,CAAE,WAAAC,CAAW,KAAI,qBAAkB,EACnCC,EAAU,iBAAe,SAASF,CAAK,EACvC,CAAE,UAAAG,EAAY,CAAC,EAAG,UAAWC,CAAiB,KAAI,EAAAC,SAAqB,CAAE,mBAAoBN,EAAa,WAAAE,CAAW,CAAC,EAE5H,SACE,QAAC,OAAI,UAAU,WACb,oBAAC,OAAI,aAAW,EAAAK,SAAW,iFAAiF,EAC1G,oBAAC,OACE,UAAAjB,MAAmB,OAAC,QAAK,UAAU,6BAA6B,KAAMA,EAAiB,EACvFD,GAAM,SAAS,gBACd,OAAC,eACC,SAAUE,EACV,SAAUC,EACV,OAAQC,EACR,KAAMJ,EAAK,QAAQ,YACnB,UAAWe,EACX,iBAAkBC,EACnB,GAEL,EACF,KACA,QAAC,OAAI,UAAU,qGACb,qBAAC,OAAI,aAAW,EAAAE,SAAW,iDAAkD,CAACJ,GAAW,cAAc,EACpG,UAAAT,MAAmB,OAAC,QAAK,UAAU,6BAA6B,KAAMA,EAAiB,KACxF,OAAC,eAAY,KAAMK,EAAM,KAAMV,EAAM,GACvC,KACA,OAAC,UACC,QAASM,GAAW,CAACC,EACrB,QAAQ,UACR,UAAU,qDACV,QAASE,EACT,SAAUD,EAET,SAAAR,EAAK,QAAQ,cAChB,GACF,GACF,CAEJ",
6
+ "names": ["Address_exports", "__export", "Address", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_classnames", "import_provider", "import_AddressForm", "import_lib", "import_ProductInfo", "import_useShippingCountries", "import_constants", "copy", "shippingAddress", "setAddress", "validateAddress", "validateErrors", "shippingProduct", "loading", "address", "disabled", "handlePayment", "item", "storeDomain", "brand", "apiBaseUrl", "rounded", "countries", "countriesLoading", "useShippingCountries", "classNames"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var Q=Object.create;var g=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var $=(r,e)=>{for(var s in e)g(r,s,{get:e[s],enumerable:!0})},S=(r,e,s,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of X(e))!Z.call(r,i)&&i!==s&&g(r,i,{get:()=>e[i],enumerable:!(u=W(e,i))||u.enumerable});return r};var x=(r,e,s)=>(s=r!=null?Q(Y(r)):{},S(e||!r||!r.__esModule?g(s,"default",{value:r,enumerable:!0}):s,r)),j=r=>S(g({},"__esModule",{value:!0}),r);var re={};$(re,{default:()=>ee});module.exports=j(re);var a=require("react/jsx-runtime"),b=x(require("classnames")),d=require("react"),U=require("../../context/provider"),y=x(require("../../context/hooks/useShippingCountries")),f=require("../../context/const"),L=require("../../context/hooks/useAddressValidate"),O=require("../../context/hooks/useRedeemProduct"),q=require("../../modal/ModalContainer"),w=require("../../../../lib"),F=require("./Error"),K=require("./Success"),_=require("./Address"),k=require("./Init");function D({item:r,copy:e,onError:s,...u}){const{fetchCreditInfo:i,profile:M,pageCommon:T}=(0,U.useCreditsContext)(),{storeDomain:B}=(0,w.useHeadlessContext)(),{shippingAddress:G,shippingProduct:P}=e.product,[n,m]=(0,d.useState)("init"),[l,R]=(0,d.useState)(),[H,p]=(0,d.useState)({code:0,message:"",imageUrl:""}),[C,c]=(0,d.useState)(!1),{countries:A=[],isLoading:oe}=(0,y.default)({shopifyStoreDomain:B}),{isMutating:h,trigger:N}=(0,O.useRedeemProduct)({onSuccess(o){if(!o){m("error"),p({code:0,imageUrl:e.errorImageUrl||"",message:e.commonError||""});return}if(o?.code===0)i(M?.user_id),m("success");else{let t,v;o.code===f.AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit?(t=e.redeemLimitError,c(!0)):o.code===f.AlpcErrorCode.CodeLpcRuleInventoryNotEnough?(t=e.inventoryNotEnough,c(!0),v=e.inventoryNotEnough):o.code===f.AlpcErrorCode.CodeLpcNotEnoughCredits?(t=e.creditsNotEnough,c(!0),i(M?.user_id)):o.code===f.AlpcErrorCode.CodeCrossSiteError&&(t=e.crossSiteError,c(!0)),m("error"),p({code:o.code,imageUrl:v||e.errorImageUrl||"",message:t||e.commonError||""}),s&&s(o.code)}},onError(o){m("error"),p({code:0,imageUrl:e.errorImageUrl||"",message:e.commonError||""})}}),E=(0,d.useMemo)(()=>e?.product.form?.flat().find(t=>t.type==="state")?.key,[e?.product.form]),{validate:I,errors:J}=(0,L.useAddressValidate)({address:l,validatorInfo:T?.validatorInfo,formData:e?.product.form?.flat()||[],errorLabel:{require:e.product.required,email:e.product.invalidEmail}}),V=(0,d.useCallback)(async()=>{const o=[];if(E&&((A.find(z=>z.code===l.country)?.provinces||[]).length||o.push(E)),I({force:!0,ignoreKeys:o}))return;let t={...l};t.name&&delete t.name,t.country==="UK"&&(t.country="GB"),N({address:btoa(JSON.stringify(t)),rule_id:Number(r.alpc?.id)})},[r,N,E,I,l,A]);return(0,d.useEffect)(()=>()=>{c(!1),p({code:0,message:"",imageUrl:""}),m("init"),R(void 0)},[]),(0,a.jsxs)(q.CreditsModalContainer,{...u,isOpen:!!r,className:(0,b.default)("w-[540px] md:h-auto min-md:max-h-[calc(100vh-40px)]",n!=="init"&&"w-[740px] md:w-full"),scrollClassName:"mb-0 min-l:px-0 md:mb-0 px-0",titleClassName:(0,b.default)("h-[56px]",n==="init"&&"bg-[#F5F5F7]"),title:n==="address"?"Order Confirmation":"",children:[n==="error"&&(0,a.jsx)(F.Error,{errorInfo:H}),n==="success"&&(0,a.jsx)(K.Success,{copy:e,shippingProduct:P,loading:h,address:l,disabled:C,onClose:u.onClose,item:r}),n==="address"&&(0,a.jsx)(_.Address,{copy:e,shippingAddress:G,setAddress:R,validateAddress:I,validateErrors:J,shippingProduct:P,loading:h,address:l,disabled:C,handlePayment:V,item:r}),n==="init"&&(0,a.jsx)(k.Init,{item:r,copy:e,loading:h,disabled:C,setStatus:m})]})}var ee=D;
1
+ "use strict";var W=Object.create;var g=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var j=(r,e)=>{for(var s in e)g(r,s,{get:e[s],enumerable:!0})},S=(r,e,s,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Y(e))!$.call(r,i)&&i!==s&&g(r,i,{get:()=>e[i],enumerable:!(u=X(e,i))||u.enumerable});return r};var U=(r,e,s)=>(s=r!=null?W(Z(r)):{},S(e||!r||!r.__esModule?g(s,"default",{value:r,enumerable:!0}):s,r)),D=r=>S(g({},"__esModule",{value:!0}),r);var oe={};j(oe,{default:()=>re});module.exports=D(oe);var a=require("react/jsx-runtime"),b=U(require("classnames")),d=require("react"),x=require("../../context/provider"),y=U(require("../../context/hooks/useShippingCountries")),f=require("../../context/const"),L=require("../../context/hooks/useAddressValidate"),O=require("../../context/hooks/useRedeemProduct"),q=require("../../modal/ModalContainer"),w=require("../../../../lib"),F=require("./Error"),K=require("./Success"),_=require("./Address"),k=require("./Init");function ee({item:r,copy:e,onError:s,...u}){const{fetchCreditInfo:i,profile:M,pageCommon:B,apiBaseUrl:T}=(0,x.useCreditsContext)(),{storeDomain:G}=(0,w.useHeadlessContext)(),{shippingAddress:H,shippingProduct:P}=e.product,[n,m]=(0,d.useState)("init"),[l,R]=(0,d.useState)(),[J,p]=(0,d.useState)({code:0,message:"",imageUrl:""}),[C,c]=(0,d.useState)(!1),{countries:A=[],isLoading:te}=(0,y.default)({shopifyStoreDomain:G,apiBaseUrl:T}),{isMutating:h,trigger:N}=(0,O.useRedeemProduct)({onSuccess(o){if(!o){m("error"),p({code:0,imageUrl:e.errorImageUrl||"",message:e.commonError||""});return}if(o?.code===0)i(M?.user_id),m("success");else{let t,v;o.code===f.AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit?(t=e.redeemLimitError,c(!0)):o.code===f.AlpcErrorCode.CodeLpcRuleInventoryNotEnough?(t=e.inventoryNotEnough,c(!0),v=e.inventoryNotEnough):o.code===f.AlpcErrorCode.CodeLpcNotEnoughCredits?(t=e.creditsNotEnough,c(!0),i(M?.user_id)):o.code===f.AlpcErrorCode.CodeCrossSiteError&&(t=e.crossSiteError,c(!0)),m("error"),p({code:o.code,imageUrl:v||e.errorImageUrl||"",message:t||e.commonError||""}),s&&s(o.code)}},onError(o){m("error"),p({code:0,imageUrl:e.errorImageUrl||"",message:e.commonError||""})}}),E=(0,d.useMemo)(()=>e?.product.form?.flat().find(t=>t.type==="state")?.key,[e?.product.form]),{validate:I,errors:V}=(0,L.useAddressValidate)({address:l,validatorInfo:B?.validatorInfo,formData:e?.product.form?.flat()||[],errorLabel:{require:e.product.required,email:e.product.invalidEmail}}),z=(0,d.useCallback)(async()=>{const o=[];if(E&&((A.find(Q=>Q.code===l.country)?.provinces||[]).length||o.push(E)),I({force:!0,ignoreKeys:o}))return;let t={...l};t.name&&delete t.name,t.country==="UK"&&(t.country="GB"),N({address:btoa(JSON.stringify(t)),rule_id:Number(r.alpc?.id)})},[r,N,E,I,l,A]);return(0,d.useEffect)(()=>()=>{c(!1),p({code:0,message:"",imageUrl:""}),m("init"),R(void 0)},[]),(0,a.jsxs)(q.CreditsModalContainer,{...u,isOpen:!!r,className:(0,b.default)("w-[540px] md:h-auto min-md:max-h-[calc(100vh-40px)]",n!=="init"&&"w-[740px] md:w-full"),scrollClassName:"mb-0 min-l:px-0 md:mb-0 px-0",titleClassName:(0,b.default)("h-[56px]",n==="init"&&"bg-[#F5F5F7]"),title:n==="address"?"Order Confirmation":"",children:[n==="error"&&(0,a.jsx)(F.Error,{errorInfo:J}),n==="success"&&(0,a.jsx)(K.Success,{copy:e,shippingProduct:P,loading:h,address:l,disabled:C,onClose:u.onClose,item:r}),n==="address"&&(0,a.jsx)(_.Address,{copy:e,shippingAddress:H,setAddress:R,validateAddress:I,validateErrors:V,shippingProduct:P,loading:h,address:l,disabled:C,handlePayment:z,item:r}),n==="init"&&(0,a.jsx)(k.Init,{item:r,copy:e,loading:h,disabled:C,setStatus:m})]})}var re=ee;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/credits/creditsRedeemList/RedeemProductModal/index.tsx"],
4
- "sourcesContent": ["import classNames from 'classnames'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { useCreditsContext } from '../../context/provider'\nimport useShippingCountries from '../../context/hooks/useShippingCountries'\nimport { AlpcErrorCode } from '../../context/const'\nimport { useAddressValidate } from '../../context/hooks/useAddressValidate'\nimport { useRedeemProduct } from '../../context/hooks/useRedeemProduct'\nimport type { ModalContainerProps } from '../../modal/ModalContainer'\nimport { CreditsModalContainer } from '../../modal/ModalContainer'\nimport type { RedeemableItem as RedeemableItemType, RedeemModalCommon } from '../../type'\nimport { useHeadlessContext } from '../../../../lib'\nimport { Error } from './Error'\nimport { Success } from './Success'\nimport { Address } from './Address'\nimport { Init } from './Init'\n\ntype RedeemProductModalProps = Omit<ModalContainerProps, 'isOpen'> & {\n item: RedeemableItemType\n copy: RedeemModalCommon\n onError: (code: AlpcErrorCode) => void\n}\n\nfunction RedeemProductModal({ item, copy, onError, ...props }: RedeemProductModalProps) {\n const { fetchCreditInfo, profile, pageCommon } = useCreditsContext()\n const { storeDomain } = useHeadlessContext()\n\n const { shippingAddress, shippingProduct } = copy.product\n\n const [status, setStatus] = useState<'init' | 'address' | 'success' | 'error'>('init')\n const [address, setAddress] = useState<any>()\n const [errorInfo, setErrorInfo] = useState({\n code: 0,\n message: '',\n imageUrl: '',\n })\n const [disabled, setDisabled] = useState(false)\n\n const { countries = [], isLoading: countriesLoading } = useShippingCountries({ shopifyStoreDomain: storeDomain })\n\n const { isMutating: loading, trigger } = useRedeemProduct({\n onSuccess(responseData) {\n if (!responseData) {\n setStatus('error')\n setErrorInfo({\n code: 0,\n imageUrl: copy.errorImageUrl || '',\n message: copy.commonError || '',\n })\n return\n }\n\n if (responseData?.code === 0) {\n fetchCreditInfo(profile?.user_id)\n setStatus('success')\n } else {\n let errorMsg\n let errorImage\n if (responseData.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n errorMsg = copy.redeemLimitError\n setDisabled(true)\n } else if (responseData.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n errorMsg = copy.inventoryNotEnough\n setDisabled(true)\n errorImage = copy.inventoryNotEnough\n } else if (responseData.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n errorMsg = copy.creditsNotEnough\n setDisabled(true)\n fetchCreditInfo(profile?.user_id)\n } else if (responseData.code === AlpcErrorCode.CodeCrossSiteError) {\n errorMsg = copy.crossSiteError\n setDisabled(true)\n }\n\n setStatus('error')\n setErrorInfo({\n code: responseData.code,\n imageUrl: errorImage || copy.errorImageUrl || '',\n message: errorMsg || copy.commonError || '',\n })\n onError && onError(responseData.code)\n }\n },\n onError(error) {\n setStatus('error')\n setErrorInfo({\n code: 0,\n imageUrl: copy.errorImageUrl || '',\n message: copy.commonError || '',\n })\n },\n })\n\n const stateInputKey = useMemo(() => {\n const stateInput = copy?.product.form?.flat().find(item => item.type === 'state')\n return stateInput?.key\n }, [copy?.product.form])\n\n const { validate: validateAddress, errors: validateErrors } = useAddressValidate({\n address: address,\n validatorInfo: pageCommon?.validatorInfo,\n formData: copy?.product.form?.flat() || [],\n errorLabel: {\n require: copy.product.required,\n email: copy.product.invalidEmail,\n },\n })\n\n const handlePayment = useCallback(async () => {\n const ignoreKeys: string[] = []\n\n if (stateInputKey) {\n const provinces = countries.find(item => item.code === address.country)?.provinces || []\n\n if (!provinces.length) {\n ignoreKeys.push(stateInputKey as never)\n }\n }\n\n if (\n validateAddress({\n force: true,\n ignoreKeys,\n })\n ) {\n // \u5730\u5740\u6821\u9A8C\u9519\u8BEF\n return\n }\n let requestAddress = { ...address }\n if (requestAddress.name) {\n delete requestAddress.name\n }\n if (requestAddress.country === 'UK') {\n requestAddress.country = 'GB'\n }\n trigger({\n address: btoa(JSON.stringify(requestAddress)),\n rule_id: Number(item.alpc?.id),\n })\n }, [item, trigger, stateInputKey, validateAddress, address, countries])\n\n useEffect(() => {\n return () => {\n setDisabled(false)\n setErrorInfo({ code: 0, message: '', imageUrl: '' })\n setStatus('init')\n setAddress(undefined)\n }\n }, [])\n\n return (\n <CreditsModalContainer\n {...props}\n isOpen={!!item}\n className={classNames(\n 'w-[540px] md:h-auto min-md:max-h-[calc(100vh-40px)]',\n status !== 'init' && 'w-[740px] md:w-full'\n )}\n scrollClassName=\"mb-0 min-l:px-0 md:mb-0 px-0\"\n titleClassName={classNames('h-[56px]', status === 'init' && 'bg-[#F5F5F7]')}\n title={status === 'address' ? 'Order Confirmation' : ''}\n >\n {status === 'error' && <Error errorInfo={errorInfo} />}\n {status === 'success' && (\n <Success\n copy={copy}\n shippingProduct={shippingProduct}\n loading={loading}\n address={address}\n disabled={disabled}\n onClose={props.onClose}\n item={item}\n />\n )}\n {status === 'address' && (\n <Address\n copy={copy}\n shippingAddress={shippingAddress}\n setAddress={setAddress}\n validateAddress={validateAddress}\n validateErrors={validateErrors}\n shippingProduct={shippingProduct}\n loading={loading}\n address={address}\n disabled={disabled}\n handlePayment={handlePayment}\n item={item}\n />\n )}\n {status === 'init' && (\n <Init item={item} copy={copy} loading={loading} disabled={disabled} setStatus={setStatus} />\n )}\n </CreditsModalContainer>\n )\n}\n\nexport default RedeemProductModal\n"],
5
- "mappings": "0jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,EAAAH,IAsJI,IAAAI,EAAA,6BAtJJC,EAAuB,yBACvBC,EAA0D,iBAC1DC,EAAkC,kCAClCC,EAAiC,uDACjCC,EAA8B,+BAC9BC,EAAmC,kDACnCC,EAAiC,gDAEjCC,EAAsC,sCAEtCC,EAAmC,2BACnCC,EAAsB,mBACtBC,EAAwB,qBACxBC,EAAwB,qBACxBC,EAAqB,kBAQrB,SAASC,EAAmB,CAAE,KAAAC,EAAM,KAAAC,EAAM,QAAAC,EAAS,GAAGC,CAAM,EAA4B,CACtF,KAAM,CAAE,gBAAAC,EAAiB,QAAAC,EAAS,WAAAC,CAAW,KAAI,qBAAkB,EAC7D,CAAE,YAAAC,CAAY,KAAI,sBAAmB,EAErC,CAAE,gBAAAC,EAAiB,gBAAAC,CAAgB,EAAIR,EAAK,QAE5C,CAACS,EAAQC,CAAS,KAAI,YAAmD,MAAM,EAC/E,CAACC,EAASC,CAAU,KAAI,YAAc,EACtC,CAACC,EAAWC,CAAY,KAAI,YAAS,CACzC,KAAM,EACN,QAAS,GACT,SAAU,EACZ,CAAC,EACK,CAACC,EAAUC,CAAW,KAAI,YAAS,EAAK,EAExC,CAAE,UAAAC,EAAY,CAAC,EAAG,UAAWC,EAAiB,KAAI,EAAAC,SAAqB,CAAE,mBAAoBb,CAAY,CAAC,EAE1G,CAAE,WAAYc,EAAS,QAAAC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AChB,gBAAiBpB,EACjB,QAASY,EACT,QAAST,EACT,SAAUI,EACV,cAAec,EACf,KAAM9B,EACR,EAEDU,IAAW,WACV,OAAC,QAAK,KAAMV,EAAM,KAAMC,EAAM,QAASoB,EAAS,SAAUL,EAAU,UAAWL,EAAW,GAE9F,CAEJ,CAEA,IAAO5B,GAAQgB",
6
- "names": ["RedeemProductModal_exports", "__export", "RedeemProductModal_default", "__toCommonJS", "import_jsx_runtime", "import_classnames", "import_react", "import_provider", "import_useShippingCountries", "import_const", "import_useAddressValidate", "import_useRedeemProduct", "import_ModalContainer", "import_lib", "import_Error", "import_Success", "import_Address", "import_Init", "RedeemProductModal", "item", "copy", "onError", "props", "fetchCreditInfo", "profile", "pageCommon", "storeDomain", "shippingAddress", "shippingProduct", "status", "setStatus", "address", "setAddress", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "countries", "countriesLoading", "useShippingCountries", "loading", "trigger", "responseData", "errorMsg", "errorImage", "error", "stateInputKey", "validateAddress", "validateErrors", "handlePayment", "ignoreKeys", "requestAddress", "classNames"]
4
+ "sourcesContent": ["import classNames from 'classnames'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { useCreditsContext } from '../../context/provider'\nimport useShippingCountries from '../../context/hooks/useShippingCountries'\nimport { AlpcErrorCode } from '../../context/const'\nimport { useAddressValidate } from '../../context/hooks/useAddressValidate'\nimport { useRedeemProduct } from '../../context/hooks/useRedeemProduct'\nimport type { ModalContainerProps } from '../../modal/ModalContainer'\nimport { CreditsModalContainer } from '../../modal/ModalContainer'\nimport type { RedeemableItem as RedeemableItemType, RedeemModalCommon } from '../../type'\nimport { useHeadlessContext } from '../../../../lib'\nimport { Error } from './Error'\nimport { Success } from './Success'\nimport { Address } from './Address'\nimport { Init } from './Init'\n\ntype RedeemProductModalProps = Omit<ModalContainerProps, 'isOpen'> & {\n item: RedeemableItemType\n copy: RedeemModalCommon\n onError: (code: AlpcErrorCode) => void\n}\n\nfunction RedeemProductModal({ item, copy, onError, ...props }: RedeemProductModalProps) {\n const { fetchCreditInfo, profile, pageCommon, apiBaseUrl } = useCreditsContext()\n const { storeDomain } = useHeadlessContext()\n\n const { shippingAddress, shippingProduct } = copy.product\n\n const [status, setStatus] = useState<'init' | 'address' | 'success' | 'error'>('init')\n const [address, setAddress] = useState<any>()\n const [errorInfo, setErrorInfo] = useState({\n code: 0,\n message: '',\n imageUrl: '',\n })\n const [disabled, setDisabled] = useState(false)\n\n const { countries = [], isLoading: countriesLoading } = useShippingCountries({ shopifyStoreDomain: storeDomain, apiBaseUrl })\n\n const { isMutating: loading, trigger } = useRedeemProduct({\n onSuccess(responseData) {\n if (!responseData) {\n setStatus('error')\n setErrorInfo({\n code: 0,\n imageUrl: copy.errorImageUrl || '',\n message: copy.commonError || '',\n })\n return\n }\n\n if (responseData?.code === 0) {\n fetchCreditInfo(profile?.user_id)\n setStatus('success')\n } else {\n let errorMsg\n let errorImage\n if (responseData.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n errorMsg = copy.redeemLimitError\n setDisabled(true)\n } else if (responseData.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n errorMsg = copy.inventoryNotEnough\n setDisabled(true)\n errorImage = copy.inventoryNotEnough\n } else if (responseData.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n errorMsg = copy.creditsNotEnough\n setDisabled(true)\n fetchCreditInfo(profile?.user_id)\n } else if (responseData.code === AlpcErrorCode.CodeCrossSiteError) {\n errorMsg = copy.crossSiteError\n setDisabled(true)\n }\n\n setStatus('error')\n setErrorInfo({\n code: responseData.code,\n imageUrl: errorImage || copy.errorImageUrl || '',\n message: errorMsg || copy.commonError || '',\n })\n onError && onError(responseData.code)\n }\n },\n onError(error) {\n setStatus('error')\n setErrorInfo({\n code: 0,\n imageUrl: copy.errorImageUrl || '',\n message: copy.commonError || '',\n })\n },\n })\n\n const stateInputKey = useMemo(() => {\n const stateInput = copy?.product.form?.flat().find(item => item.type === 'state')\n return stateInput?.key\n }, [copy?.product.form])\n\n const { validate: validateAddress, errors: validateErrors } = useAddressValidate({\n address: address,\n validatorInfo: pageCommon?.validatorInfo,\n formData: copy?.product.form?.flat() || [],\n errorLabel: {\n require: copy.product.required,\n email: copy.product.invalidEmail,\n },\n })\n\n const handlePayment = useCallback(async () => {\n const ignoreKeys: string[] = []\n\n if (stateInputKey) {\n const provinces = countries.find(item => item.code === address.country)?.provinces || []\n\n if (!provinces.length) {\n ignoreKeys.push(stateInputKey as never)\n }\n }\n\n if (\n validateAddress({\n force: true,\n ignoreKeys,\n })\n ) {\n // \u5730\u5740\u6821\u9A8C\u9519\u8BEF\n return\n }\n let requestAddress = { ...address }\n if (requestAddress.name) {\n delete requestAddress.name\n }\n if (requestAddress.country === 'UK') {\n requestAddress.country = 'GB'\n }\n trigger({\n address: btoa(JSON.stringify(requestAddress)),\n rule_id: Number(item.alpc?.id),\n })\n }, [item, trigger, stateInputKey, validateAddress, address, countries])\n\n useEffect(() => {\n return () => {\n setDisabled(false)\n setErrorInfo({ code: 0, message: '', imageUrl: '' })\n setStatus('init')\n setAddress(undefined)\n }\n }, [])\n\n return (\n <CreditsModalContainer\n {...props}\n isOpen={!!item}\n className={classNames(\n 'w-[540px] md:h-auto min-md:max-h-[calc(100vh-40px)]',\n status !== 'init' && 'w-[740px] md:w-full'\n )}\n scrollClassName=\"mb-0 min-l:px-0 md:mb-0 px-0\"\n titleClassName={classNames('h-[56px]', status === 'init' && 'bg-[#F5F5F7]')}\n title={status === 'address' ? 'Order Confirmation' : ''}\n >\n {status === 'error' && <Error errorInfo={errorInfo} />}\n {status === 'success' && (\n <Success\n copy={copy}\n shippingProduct={shippingProduct}\n loading={loading}\n address={address}\n disabled={disabled}\n onClose={props.onClose}\n item={item}\n />\n )}\n {status === 'address' && (\n <Address\n copy={copy}\n shippingAddress={shippingAddress}\n setAddress={setAddress}\n validateAddress={validateAddress}\n validateErrors={validateErrors}\n shippingProduct={shippingProduct}\n loading={loading}\n address={address}\n disabled={disabled}\n handlePayment={handlePayment}\n item={item}\n />\n )}\n {status === 'init' && (\n <Init item={item} copy={copy} loading={loading} disabled={disabled} setStatus={setStatus} />\n )}\n </CreditsModalContainer>\n )\n}\n\nexport default RedeemProductModal\n"],
5
+ "mappings": "0jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,EAAAH,IAsJI,IAAAI,EAAA,6BAtJJC,EAAuB,yBACvBC,EAA0D,iBAC1DC,EAAkC,kCAClCC,EAAiC,uDACjCC,EAA8B,+BAC9BC,EAAmC,kDACnCC,EAAiC,gDAEjCC,EAAsC,sCAEtCC,EAAmC,2BACnCC,EAAsB,mBACtBC,EAAwB,qBACxBC,EAAwB,qBACxBC,EAAqB,kBAQrB,SAASC,GAAmB,CAAE,KAAAC,EAAM,KAAAC,EAAM,QAAAC,EAAS,GAAGC,CAAM,EAA4B,CACtF,KAAM,CAAE,gBAAAC,EAAiB,QAAAC,EAAS,WAAAC,EAAY,WAAAC,CAAW,KAAI,qBAAkB,EACzE,CAAE,YAAAC,CAAY,KAAI,sBAAmB,EAErC,CAAE,gBAAAC,EAAiB,gBAAAC,CAAgB,EAAIT,EAAK,QAE5C,CAACU,EAAQC,CAAS,KAAI,YAAmD,MAAM,EAC/E,CAACC,EAASC,CAAU,KAAI,YAAc,EACtC,CAACC,EAAWC,CAAY,KAAI,YAAS,CACzC,KAAM,EACN,QAAS,GACT,SAAU,EACZ,CAAC,EACK,CAACC,EAAUC,CAAW,KAAI,YAAS,EAAK,EAExC,CAAE,UAAAC,EAAY,CAAC,EAAG,UAAWC,EAAiB,KAAI,EAAAC,SAAqB,CAAE,mBAAoBb,EAAa,WAAAD,CAAW,CAAC,EAEtH,CAAE,WAAYe,EAAS,QAAAC,CAAQ,KAAI,oBAAiB,CACxD,UAAUC,EAAc,CACtB,GAAI,CAACA,EAAc,CACjBZ,EAAU,OAAO,EACjBI,EAAa,CACX,KAAM,EACN,SAAUf,EAAK,eAAiB,GAChC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EAAS,SAAUL,EAAU,UAAWL,EAAW,GAE9F,CAEJ,CAEA,IAAO7B,GAAQgB",
6
+ "names": ["RedeemProductModal_exports", "__export", "RedeemProductModal_default", "__toCommonJS", "import_jsx_runtime", "import_classnames", "import_react", "import_provider", "import_useShippingCountries", "import_const", "import_useAddressValidate", "import_useRedeemProduct", "import_ModalContainer", "import_lib", "import_Error", "import_Success", "import_Address", "import_Init", "RedeemProductModal", "item", "copy", "onError", "props", "fetchCreditInfo", "profile", "pageCommon", "apiBaseUrl", "storeDomain", "shippingAddress", "shippingProduct", "status", "setStatus", "address", "setAddress", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "countries", "countriesLoading", "useShippingCountries", "loading", "trigger", "responseData", "errorMsg", "errorImage", "error", "stateInputKey", "validateAddress", "validateErrors", "handlePayment", "ignoreKeys", "requestAddress", "classNames"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var v=(e,o)=>{for(var r in o)n(e,r,{get:o[r],enumerable:!0})},M=(e,o,r,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of b(o))!S.call(e,t)&&t!==r&&n(e,t,{get:()=>o[t],enumerable:!(i=m(o,t))||i.enumerable});return e};var x=e=>M(n({},"__esModule",{value:!0}),e);var h={};v(h,{MemberPopupContext:()=>u,MemberPopupProvider:()=>I,useMemberPopupContext:()=>g});module.exports=x(h);var p=require("react/jsx-runtime"),s=require("react"),c=require("../../../lib"),a=require("../../registration");const u=(0,s.createContext)({profile:null,isLoadingProfile:!1,creditInfo:void 0,fetchCreditInfo:()=>{},openSignUpPopup:()=>{},openSignInPopup:()=>{},taskIdToTypeMapping:{},alpcConfig:{brand:"",locale:"",appName:""},isSubscribeSuccess:!1,setIsSubscribeSuccess:()=>{},isActivateSuccess:!1,setIsActivateSuccess:()=>{},isProfileCompleteSuccess:!1,setIsProfileCompleteSuccess:()=>{}});function I({children:e,headlessConfig:o,earnCreditsCopy:r,...i}){const[t,l]=(0,s.useState)(!1),[P,d]=(0,s.useState)(!1),[f,C]=(0,s.useState)(!1);return(0,p.jsx)(c.HeadlessProvider,{headlessConfig:o,children:(0,p.jsx)(a.RegistrationProvider,{email:i.profile?.email,copy:{authCodeActivate:r?.authCodeActivate},children:(0,p.jsx)(u.Provider,{value:{...i,isSubscribeSuccess:t,setIsSubscribeSuccess:l,isActivateSuccess:P,setIsActivateSuccess:d,isProfileCompleteSuccess:f,setIsProfileCompleteSuccess:C},children:e})})})}function g(){const e=(0,s.useContext)(u);if(!e)throw new Error("useMemberPopupContext must be used within a MemberPopupProvider");return e}
1
+ "use strict";var n=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var v=(e,o)=>{for(var t in o)n(e,t,{get:o[t],enumerable:!0})},M=(e,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of b(o))!S.call(e,r)&&r!==t&&n(e,r,{get:()=>o[r],enumerable:!(i=m(o,r))||i.enumerable});return e};var g=e=>M(n({},"__esModule",{value:!0}),e);var x={};v(x,{MemberPopupContext:()=>a,MemberPopupProvider:()=>I,useMemberPopupContext:()=>h});module.exports=g(x);var p=require("react/jsx-runtime"),s=require("react"),c=require("../../../lib"),u=require("../../registration");const a=(0,s.createContext)({profile:null,isLoadingProfile:!1,creditInfo:void 0,fetchCreditInfo:()=>{},openSignUpPopup:()=>{},openSignInPopup:()=>{},taskIdToTypeMapping:{},alpcConfig:{brand:"",locale:"",appName:""},isSubscribeSuccess:!1,setIsSubscribeSuccess:()=>{},isActivateSuccess:!1,setIsActivateSuccess:()=>{},isProfileCompleteSuccess:!1,setIsProfileCompleteSuccess:()=>{}});function I({children:e,headlessConfig:o,earnCreditsCopy:t,...i}){const[r,l]=(0,s.useState)(!1),[P,d]=(0,s.useState)(!1),[f,C]=(0,s.useState)(!1);return(0,p.jsx)(c.HeadlessProvider,{headlessConfig:o,children:(0,p.jsx)(u.RegistrationProvider,{email:i.profile?.email,copy:{authCodeActivate:t?.authCodeActivate},apiBaseUrl:i.alpcConfig?.apiBaseUrl,children:(0,p.jsx)(a.Provider,{value:{...i,isSubscribeSuccess:r,setIsSubscribeSuccess:l,isActivateSuccess:P,setIsActivateSuccess:d,isProfileCompleteSuccess:f,setIsProfileCompleteSuccess:C},children:e})})})}function h(){const e=(0,s.useContext)(a);if(!e)throw new Error("useMemberPopupContext must be used within a MemberPopupProvider");return e}
2
2
  //# sourceMappingURL=provider.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/memberPopup/context/provider.tsx"],
4
- "sourcesContent": ["import { createContext, PropsWithChildren, useContext, useState } from 'react'\nimport { HeadlessProvider, type HeadlessConfig } from '../../../lib'\nimport { RegistrationProvider } from '../../registration'\nimport type { EarnCreditsCopy, MemberPopupContextValue, MemberPopupInternalContextValue } from '../type'\n\nexport const MemberPopupContext = createContext<MemberPopupInternalContextValue>({\n profile: null,\n isLoadingProfile: false,\n creditInfo: undefined,\n fetchCreditInfo: () => {},\n openSignUpPopup: () => {},\n openSignInPopup: () => {},\n taskIdToTypeMapping: {},\n alpcConfig: {\n brand: '',\n locale: '',\n appName: '',\n },\n isSubscribeSuccess: false,\n setIsSubscribeSuccess: () => {},\n isActivateSuccess: false,\n setIsActivateSuccess: () => {},\n isProfileCompleteSuccess: false,\n setIsProfileCompleteSuccess: () => {},\n})\n\ntype MemberPopupProviderProps = MemberPopupContextValue & {\n headlessConfig: HeadlessConfig\n earnCreditsCopy?: EarnCreditsCopy\n}\n\nexport function MemberPopupProvider({\n children,\n headlessConfig,\n earnCreditsCopy,\n ...contextValue\n}: PropsWithChildren<MemberPopupProviderProps>) {\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isActivateSuccess, setIsActivateSuccess] = useState(false)\n const [isProfileCompleteSuccess, setIsProfileCompleteSuccess] = useState(false)\n\n return (\n <HeadlessProvider headlessConfig={headlessConfig}>\n <RegistrationProvider\n email={contextValue.profile?.email}\n copy={{ authCodeActivate: earnCreditsCopy?.authCodeActivate }}\n >\n <MemberPopupContext.Provider\n value={{\n ...contextValue,\n isSubscribeSuccess,\n setIsSubscribeSuccess,\n isActivateSuccess,\n setIsActivateSuccess,\n isProfileCompleteSuccess,\n setIsProfileCompleteSuccess,\n }}\n >\n {children}\n </MemberPopupContext.Provider>\n </RegistrationProvider>\n </HeadlessProvider>\n )\n}\n\nexport function useMemberPopupContext() {\n const context = useContext(MemberPopupContext)\n if (!context) {\n throw new Error('useMemberPopupContext must be used within a MemberPopupProvider')\n }\n return context\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,wBAAAC,EAAA,0BAAAC,IAAA,eAAAC,EAAAL,GA+CQ,IAAAM,EAAA,6BA/CRC,EAAuE,iBACvEC,EAAsD,wBACtDC,EAAqC,8BAG9B,MAAMP,KAAqB,iBAA+C,CAC/E,QAAS,KACT,iBAAkB,GAClB,WAAY,OACZ,gBAAiB,IAAM,CAAC,EACxB,gBAAiB,IAAM,CAAC,EACxB,gBAAiB,IAAM,CAAC,EACxB,oBAAqB,CAAC,EACtB,WAAY,CACV,MAAO,GACP,OAAQ,GACR,QAAS,EACX,EACA,mBAAoB,GACpB,sBAAuB,IAAM,CAAC,EAC9B,kBAAmB,GACnB,qBAAsB,IAAM,CAAC,EAC7B,yBAA0B,GAC1B,4BAA6B,IAAM,CAAC,CACtC,CAAC,EAOM,SAASC,EAAoB,CAClC,SAAAO,EACA,eAAAC,EACA,gBAAAC,EACA,GAAGC,CACL,EAAgD,CAC9C,KAAM,CAACC,EAAoBC,CAAqB,KAAI,YAAS,EAAK,EAC5D,CAACC,EAAmBC,CAAoB,KAAI,YAAS,EAAK,EAC1D,CAACC,EAA0BC,CAA2B,KAAI,YAAS,EAAK,EAE9E,SACE,OAAC,oBAAiB,eAAgBR,EAChC,mBAAC,wBACC,MAAOE,EAAa,SAAS,MAC7B,KAAM,CAAE,iBAAkBD,GAAiB,gBAAiB,EAE5D,mBAACV,EAAmB,SAAnB,CACC,MAAO,CACL,GAAGW,EACH,mBAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,qBAAAC,EACA,yBAAAC,EACA,4BAAAC,CACF,EAEC,SAAAT,EACH,EACF,EACF,CAEJ,CAEO,SAASN,GAAwB,CACtC,MAAMgB,KAAU,cAAWlB,CAAkB,EAC7C,GAAI,CAACkB,EACH,MAAM,IAAI,MAAM,iEAAiE,EAEnF,OAAOA,CACT",
4
+ "sourcesContent": ["import { createContext, PropsWithChildren, useContext, useState } from 'react'\nimport { HeadlessProvider, type HeadlessConfig } from '../../../lib'\nimport { RegistrationProvider } from '../../registration'\nimport type { EarnCreditsCopy, MemberPopupContextValue, MemberPopupInternalContextValue } from '../type'\n\nexport const MemberPopupContext = createContext<MemberPopupInternalContextValue>({\n profile: null,\n isLoadingProfile: false,\n creditInfo: undefined,\n fetchCreditInfo: () => {},\n openSignUpPopup: () => {},\n openSignInPopup: () => {},\n taskIdToTypeMapping: {},\n alpcConfig: {\n brand: '',\n locale: '',\n appName: '',\n },\n isSubscribeSuccess: false,\n setIsSubscribeSuccess: () => {},\n isActivateSuccess: false,\n setIsActivateSuccess: () => {},\n isProfileCompleteSuccess: false,\n setIsProfileCompleteSuccess: () => {},\n})\n\ntype MemberPopupProviderProps = MemberPopupContextValue & {\n headlessConfig: HeadlessConfig\n earnCreditsCopy?: EarnCreditsCopy\n}\n\nexport function MemberPopupProvider({\n children,\n headlessConfig,\n earnCreditsCopy,\n ...contextValue\n}: PropsWithChildren<MemberPopupProviderProps>) {\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isActivateSuccess, setIsActivateSuccess] = useState(false)\n const [isProfileCompleteSuccess, setIsProfileCompleteSuccess] = useState(false)\n\n return (\n <HeadlessProvider headlessConfig={headlessConfig}>\n <RegistrationProvider\n email={contextValue.profile?.email}\n copy={{ authCodeActivate: earnCreditsCopy?.authCodeActivate }}\n apiBaseUrl={contextValue.alpcConfig?.apiBaseUrl}\n >\n <MemberPopupContext.Provider\n value={{\n ...contextValue,\n isSubscribeSuccess,\n setIsSubscribeSuccess,\n isActivateSuccess,\n setIsActivateSuccess,\n isProfileCompleteSuccess,\n setIsProfileCompleteSuccess,\n }}\n >\n {children}\n </MemberPopupContext.Provider>\n </RegistrationProvider>\n </HeadlessProvider>\n )\n}\n\nexport function useMemberPopupContext() {\n const context = useContext(MemberPopupContext)\n if (!context) {\n throw new Error('useMemberPopupContext must be used within a MemberPopupProvider')\n }\n return context\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,wBAAAC,EAAA,0BAAAC,IAAA,eAAAC,EAAAL,GAgDQ,IAAAM,EAAA,6BAhDRC,EAAuE,iBACvEC,EAAsD,wBACtDC,EAAqC,8BAG9B,MAAMP,KAAqB,iBAA+C,CAC/E,QAAS,KACT,iBAAkB,GAClB,WAAY,OACZ,gBAAiB,IAAM,CAAC,EACxB,gBAAiB,IAAM,CAAC,EACxB,gBAAiB,IAAM,CAAC,EACxB,oBAAqB,CAAC,EACtB,WAAY,CACV,MAAO,GACP,OAAQ,GACR,QAAS,EACX,EACA,mBAAoB,GACpB,sBAAuB,IAAM,CAAC,EAC9B,kBAAmB,GACnB,qBAAsB,IAAM,CAAC,EAC7B,yBAA0B,GAC1B,4BAA6B,IAAM,CAAC,CACtC,CAAC,EAOM,SAASC,EAAoB,CAClC,SAAAO,EACA,eAAAC,EACA,gBAAAC,EACA,GAAGC,CACL,EAAgD,CAC9C,KAAM,CAACC,EAAoBC,CAAqB,KAAI,YAAS,EAAK,EAC5D,CAACC,EAAmBC,CAAoB,KAAI,YAAS,EAAK,EAC1D,CAACC,EAA0BC,CAA2B,KAAI,YAAS,EAAK,EAE9E,SACE,OAAC,oBAAiB,eAAgBR,EAChC,mBAAC,wBACC,MAAOE,EAAa,SAAS,MAC7B,KAAM,CAAE,iBAAkBD,GAAiB,gBAAiB,EAC5D,WAAYC,EAAa,YAAY,WAErC,mBAACX,EAAmB,SAAnB,CACC,MAAO,CACL,GAAGW,EACH,mBAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,qBAAAC,EACA,yBAAAC,EACA,4BAAAC,CACF,EAEC,SAAAT,EACH,EACF,EACF,CAEJ,CAEO,SAASN,GAAwB,CACtC,MAAMgB,KAAU,cAAWlB,CAAkB,EAC7C,GAAI,CAACkB,EACH,MAAM,IAAI,MAAM,iEAAiE,EAEnF,OAAOA,CACT",
6
6
  "names": ["provider_exports", "__export", "MemberPopupContext", "MemberPopupProvider", "useMemberPopupContext", "__toCommonJS", "import_jsx_runtime", "import_react", "import_lib", "import_registration", "children", "headlessConfig", "earnCreditsCopy", "contextValue", "isSubscribeSuccess", "setIsSubscribeSuccess", "isActivateSuccess", "setIsActivateSuccess", "isProfileCompleteSuccess", "setIsProfileCompleteSuccess", "context"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var E=Object.create;var f=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var j=(e,r)=>{for(var s in r)f(e,s,{get:r[s],enumerable:!0})},N=(e,r,s,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of H(r))!O.call(e,n)&&n!==s&&f(e,n,{get:()=>r[n],enumerable:!(d=F(r,n))||d.enumerable});return e};var q=(e,r,s)=>(s=e!=null?E(I(e)):{},N(r||!e||!e.__esModule?f(s,"default",{value:e,enumerable:!0}):s,e)),z=e=>N(f({},"__esModule",{value:!0}),e);var W={};j(W,{default:()=>T});module.exports=z(W);var t=require("react/jsx-runtime"),o=require("react"),a=require("@anker-in/headless-ui"),c=require("../../../lib"),m=q(require("js-cookie")),M=require("query-string"),S=require("../../credits/context/utils"),k=require("../context/provider"),L=require("../../../constants");function J(){if(typeof window>"u")return{register_source:""};const{search:e,href:r}=window.location,s=(0,M.parse)(e);return{fbuy_ref_code:m.default.get("fbuy_ref_code"),ref:m.default.get("ref_ads"),inviter_code:s.ic??s.inviter_code??m.default.get("inviter_code"),register_source:s.redirect??m.default.get("reg_source")??r}}async function V(e){if(typeof window>"u"||!window?.grecaptcha?.execute||!e)return"";try{return await window.grecaptcha.execute(e,{action:"activity"})}catch{return""}}function T({copy:e,email:r}){const{alpcConfig:s,setIsSubscribeSuccess:d,pageHandle:n}=(0,k.useMemberPopupContext)(),{locale:x}=s,{brand:P,storeDomain:g,recaptchaSitekey:y}=(0,c.useHeadlessContext)(),h=L.ROUNDED_BRANDS.includes(P),[p,A]=(0,o.useState)(e.policyDefaultChecked??!1),[u,_]=(0,o.useState)(r??""),[v,i]=(0,o.useState)(""),[U,w]=(0,o.useState)(""),[B,C]=(0,o.useState)(!1);(0,o.useEffect)(()=>{r&&_(r)},[r]);const D=(0,o.useCallback)(async()=>{if(i(""),!u)return i("Please fill in your email");if(!(0,S.emailValidate)(u))return i("Invalid email address");if(!p)return i("Please agree to the policy");C(!0);const{register_source:l}=J(),R=await V(y||"");try{const b=await(await fetch("/api/multipass/rainbowbridge/activities",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","current-language":x,"X-Recaptcha-Token":R},body:JSON.stringify({email:u,register_source:l,shopify_domain:g,single_brand_subscribe:e.single_brand_subscribe??!0,genre:e.genre??e.dealsType??"",sub_brand_type:e.sub_brand_type??""})})).json();b?.data?.is_new_subscribe?b?.data?.errors?i(b?.data?.errors??"Error occurred"):(w(e.successTips??"Subscribed successfully!"),d(!0),(0,c.gaTrack)({event:"ga4Event",event_name:"subscribe",event_parameters:{page_group:e.dealsType??e.genre??"",position:"sticky",info:"Member Floating Window"}})):w(e.subscribedLabel??"You've already subscribed!")}catch{i("Network error")}finally{C(!1)}},[u,p,x,g,e,d]);return(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)(a.Text,{className:"text-[22px] font-bold leading-[1.2]",html:e.title}),e.desc&&(0,t.jsx)(a.Text,{className:"text-[16px] mt-[16px] font-bold text-[#1E2024]",html:e.desc}),(0,t.jsx)("input",{className:(0,c.classNames)("h-[46px] w-full border mt-[8px] px-[14px] text-[16px] outline-none placeholder:text-[#999]",h?"rounded-[4px]":"rounded-none"),placeholder:e.placeholder,value:u,onChange:l=>{i(""),_(l.target.value.trim())}}),(0,t.jsxs)("div",{className:"flex w-full mt-[8px] items-start gap-[8px]",children:[(0,t.jsx)(a.Checkbox,{checked:p,onCheckedChange:()=>A(l=>!l),className:"border-[#1d1d1f] mt-[2px]"}),(0,t.jsx)("label",{className:"text-left text-[14px] font-bold text-[#4A4C56] [&_a]:underline",dangerouslySetInnerHTML:{__html:e.policy??""}})]}),(0,t.jsx)(a.Button,{className:"w-full mt-[16px]",size:"base",loading:B,onClick:D,children:e.buttonLabel??"Subscribe"}),v&&(0,t.jsx)("div",{className:"text-left mt-[4px] text-[16px] font-semibold text-[#f84d4f]",children:(0,t.jsx)(a.Text,{html:v})}),(0,t.jsx)("div",{className:"text-left mt-[4px] text-[16px] font-semibold text-[#52c41a]",children:(0,t.jsx)(a.Text,{html:U})}),e.promo&&(0,t.jsxs)("div",{className:"flex mt-[32px] flex-col text-left",children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[e.promo?.title&&(0,t.jsx)(a.Text,{className:"text-[18px] font-bold leading-[1.2]",html:e.promo.title}),e.promo.description&&(0,t.jsx)(a.Text,{className:"text-[14px] text-[#080A0F] mt-[8px] font-bold",html:e.promo.description}),e.promo.learnMoreLabel&&e.promo.learnMoreUrl&&(0,t.jsxs)("a",{href:(()=>{try{if(!n)return e.promo.learnMoreUrl;const l=new URL(e.promo.learnMoreUrl,window.location.href);return l.searchParams.set("ref",`${n}_subscribe`),l.toString()}catch{return e.promo.learnMoreUrl}})(),target:"_blank",rel:"noopener noreferrer",className:"flex mt-[8px] items-center gap-[4px] text-[14px] font-bold",children:[e.promo.learnMoreLabel,(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:(0,t.jsx)("path",{d:"M5.52827 3.52876C5.78862 3.26841 6.21063 3.26841 6.47098 3.52876L10.471 7.52876C10.7313 7.78911 10.7313 8.21112 10.471 8.47147L6.47098 12.4715C6.21063 12.7318 5.78862 12.7318 5.52827 12.4715C5.26792 12.2111 5.26792 11.7891 5.52827 11.5288L9.05692 8.00011L5.52827 4.47147C5.26792 4.21112 5.26792 3.78911 5.52827 3.52876Z",fill:"#080A0F"})})]})]}),e.promo.image?.url&&(0,t.jsx)(a.Picture,{source:e.promo.image.url,alt:e.promo.image.alt??"",className:(0,c.classNames)("h-[100px] mt-[8px] w-full object-cover",h?"rounded-[8px]":"rounded-none")})]})]})}
1
+ "use strict";var F=Object.create;var f=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var $=(e,r)=>{for(var s in r)f(e,s,{get:r[s],enumerable:!0})},M=(e,r,s,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of I(r))!j.call(e,n)&&n!==s&&f(e,n,{get:()=>r[n],enumerable:!(d=H(r,n))||d.enumerable});return e};var q=(e,r,s)=>(s=e!=null?F(O(e)):{},M(r||!e||!e.__esModule?f(s,"default",{value:e,enumerable:!0}):s,e)),z=e=>M(f({},"__esModule",{value:!0}),e);var W={};$(W,{default:()=>P});module.exports=z(W);var t=require("react/jsx-runtime"),o=require("react"),a=require("@anker-in/headless-ui"),c=require("../../../lib"),m=q(require("js-cookie")),S=require("query-string"),k=require("../../credits/context/utils"),L=require("../context/provider"),T=require("../../../constants");function J(){if(typeof window>"u")return{register_source:""};const{search:e,href:r}=window.location,s=(0,S.parse)(e);return{fbuy_ref_code:m.default.get("fbuy_ref_code"),ref:m.default.get("ref_ads"),inviter_code:s.ic??s.inviter_code??m.default.get("inviter_code"),register_source:s.redirect??m.default.get("reg_source")??r}}async function V(e){if(typeof window>"u"||!window?.grecaptcha?.execute||!e)return"";try{return await window.grecaptcha.execute(e,{action:"activity"})}catch{return""}}function P({copy:e,email:r}){const{alpcConfig:s,setIsSubscribeSuccess:d,pageHandle:n}=(0,L.useMemberPopupContext)(),{locale:x,apiBaseUrl:g}=s,{brand:y,storeDomain:h,recaptchaSitekey:U}=(0,c.useHeadlessContext)(),_=T.ROUNDED_BRANDS.includes(y),[p,A]=(0,o.useState)(e.policyDefaultChecked??!1),[u,v]=(0,o.useState)(r??""),[w,i]=(0,o.useState)(""),[B,C]=(0,o.useState)(""),[D,N]=(0,o.useState)(!1);(0,o.useEffect)(()=>{r&&v(r)},[r]);const R=(0,o.useCallback)(async()=>{if(i(""),!u)return i("Please fill in your email");if(!(0,k.emailValidate)(u))return i("Invalid email address");if(!p)return i("Please agree to the policy");N(!0);const{register_source:l}=J(),E=await V(U||"");try{const b=await(await fetch(`${g||""}/api/multipass/rainbowbridge/activities`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","current-language":x,"X-Recaptcha-Token":E},body:JSON.stringify({email:u,register_source:l,shopify_domain:h,single_brand_subscribe:e.single_brand_subscribe??!0,genre:e.genre??e.dealsType??"",sub_brand_type:e.sub_brand_type??""})})).json();b?.data?.is_new_subscribe?b?.data?.errors?i(b?.data?.errors??"Error occurred"):(C(e.successTips??"Subscribed successfully!"),d(!0),(0,c.gaTrack)({event:"ga4Event",event_name:"subscribe",event_parameters:{page_group:e.dealsType??e.genre??"",position:"sticky",info:"Member Floating Window"}})):C(e.subscribedLabel??"You've already subscribed!")}catch{i("Network error")}finally{N(!1)}},[u,p,x,h,e,d,g]);return(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)(a.Text,{className:"text-[22px] font-bold leading-[1.2]",html:e.title}),e.desc&&(0,t.jsx)(a.Text,{className:"text-[16px] mt-[16px] font-bold text-[#1E2024]",html:e.desc}),(0,t.jsx)("input",{className:(0,c.classNames)("h-[46px] w-full border mt-[8px] px-[14px] text-[16px] outline-none placeholder:text-[#999]",_?"rounded-[4px]":"rounded-none"),placeholder:e.placeholder,value:u,onChange:l=>{i(""),v(l.target.value.trim())}}),(0,t.jsxs)("div",{className:"flex w-full mt-[8px] items-start gap-[8px]",children:[(0,t.jsx)(a.Checkbox,{checked:p,onCheckedChange:()=>A(l=>!l),className:"border-[#1d1d1f] mt-[2px]"}),(0,t.jsx)("label",{className:"text-left text-[14px] font-bold text-[#4A4C56] [&_a]:underline",dangerouslySetInnerHTML:{__html:e.policy??""}})]}),(0,t.jsx)(a.Button,{className:"w-full mt-[16px]",size:"base",loading:D,onClick:R,children:e.buttonLabel??"Subscribe"}),w&&(0,t.jsx)("div",{className:"text-left mt-[4px] text-[16px] font-semibold text-[#f84d4f]",children:(0,t.jsx)(a.Text,{html:w})}),(0,t.jsx)("div",{className:"text-left mt-[4px] text-[16px] font-semibold text-[#52c41a]",children:(0,t.jsx)(a.Text,{html:B})}),e.promo&&(0,t.jsxs)("div",{className:"flex mt-[32px] flex-col text-left",children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[e.promo?.title&&(0,t.jsx)(a.Text,{className:"text-[18px] font-bold leading-[1.2]",html:e.promo.title}),e.promo.description&&(0,t.jsx)(a.Text,{className:"text-[14px] text-[#080A0F] mt-[8px] font-bold",html:e.promo.description}),e.promo.learnMoreLabel&&e.promo.learnMoreUrl&&(0,t.jsxs)("a",{href:(()=>{try{if(!n)return e.promo.learnMoreUrl;const l=new URL(e.promo.learnMoreUrl,window.location.href);return l.searchParams.set("ref",`${n}_subscribe`),l.toString()}catch{return e.promo.learnMoreUrl}})(),target:"_blank",rel:"noopener noreferrer",className:"flex mt-[8px] items-center gap-[4px] text-[14px] font-bold",children:[e.promo.learnMoreLabel,(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:(0,t.jsx)("path",{d:"M5.52827 3.52876C5.78862 3.26841 6.21063 3.26841 6.47098 3.52876L10.471 7.52876C10.7313 7.78911 10.7313 8.21112 10.471 8.47147L6.47098 12.4715C6.21063 12.7318 5.78862 12.7318 5.52827 12.4715C5.26792 12.2111 5.26792 11.7891 5.52827 11.5288L9.05692 8.00011L5.52827 4.47147C5.26792 4.21112 5.26792 3.78911 5.52827 3.52876Z",fill:"#080A0F"})})]})]}),e.promo.image?.url&&(0,t.jsx)(a.Picture,{source:e.promo.image.url,alt:e.promo.image.alt??"",className:(0,c.classNames)("h-[100px] mt-[8px] w-full object-cover",_?"rounded-[8px]":"rounded-none")})]})]})}
2
2
  //# sourceMappingURL=ActivitiesSubscribePanel.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx"],
4
- "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Button, Checkbox, Picture, Text } from '@anker-in/headless-ui'\nimport { gaTrack, classNames as cn, useHeadlessContext } from '../../../lib'\nimport Cookies from 'js-cookie'\nimport { parse } from 'query-string'\nimport { emailValidate } from '../../credits/context/utils'\nimport { useMemberPopupContext } from '../context/provider'\nimport type { SubscribeModalCopy } from '../type'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\ntype Props = {\n copy: SubscribeModalCopy\n email?: string\n}\n\nfunction getAdCookie() {\n if (typeof window === 'undefined') return { register_source: '' }\n const { search, href } = window.location\n const query = parse(search)\n return {\n fbuy_ref_code: Cookies.get('fbuy_ref_code'),\n ref: Cookies.get('ref_ads'),\n inviter_code: query.ic ?? query.inviter_code ?? Cookies.get('inviter_code'),\n register_source: query.redirect ?? Cookies.get('reg_source') ?? href,\n }\n}\n\nasync function getRecaptchaToken(sitekey: string): Promise<string> {\n if (typeof window === 'undefined' || !window?.grecaptcha?.execute) return ''\n if (!sitekey) return ''\n try {\n return await window.grecaptcha.execute(sitekey, { action: 'activity' })\n } catch {\n return ''\n }\n}\n\nexport default function ActivitiesSubscribeModal({ copy, email: initialEmail }: Props) {\n const { alpcConfig, setIsSubscribeSuccess, pageHandle } = useMemberPopupContext()\n const { locale } = alpcConfig\n const { brand: headlessBrand, storeDomain, recaptchaSitekey } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(headlessBrand)\n const [policy, setPolicy] = useState(copy.policyDefaultChecked ?? false)\n const [email, setEmail] = useState(initialEmail ?? '')\n const [errorMessage, setErrorMessage] = useState('')\n const [successMessage, setSuccessMessage] = useState('')\n const [loading, setLoading] = useState(false)\n\n useEffect(() => {\n if (initialEmail) setEmail(initialEmail)\n }, [initialEmail])\n\n const handleSubmit = useCallback(async () => {\n setErrorMessage('')\n if (!email) return setErrorMessage('Please fill in your email')\n if (!emailValidate(email)) return setErrorMessage('Invalid email address')\n if (!policy) return setErrorMessage('Please agree to the policy')\n\n setLoading(true)\n const { register_source } = getAdCookie()\n const recaptchaToken = await getRecaptchaToken(recaptchaSitekey || '')\n try {\n const response = await fetch('/api/multipass/rainbowbridge/activities', {\n method: 'POST',\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n 'current-language': locale,\n 'X-Recaptcha-Token': recaptchaToken,\n },\n body: JSON.stringify({\n email,\n register_source,\n shopify_domain: storeDomain,\n single_brand_subscribe: copy.single_brand_subscribe ?? true,\n genre: copy.genre ?? copy.dealsType ?? '',\n sub_brand_type: copy.sub_brand_type ?? '',\n }),\n })\n const result = await response.json()\n if (!result?.data?.is_new_subscribe) {\n setSuccessMessage(copy.subscribedLabel ?? \"You've already subscribed!\")\n } else if (!result?.data?.errors) {\n setSuccessMessage(copy.successTips ?? 'Subscribed successfully!')\n setIsSubscribeSuccess(true)\n gaTrack({\n event: 'ga4Event',\n event_name: 'subscribe',\n event_parameters: {\n page_group: copy.dealsType ?? copy.genre ?? '',\n position: 'sticky',\n info: 'Member Floating Window',\n },\n })\n } else {\n setErrorMessage(result?.data?.errors ?? 'Error occurred')\n }\n } catch {\n setErrorMessage('Network error')\n } finally {\n setLoading(false)\n }\n }, [email, policy, locale, storeDomain, copy, setIsSubscribeSuccess])\n\n return (\n <div className=\"flex flex-col\">\n <Text className=\"text-[22px] font-bold leading-[1.2]\" html={copy.title} />\n {copy.desc && <Text className=\"text-[16px] mt-[16px] font-bold text-[#1E2024]\" html={copy.desc} />}\n\n <input\n className={cn(\n 'h-[46px] w-full border mt-[8px] px-[14px] text-[16px] outline-none placeholder:text-[#999]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n placeholder={copy.placeholder}\n value={email}\n onChange={e => {\n setErrorMessage('')\n setEmail(e.target.value.trim())\n }}\n />\n\n <div className=\"flex w-full mt-[8px] items-start gap-[8px]\">\n <Checkbox checked={policy} onCheckedChange={() => setPolicy(v => !v)} className=\"border-[#1d1d1f] mt-[2px]\" />\n <label\n className=\"text-left text-[14px] font-bold text-[#4A4C56] [&_a]:underline\"\n dangerouslySetInnerHTML={{ __html: copy.policy ?? '' }}\n />\n </div>\n\n <Button className=\"w-full mt-[16px]\" size=\"base\" loading={loading} onClick={handleSubmit}>\n {copy.buttonLabel ?? 'Subscribe'}\n </Button>\n\n {errorMessage && (\n <div className=\"text-left mt-[4px] text-[16px] font-semibold text-[#f84d4f]\">\n <Text html={errorMessage} />\n </div>\n )}\n <div className=\"text-left mt-[4px] text-[16px] font-semibold text-[#52c41a]\">\n <Text html={successMessage} />\n </div>\n\n {copy.promo && (\n <div className=\"flex mt-[32px] flex-col text-left\">\n <div className=\"flex flex-col\">\n {copy.promo?.title && <Text className=\"text-[18px] font-bold leading-[1.2]\" html={copy.promo.title} />}\n {copy.promo.description && (\n <Text className=\"text-[14px] text-[#080A0F] mt-[8px] font-bold\" html={copy.promo.description} />\n )}\n {copy.promo.learnMoreLabel && copy.promo.learnMoreUrl && (\n <a\n href={(() => {\n try {\n if (!pageHandle) return copy.promo!.learnMoreUrl!\n const url = new URL(copy.promo!.learnMoreUrl!, window.location.href)\n url.searchParams.set('ref', `${pageHandle}_subscribe`)\n return url.toString()\n } catch {\n return copy.promo!.learnMoreUrl!\n }\n })()}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"flex mt-[8px] items-center gap-[4px] text-[14px] font-bold\"\n >\n {copy.promo.learnMoreLabel}\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n <path\n d=\"M5.52827 3.52876C5.78862 3.26841 6.21063 3.26841 6.47098 3.52876L10.471 7.52876C10.7313 7.78911 10.7313 8.21112 10.471 8.47147L6.47098 12.4715C6.21063 12.7318 5.78862 12.7318 5.52827 12.4715C5.26792 12.2111 5.26792 11.7891 5.52827 11.5288L9.05692 8.00011L5.52827 4.47147C5.26792 4.21112 5.26792 3.78911 5.52827 3.52876Z\"\n fill=\"#080A0F\"\n />\n </svg>\n </a>\n )}\n </div>\n {copy.promo.image?.url && (\n <Picture\n source={copy.promo.image.url}\n alt={copy.promo.image.alt ?? ''}\n className={cn('h-[100px] mt-[8px] w-full object-cover', rounded ? 'rounded-[8px]' : 'rounded-none')}\n />\n )}\n </div>\n )}\n </div>\n )\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA0GM,IAAAI,EAAA,6BA1GNC,EAAiD,iBACjDC,EAAgD,iCAChDC,EAA8D,wBAC9DC,EAAoB,wBACpBC,EAAsB,wBACtBC,EAA8B,uCAC9BC,EAAsC,+BAEtCC,EAA+B,8BAO/B,SAASC,GAAc,CACrB,GAAI,OAAO,OAAW,IAAa,MAAO,CAAE,gBAAiB,EAAG,EAChE,KAAM,CAAE,OAAAC,EAAQ,KAAAC,CAAK,EAAI,OAAO,SAC1BC,KAAQ,SAAMF,CAAM,EAC1B,MAAO,CACL,cAAe,EAAAG,QAAQ,IAAI,eAAe,EAC1C,IAAK,EAAAA,QAAQ,IAAI,SAAS,EAC1B,aAAcD,EAAM,IAAMA,EAAM,cAAgB,EAAAC,QAAQ,IAAI,cAAc,EAC1E,gBAAiBD,EAAM,UAAY,EAAAC,QAAQ,IAAI,YAAY,GAAKF,CAClE,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import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_js_cookie", "import_query_string", "import_utils", "import_provider", "import_constants", "getAdCookie", "search", "href", "query", "Cookies", "getRecaptchaToken", "sitekey", "copy", "initialEmail", "alpcConfig", "setIsSubscribeSuccess", "pageHandle", "locale", "headlessBrand", "storeDomain", "recaptchaSitekey", "rounded", "policy", "setPolicy", "email", "setEmail", "errorMessage", "setErrorMessage", "successMessage", "setSuccessMessage", "loading", "setLoading", "handleSubmit", "register_source", "recaptchaToken", "result", "cn", "e", "v", "url"]
4
+ "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Button, Checkbox, Picture, Text } from '@anker-in/headless-ui'\nimport { gaTrack, classNames as cn, useHeadlessContext } from '../../../lib'\nimport Cookies from 'js-cookie'\nimport { parse } from 'query-string'\nimport { emailValidate } from '../../credits/context/utils'\nimport { useMemberPopupContext } from '../context/provider'\nimport type { SubscribeModalCopy } from '../type'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\ntype Props = {\n copy: SubscribeModalCopy\n email?: string\n}\n\nfunction getAdCookie() {\n if (typeof window === 'undefined') return { register_source: '' }\n const { search, href } = window.location\n const query = parse(search)\n return {\n fbuy_ref_code: Cookies.get('fbuy_ref_code'),\n ref: Cookies.get('ref_ads'),\n inviter_code: query.ic ?? query.inviter_code ?? Cookies.get('inviter_code'),\n register_source: query.redirect ?? Cookies.get('reg_source') ?? href,\n }\n}\n\nasync function getRecaptchaToken(sitekey: string): Promise<string> {\n if (typeof window === 'undefined' || !window?.grecaptcha?.execute) return ''\n if (!sitekey) return ''\n try {\n return await window.grecaptcha.execute(sitekey, { action: 'activity' })\n } catch {\n return ''\n }\n}\n\nexport default function ActivitiesSubscribeModal({ copy, email: initialEmail }: Props) {\n const { alpcConfig, setIsSubscribeSuccess, pageHandle } = useMemberPopupContext()\n const { locale, apiBaseUrl } = alpcConfig\n const { brand: headlessBrand, storeDomain, recaptchaSitekey } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(headlessBrand)\n const [policy, setPolicy] = useState(copy.policyDefaultChecked ?? false)\n const [email, setEmail] = useState(initialEmail ?? '')\n const [errorMessage, setErrorMessage] = useState('')\n const [successMessage, setSuccessMessage] = useState('')\n const [loading, setLoading] = useState(false)\n\n useEffect(() => {\n if (initialEmail) setEmail(initialEmail)\n }, [initialEmail])\n\n const handleSubmit = useCallback(async () => {\n setErrorMessage('')\n if (!email) return setErrorMessage('Please fill in your email')\n if (!emailValidate(email)) return setErrorMessage('Invalid email address')\n if (!policy) return setErrorMessage('Please agree to the policy')\n\n setLoading(true)\n const { register_source } = getAdCookie()\n const recaptchaToken = await getRecaptchaToken(recaptchaSitekey || '')\n try {\n const response = await fetch(`${apiBaseUrl || ''}/api/multipass/rainbowbridge/activities`, {\n method: 'POST',\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n 'current-language': locale,\n 'X-Recaptcha-Token': recaptchaToken,\n },\n body: JSON.stringify({\n email,\n register_source,\n shopify_domain: storeDomain,\n single_brand_subscribe: copy.single_brand_subscribe ?? true,\n genre: copy.genre ?? copy.dealsType ?? '',\n sub_brand_type: copy.sub_brand_type ?? '',\n }),\n })\n const result = await response.json()\n if (!result?.data?.is_new_subscribe) {\n setSuccessMessage(copy.subscribedLabel ?? \"You've already subscribed!\")\n } else if (!result?.data?.errors) {\n setSuccessMessage(copy.successTips ?? 'Subscribed successfully!')\n setIsSubscribeSuccess(true)\n gaTrack({\n event: 'ga4Event',\n event_name: 'subscribe',\n event_parameters: {\n page_group: copy.dealsType ?? copy.genre ?? '',\n position: 'sticky',\n info: 'Member Floating Window',\n },\n })\n } else {\n setErrorMessage(result?.data?.errors ?? 'Error occurred')\n }\n } catch {\n setErrorMessage('Network error')\n } finally {\n setLoading(false)\n }\n }, [email, policy, locale, storeDomain, copy, setIsSubscribeSuccess, apiBaseUrl])\n\n return (\n <div className=\"flex flex-col\">\n <Text className=\"text-[22px] font-bold leading-[1.2]\" html={copy.title} />\n {copy.desc && <Text className=\"text-[16px] mt-[16px] font-bold text-[#1E2024]\" html={copy.desc} />}\n\n <input\n className={cn(\n 'h-[46px] w-full border mt-[8px] px-[14px] text-[16px] outline-none placeholder:text-[#999]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n placeholder={copy.placeholder}\n value={email}\n onChange={e => {\n setErrorMessage('')\n setEmail(e.target.value.trim())\n }}\n />\n\n <div className=\"flex w-full mt-[8px] items-start gap-[8px]\">\n <Checkbox checked={policy} onCheckedChange={() => setPolicy(v => !v)} className=\"border-[#1d1d1f] mt-[2px]\" />\n <label\n className=\"text-left text-[14px] font-bold text-[#4A4C56] [&_a]:underline\"\n dangerouslySetInnerHTML={{ __html: copy.policy ?? '' }}\n />\n </div>\n\n <Button className=\"w-full mt-[16px]\" size=\"base\" loading={loading} onClick={handleSubmit}>\n {copy.buttonLabel ?? 'Subscribe'}\n </Button>\n\n {errorMessage && (\n <div className=\"text-left mt-[4px] text-[16px] font-semibold text-[#f84d4f]\">\n <Text html={errorMessage} />\n </div>\n )}\n <div className=\"text-left mt-[4px] text-[16px] font-semibold text-[#52c41a]\">\n <Text html={successMessage} />\n </div>\n\n {copy.promo && (\n <div className=\"flex mt-[32px] flex-col text-left\">\n <div className=\"flex flex-col\">\n {copy.promo?.title && <Text className=\"text-[18px] font-bold leading-[1.2]\" html={copy.promo.title} />}\n {copy.promo.description && (\n <Text className=\"text-[14px] text-[#080A0F] mt-[8px] font-bold\" html={copy.promo.description} />\n )}\n {copy.promo.learnMoreLabel && copy.promo.learnMoreUrl && (\n <a\n href={(() => {\n try {\n if (!pageHandle) return copy.promo!.learnMoreUrl!\n const url = new URL(copy.promo!.learnMoreUrl!, window.location.href)\n url.searchParams.set('ref', `${pageHandle}_subscribe`)\n return url.toString()\n } catch {\n return copy.promo!.learnMoreUrl!\n }\n })()}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"flex mt-[8px] items-center gap-[4px] text-[14px] font-bold\"\n >\n {copy.promo.learnMoreLabel}\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n <path\n d=\"M5.52827 3.52876C5.78862 3.26841 6.21063 3.26841 6.47098 3.52876L10.471 7.52876C10.7313 7.78911 10.7313 8.21112 10.471 8.47147L6.47098 12.4715C6.21063 12.7318 5.78862 12.7318 5.52827 12.4715C5.26792 12.2111 5.26792 11.7891 5.52827 11.5288L9.05692 8.00011L5.52827 4.47147C5.26792 4.21112 5.26792 3.78911 5.52827 3.52876Z\"\n fill=\"#080A0F\"\n />\n </svg>\n </a>\n )}\n </div>\n {copy.promo.image?.url && (\n <Picture\n source={copy.promo.image.url}\n alt={copy.promo.image.alt ?? ''}\n className={cn('h-[100px] mt-[8px] w-full object-cover', rounded ? 'rounded-[8px]' : 'rounded-none')}\n />\n )}\n </div>\n )}\n </div>\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA0GM,IAAAI,EAAA,6BA1GNC,EAAiD,iBACjDC,EAAgD,iCAChDC,EAA8D,wBAC9DC,EAAoB,wBACpBC,EAAsB,wBACtBC,EAA8B,uCAC9BC,EAAsC,+BAEtCC,EAA+B,8BAO/B,SAASC,GAAc,CACrB,GAAI,OAAO,OAAW,IAAa,MAAO,CAAE,gBAAiB,EAAG,EAChE,KAAM,CAAE,OAAAC,EAAQ,KAAAC,CAAK,EAAI,OAAO,SAC1BC,KAAQ,SAAMF,CAAM,EAC1B,MAAO,CACL,cAAe,EAAAG,QAAQ,IAAI,eAAe,EAC1C,IAAK,EAAAA,QAAQ,IAAI,SAAS,EAC1B,aAAcD,EAAM,IAAMA,EAAM,cAAgB,EAAAC,QAAQ,IAAI,cAAc,EAC1E,gBAAiBD,EAAM,UAAY,EAAAC,QAAQ,IAAI,YAAY,GAAKF,CAClE,CACF,CAEA,eAAeG,EAAkBC,EAAkC,CAEjE,GADI,OAAO,OAAW,KAAe,CAAC,QAAQ,YAAY,SACt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AAK,OAAO,QAASmB,EAAS,QAASE,EACzE,SAAArB,EAAK,aAAe,YACvB,EAECe,MACC,OAAC,OAAI,UAAU,8DACb,mBAAC,QAAK,KAAMA,EAAc,EAC5B,KAEF,OAAC,OAAI,UAAU,8DACb,mBAAC,QAAK,KAAME,EAAgB,EAC9B,EAECjB,EAAK,UACJ,QAAC,OAAI,UAAU,oCACb,qBAAC,OAAI,UAAU,gBACZ,UAAAA,EAAK,OAAO,UAAS,OAAC,QAAK,UAAU,sCAAsC,KAAMA,EAAK,MAAM,MAAO,EACnGA,EAAK,MAAM,gBACV,OAAC,QAAK,UAAU,gDAAgD,KAAMA,EAAK,MAAM,YAAa,EAE/FA,EAAK,MAAM,gBAAkBA,EAAK,MAAM,iBACvC,QAAC,KACC,MAAO,IAAM,CACX,GAAI,CACF,GAAI,CAACI,EAAY,OAAOJ,EAAK,MAAO,aACpC,MAAM4B,EAAM,IAAI,IAAI5B,EAAK,MAAO,aAAe,OAAO,SAAS,IAAI,EACnE,OAAA4B,EAAI,aAAa,IAAI,MAAO,GAAGxB,CAAU,YAAY,EAC9CwB,EAAI,SAAS,CACtB,MAAQ,CACN,OAAO5B,EAAK,MAAO,YACrB,CACF,GAAG,EACH,OAAO,SACP,IAAI,sBACJ,UAAU,6DAET,UAAAA,EAAK,MAAM,kBACZ,OAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACnD,mBAAC,QACC,EAAE,kUACF,KAAK,UACP,EACF,GACF,GAEJ,EACCA,EAAK,MAAM,OAAO,QACjB,OAAC,WACC,OAAQA,EAAK,MAAM,MAAM,IACzB,IAAKA,EAAK,MAAM,MAAM,KAAO,GAC7B,aAAW,EAAAyB,YAAG,yCAA0Cf,EAAU,gBAAkB,cAAc,EACpG,GAEJ,GAEJ,CAEJ",
6
+ "names": ["ActivitiesSubscribePanel_exports", "__export", "ActivitiesSubscribeModal", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_js_cookie", "import_query_string", "import_utils", "import_provider", "import_constants", "getAdCookie", "search", "href", "query", "Cookies", "getRecaptchaToken", "sitekey", "copy", "initialEmail", "alpcConfig", "setIsSubscribeSuccess", "pageHandle", "locale", "apiBaseUrl", "headlessBrand", "storeDomain", "recaptchaSitekey", "rounded", "policy", "setPolicy", "email", "setEmail", "errorMessage", "setErrorMessage", "successMessage", "setSuccessMessage", "loading", "setLoading", "handleSubmit", "register_source", "recaptchaToken", "result", "cn", "e", "v", "url"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var S=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var X=(e,i)=>{for(var c in i)S(e,c,{get:i[c],enumerable:!0})},Y=(e,i,c,g)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of J(i))!Q.call(e,r)&&r!==c&&S(e,r,{get:()=>i[r],enumerable:!(g=G(i,r))||g.enumerable});return e};var Z=e=>Y(S({},"__esModule",{value:!0}),e);var ee={};X(ee,{default:()=>V});module.exports=Z(ee);var n=require("react/jsx-runtime"),o=require("react"),u=require("@anker-in/headless-ui"),s=require("../../../../lib"),R=require("../../../registration/authCodeActivate/Message"),H=require("../../../registration"),L=require("../../context/provider"),P=require("../../../../constants");function V({copy:e,onClose:i}){const{setIsActivateSuccess:c,fetchCreditInfo:g,profile:r}=(0,L.useMemberPopupContext)(),{locale:B,brand:F}=(0,s.useHeadlessContext)(),{email:d}=(0,H.useRegistration)(),$=P.ROUNDED_BRANDS.includes(F),{isMutating:z,trigger:x,data:E}=(0,s.useSendEmailValidation)(),{isMutating:y,trigger:k}=(0,s.useEmailValidation)(),[W,f]=(0,o.useState)(""),[j,p]=(0,o.useState)(""),{startCountDown:A,startAction:D,countDown:K}=(0,s.useCountDown)(60),[I,b]=(0,o.useState)(""),[N,_]=(0,o.useState)(0),[m,w]=(0,o.useState)(new Array(6).fill("")),T=(0,o.useRef)([]),C=m.join("");(0,o.useEffect)(()=>{T.current[N]&&T.current[N].focus()},[N]),(0,o.useEffect)(()=>{d&&x({email:d,data:{redirect_url:`${window?.location?.origin}${window?.location?.pathname}`}},{onSuccess:()=>{p("success"),f(e?.sendEmailSuccessMessage||""),D(),setTimeout(()=>{p(""),f("")},5e3)}})},[d]);const O=(0,o.useCallback)(async()=>{d&&(await x({email:d,data:{redirect_url:`${window?.location?.origin}${window?.location?.pathname}`}},{onSuccess:()=>{p("success"),f(e?.sendEmailSuccessMessage||""),D(),setTimeout(()=>{p(""),f("")},5e3)}}),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{page_group:"reg_sub_pop",position:"auth_code",button_name:"sent_again"}}))},[d,x]),U=(v,a)=>{const{value:t}=v.target;if(b(""),Number.isNaN(Number(t)))return;if(t.length>1){a<m.length-1&&(m[a+1]||(_(a+1),w(h=>{const M=[...h];return M[a]=t[0],t.length>1&&(M[a+1]=t[1]),M})));return}const l=[...m];l[a]=t,w(l),t?a<m.length-1&&!m[a+1]&&_(a+1):a>0&&_(a-1)},q=(0,o.useCallback)(async()=>{if(!C?.length){b(e?.codeEmptyError||"");return}if(C.length<6){b(e?.incorrectCodeError||"");return}const v=E?.data?.data?.active_token??E?.data?.active_token;v&&await k({token:v,code:C},{onSuccess:t=>{if(t.status>=200&&t.status<300)p("success"),f(e?.authSuccessMessage||""),c(!0),r?.user_id&&setTimeout(()=>g(r.user_id),3e3),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{page_group:"reg_sub_pop",position:"auth_code",button_name:"check_and_active",info:"Member Floating Window"}}),setTimeout(()=>{i()},3e3);else{const l=t?.data?.error_code??t?.error_code;l==="104"?(c(!0),r?.user_id&&setTimeout(()=>g(r.user_id),3e3),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{page_group:"reg_sub_pop",position:"auth_code",button_name:"check_and_active",info:"Member Floating Window"}}),setTimeout(()=>{i()},3e3)):b(l==="142"?e?.incorrectCodeError||"Invalid verification code.":l==="154"?e?.expiredCodeMessage||"":e?.sendEmailErrorMessage||"")}}});let a=setTimeout(()=>{p(""),f(""),clearTimeout(a)},5e3)},[C,e?.codeEmptyError,e?.authSuccessMessage,e?.incorrectCodeError,e?.expiredCodeMessage,e?.sendEmailErrorMessage,B,E,k,i,c,g,r]);return(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(u.Text,{className:"text-[22px] font-extrabold leading-[120%] text-[#333] min-l:text-[24px] [&_abbr]:text-[#005d8e]",html:e?.authCodeTitle}),(0,n.jsx)(u.Text,{as:"p",className:"mt-3 text-[14px] font-semibold leading-[140%] text-[rgba(51,51,51,0.75)] min-l:text-base [&_abbr]:text-[#333]",html:e?.authCodeDesc?.replace("%email%",d||"")})]}),(0,n.jsxs)("div",{className:"mt-6",children:[(0,n.jsx)(u.Text,{className:"mt-4 text-[14px] !font-bold font-semibold leading-[140%] text-[#333] min-l:mt-6",html:e?.enterActiveCodeText}),(0,n.jsx)("div",{className:"my-3 grid grid-cols-6 gap-2",children:m.map((v,a)=>(0,n.jsx)("div",{className:"col-span-1 aspect-1 text-[#555]",children:(0,n.jsx)("input",{ref:t=>{t&&(T.current[a]=t)},type:"tel",className:(0,s.classNames)("flex size-full items-center justify-center border border-[#333333]/20 bg-[#EEEEEE] text-center text-[24px] font-medium focus:border-[#333]/50 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none [&:focus-visible]:outline-none",$&&"rounded-[12px]"),value:v,autoComplete:"false",autoCorrect:"false",spellCheck:"false",autoCapitalize:"false",onChange:t=>U(t,a),onFocus:()=>{_(a)},onPaste:t=>{const l=t.clipboardData.getData("text");if(!Number.isNaN(Number(l))){const h=l.split("").slice(0,6);w(h.concat(Array(6-h.length).fill(""))),h.length<=m.length&&_(h.length-1)}},onKeyDown:t=>{const{value:l}=t.target;t.key==="Backspace"&&!l&&a>0&&_(a-1)}},a)},a))}),I&&(0,n.jsx)(u.Text,{className:"mb-3 text-[14px] font-semibold leading-[120%] text-[#f84d4f]",html:I}),e?.authCodeContent&&(0,n.jsx)("ul",{className:'flex flex-col gap-1 [&_li]:flex [&_li]:gap-2 [&_li]:text-[14px] [&_li]:font-semibold [&_li]:leading-[120%] [&_li]:text-[rgba(51,51,51,0.55)] [&_li]:before:content-["\u2022"]',dangerouslySetInnerHTML:{__html:e?.authCodeContent}})]}),(0,n.jsxs)("div",{className:"mt-4 min-l:mt-6",children:[(0,n.jsx)(u.Text,{className:"text-base font-semibold leading-[100%] text-[#333]",html:e?.authCodeReceiveText})," ",A?(0,n.jsx)(u.Text,{html:e?.retrieveText?.replace("%countdownTime%",K.toString()),className:"cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline"}):(0,n.jsx)(u.Text,{onClick:O,className:(0,s.classNames)("cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline",{"pointer-events-none":A||z}),html:e?.sendAgainText}),(0,n.jsx)(u.Button,{type:"submit",loading:y,className:"mt-6 w-full min-l:mt-8",size:"base",onClick:q,children:e.buttonText})]}),(0,n.jsx)(R.Message,{status:j,message:W})]})}
1
+ "use strict";var S=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var X=Object.prototype.hasOwnProperty;var Y=(e,i)=>{for(var c in i)S(e,c,{get:i[c],enumerable:!0})},Z=(e,i,c,g)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of Q(i))!X.call(e,r)&&r!==c&&S(e,r,{get:()=>i[r],enumerable:!(g=J(i,r))||g.enumerable});return e};var ee=e=>Z(S({},"__esModule",{value:!0}),e);var te={};Y(te,{default:()=>V});module.exports=ee(te);var n=require("react/jsx-runtime"),o=require("react"),u=require("@anker-in/headless-ui"),s=require("../../../../lib"),R=require("../../../registration/authCodeActivate/Message"),H=require("../../../registration"),L=require("../../context/provider"),P=require("../../../../constants");function V({copy:e,onClose:i}){const{setIsActivateSuccess:c,fetchCreditInfo:g,profile:r,alpcConfig:k}=(0,L.useMemberPopupContext)(),{locale:F,brand:$}=(0,s.useHeadlessContext)(),{email:d}=(0,H.useRegistration)(),z=P.ROUNDED_BRANDS.includes($),{isMutating:U,trigger:x,data:E}=(0,s.useSendEmailValidation)(k.apiBaseUrl),{isMutating:y,trigger:A}=(0,s.useEmailValidation)(void 0,k.apiBaseUrl),[W,f]=(0,o.useState)(""),[j,p]=(0,o.useState)(""),{startCountDown:D,startAction:I,countDown:K}=(0,s.useCountDown)(60),[B,b]=(0,o.useState)(""),[N,_]=(0,o.useState)(0),[m,w]=(0,o.useState)(new Array(6).fill("")),T=(0,o.useRef)([]),C=m.join("");(0,o.useEffect)(()=>{T.current[N]&&T.current[N].focus()},[N]),(0,o.useEffect)(()=>{d&&x({email:d,data:{redirect_url:`${window?.location?.origin}${window?.location?.pathname}`}},{onSuccess:()=>{p("success"),f(e?.sendEmailSuccessMessage||""),I(),setTimeout(()=>{p(""),f("")},5e3)}})},[d]);const O=(0,o.useCallback)(async()=>{d&&(await x({email:d,data:{redirect_url:`${window?.location?.origin}${window?.location?.pathname}`}},{onSuccess:()=>{p("success"),f(e?.sendEmailSuccessMessage||""),I(),setTimeout(()=>{p(""),f("")},5e3)}}),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{page_group:"reg_sub_pop",position:"auth_code",button_name:"sent_again"}}))},[d,x]),q=(v,a)=>{const{value:t}=v.target;if(b(""),Number.isNaN(Number(t)))return;if(t.length>1){a<m.length-1&&(m[a+1]||(_(a+1),w(h=>{const M=[...h];return M[a]=t[0],t.length>1&&(M[a+1]=t[1]),M})));return}const l=[...m];l[a]=t,w(l),t?a<m.length-1&&!m[a+1]&&_(a+1):a>0&&_(a-1)},G=(0,o.useCallback)(async()=>{if(!C?.length){b(e?.codeEmptyError||"");return}if(C.length<6){b(e?.incorrectCodeError||"");return}const v=E?.data?.data?.active_token??E?.data?.active_token;v&&await A({token:v,code:C},{onSuccess:t=>{if(t.status>=200&&t.status<300)p("success"),f(e?.authSuccessMessage||""),c(!0),r?.user_id&&setTimeout(()=>g(r.user_id),3e3),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{page_group:"reg_sub_pop",position:"auth_code",button_name:"check_and_active",info:"Member Floating Window"}}),setTimeout(()=>{i()},3e3);else{const l=t?.data?.error_code??t?.error_code;l==="104"?(c(!0),r?.user_id&&setTimeout(()=>g(r.user_id),3e3),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{page_group:"reg_sub_pop",position:"auth_code",button_name:"check_and_active",info:"Member Floating Window"}}),setTimeout(()=>{i()},3e3)):b(l==="142"?e?.incorrectCodeError||"Invalid verification code.":l==="154"?e?.expiredCodeMessage||"":e?.sendEmailErrorMessage||"")}}});let a=setTimeout(()=>{p(""),f(""),clearTimeout(a)},5e3)},[C,e?.codeEmptyError,e?.authSuccessMessage,e?.incorrectCodeError,e?.expiredCodeMessage,e?.sendEmailErrorMessage,F,E,A,i,c,g,r]);return(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(u.Text,{className:"text-[22px] font-extrabold leading-[120%] text-[#333] min-l:text-[24px] [&_abbr]:text-[#005d8e]",html:e?.authCodeTitle}),(0,n.jsx)(u.Text,{as:"p",className:"mt-3 text-[14px] font-semibold leading-[140%] text-[rgba(51,51,51,0.75)] min-l:text-base [&_abbr]:text-[#333]",html:e?.authCodeDesc?.replace("%email%",d||"")})]}),(0,n.jsxs)("div",{className:"mt-6",children:[(0,n.jsx)(u.Text,{className:"mt-4 text-[14px] !font-bold font-semibold leading-[140%] text-[#333] min-l:mt-6",html:e?.enterActiveCodeText}),(0,n.jsx)("div",{className:"my-3 grid grid-cols-6 gap-2",children:m.map((v,a)=>(0,n.jsx)("div",{className:"col-span-1 aspect-1 text-[#555]",children:(0,n.jsx)("input",{ref:t=>{t&&(T.current[a]=t)},type:"tel",className:(0,s.classNames)("flex size-full items-center justify-center border border-[#333333]/20 bg-[#EEEEEE] text-center text-[24px] font-medium focus:border-[#333]/50 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none [&:focus-visible]:outline-none",z&&"rounded-[12px]"),value:v,autoComplete:"false",autoCorrect:"false",spellCheck:"false",autoCapitalize:"false",onChange:t=>q(t,a),onFocus:()=>{_(a)},onPaste:t=>{const l=t.clipboardData.getData("text");if(!Number.isNaN(Number(l))){const h=l.split("").slice(0,6);w(h.concat(Array(6-h.length).fill(""))),h.length<=m.length&&_(h.length-1)}},onKeyDown:t=>{const{value:l}=t.target;t.key==="Backspace"&&!l&&a>0&&_(a-1)}},a)},a))}),B&&(0,n.jsx)(u.Text,{className:"mb-3 text-[14px] font-semibold leading-[120%] text-[#f84d4f]",html:B}),e?.authCodeContent&&(0,n.jsx)("ul",{className:'flex flex-col gap-1 [&_li]:flex [&_li]:gap-2 [&_li]:text-[14px] [&_li]:font-semibold [&_li]:leading-[120%] [&_li]:text-[rgba(51,51,51,0.55)] [&_li]:before:content-["\u2022"]',dangerouslySetInnerHTML:{__html:e?.authCodeContent}})]}),(0,n.jsxs)("div",{className:"mt-4 min-l:mt-6",children:[(0,n.jsx)(u.Text,{className:"text-base font-semibold leading-[100%] text-[#333]",html:e?.authCodeReceiveText})," ",D?(0,n.jsx)(u.Text,{html:e?.retrieveText?.replace("%countdownTime%",K.toString()),className:"cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline"}):(0,n.jsx)(u.Text,{onClick:O,className:(0,s.classNames)("cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline",{"pointer-events-none":D||U}),html:e?.sendAgainText}),(0,n.jsx)(u.Button,{type:"submit",loading:y,className:"mt-6 w-full min-l:mt-8",size:"base",onClick:G,children:e.buttonText})]}),(0,n.jsx)(R.Message,{status:j,message:W})]})}
2
2
  //# sourceMappingURL=ActivatePanel.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/EarnCredits/ActivatePanel.tsx"],
4
- "sourcesContent": ["import { useState, useCallback, useRef, useEffect } from 'react'\nimport { Button, Text } from '@anker-in/headless-ui'\nimport {\n useSendEmailValidation,\n gaTrack,\n classNames as cn,\n useHeadlessContext,\n useEmailValidation,\n useCountDown,\n} from '../../../../lib'\nimport { Message } from '../../../registration/authCodeActivate/Message'\nimport type { AuthCodeActivateCopy } from '../../type'\nimport { useRegistration } from '../../../registration'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n copy: AuthCodeActivateCopy\n onClose: () => void\n}\n\nexport default function ActivatePanel({ copy, onClose }: Props) {\n const { setIsActivateSuccess, fetchCreditInfo, profile } = useMemberPopupContext()\n const { locale, brand } = useHeadlessContext()\n const { email } = useRegistration()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const {\n isMutating: isSendingEmail,\n trigger: triggerSendValidationEmail,\n data: sendEmailData,\n } = useSendEmailValidation()\n\n const { isMutating: emailValidationLoading, trigger: triggerEmailValidation } = useEmailValidation()\n\n const [messageText, setMessageText] = useState('')\n const [messageStatus, setMessageStatus] = useState('')\n const { startCountDown: isStartCountDown, startAction: startCountDown, countDown } = useCountDown(60)\n\n const [error, setError] = useState('')\n const [focusIndex, setFocusIndex] = useState(0)\n const [codeArray, setCodeArray] = useState(new Array(6).fill(''))\n\n const inputRefs = useRef<HTMLInputElement[]>([])\n const code = codeArray.join('')\n\n useEffect(() => {\n if (inputRefs.current[focusIndex]) {\n inputRefs.current[focusIndex].focus()\n }\n }, [focusIndex])\n\n useEffect(() => {\n if (email) {\n triggerSendValidationEmail(\n {\n email: email,\n data: {\n redirect_url: `${window?.location?.origin}${window?.location?.pathname}`,\n },\n },\n {\n onSuccess: () => {\n setMessageStatus('success')\n setMessageText(copy?.sendEmailSuccessMessage || '')\n startCountDown()\n setTimeout(() => {\n setMessageStatus('')\n setMessageText('')\n }, 5000)\n },\n }\n )\n }\n }, [email])\n\n const handleSendAgain = useCallback(async () => {\n if (!email) return\n await triggerSendValidationEmail(\n {\n email: email,\n data: {\n redirect_url: `${window?.location?.origin}${window?.location?.pathname}`,\n },\n },\n {\n onSuccess: () => {\n setMessageStatus('success')\n setMessageText(copy?.sendEmailSuccessMessage || '')\n startCountDown()\n setTimeout(() => {\n setMessageStatus('')\n setMessageText('')\n }, 5000)\n },\n }\n )\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n page_group: 'reg_sub_pop',\n position: 'auth_code',\n button_name: 'sent_again',\n },\n })\n }, [email, triggerSendValidationEmail])\n\n const handleInputCodeChange = (event: React.ChangeEvent<HTMLInputElement>, index: number) => {\n const { value } = event.target\n\n setError('')\n\n if (Number.isNaN(Number(value))) {\n return\n }\n\n if (value.length > 1) {\n if (index < codeArray.length - 1) {\n if (!codeArray[index + 1]) {\n setFocusIndex(index + 1)\n setCodeArray(old => {\n const newCode = [...old]\n newCode[index] = value[0]\n if (value.length > 1) {\n newCode[index + 1] = value[1]\n }\n return newCode\n })\n }\n }\n return\n }\n const newCode = [...codeArray]\n newCode[index] = value\n setCodeArray(newCode)\n if (value) {\n if (index < codeArray.length - 1 && !codeArray[index + 1]) {\n setFocusIndex(index + 1)\n }\n } else if (index > 0) {\n setFocusIndex(index - 1)\n }\n }\n\n const handleAuthCodeSubmit = useCallback(async () => {\n if (!code?.length) {\n setError(copy?.codeEmptyError || '')\n return\n }\n\n if (code.length < 6) {\n setError(copy?.incorrectCodeError || '')\n return\n }\n\n const token = sendEmailData?.data?.data?.active_token ?? sendEmailData?.data?.active_token\n if (token) {\n await triggerEmailValidation(\n {\n token: token,\n code: code,\n },\n {\n onSuccess: data => {\n if (data.status >= 200 && data.status < 300) {\n setMessageStatus('success')\n setMessageText(copy?.authSuccessMessage || '')\n setIsActivateSuccess(true)\n if (profile?.user_id) setTimeout(() => fetchCreditInfo(profile.user_id), 3000)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n page_group: 'reg_sub_pop',\n position: 'auth_code',\n button_name: 'check_and_active',\n info: 'Member Floating Window',\n },\n })\n setTimeout(() => {\n onClose()\n }, 3000)\n } else {\n const errorCode = data?.data?.error_code ?? data?.error_code\n if (errorCode === '104') {\n setIsActivateSuccess(true)\n if (profile?.user_id) setTimeout(() => fetchCreditInfo(profile.user_id), 3000)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n page_group: 'reg_sub_pop',\n position: 'auth_code',\n button_name: 'check_and_active',\n info: 'Member Floating Window',\n },\n })\n setTimeout(() => {\n onClose()\n }, 3000)\n } else if (errorCode === '142') {\n setError(copy?.incorrectCodeError || 'Invalid verification code.')\n } else if (errorCode === '154') {\n setError(copy?.expiredCodeMessage || '')\n } else {\n setError(copy?.sendEmailErrorMessage || '')\n }\n }\n },\n }\n )\n }\n\n let timer = setTimeout(() => {\n setMessageStatus('')\n setMessageText('')\n clearTimeout(timer)\n }, 5000)\n }, [\n code,\n copy?.codeEmptyError,\n copy?.authSuccessMessage,\n copy?.incorrectCodeError,\n copy?.expiredCodeMessage,\n copy?.sendEmailErrorMessage,\n locale,\n sendEmailData,\n triggerEmailValidation,\n onClose,\n setIsActivateSuccess,\n fetchCreditInfo,\n profile,\n ])\n\n return (\n <div className=\"relative\">\n <div>\n <Text\n className=\"text-[22px] font-extrabold leading-[120%] text-[#333] min-l:text-[24px] [&_abbr]:text-[#005d8e]\"\n html={copy?.authCodeTitle}\n />\n <Text\n as=\"p\"\n className=\"mt-3 text-[14px] font-semibold leading-[140%] text-[rgba(51,51,51,0.75)] min-l:text-base [&_abbr]:text-[#333]\"\n html={copy?.authCodeDesc?.replace('%email%', email || '')}\n />\n </div>\n <div className=\"mt-6\">\n <Text\n className=\"mt-4 text-[14px] !font-bold font-semibold leading-[140%] text-[#333] min-l:mt-6\"\n html={copy?.enterActiveCodeText}\n />\n <div className=\"my-3 grid grid-cols-6 gap-2\">\n {codeArray.map((item, index) => (\n <div key={index} className=\"col-span-1 aspect-1 text-[#555]\">\n <input\n ref={inputRef => {\n if (inputRef) {\n inputRefs.current[index] = inputRef\n }\n }}\n key={index}\n type=\"tel\"\n className={cn(\n 'flex size-full items-center justify-center border border-[#333333]/20 bg-[#EEEEEE] text-center text-[24px] font-medium focus:border-[#333]/50 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none [&:focus-visible]:outline-none',\n rounded && 'rounded-[12px]'\n )}\n value={item}\n autoComplete=\"false\"\n autoCorrect=\"false\"\n spellCheck=\"false\"\n autoCapitalize=\"false\"\n onChange={event => handleInputCodeChange(event, index)}\n onFocus={() => {\n setFocusIndex(index)\n }}\n onPaste={event => {\n const paste = event.clipboardData.getData('text')\n if (!Number.isNaN(Number(paste))) {\n const pastedCode = paste.split('').slice(0, 6)\n setCodeArray(pastedCode.concat(Array(6 - pastedCode.length).fill('')))\n if (pastedCode.length <= codeArray.length) {\n setFocusIndex(pastedCode.length - 1)\n }\n }\n }}\n onKeyDown={event => {\n const { value } = event.target as HTMLInputElement\n if (event.key === 'Backspace' && !value && index > 0) {\n setFocusIndex(index - 1)\n }\n }}\n />\n </div>\n ))}\n </div>\n\n {error && <Text className=\"mb-3 text-[14px] font-semibold leading-[120%] text-[#f84d4f]\" html={error} />}\n {copy?.authCodeContent && (\n <ul\n className='flex flex-col gap-1 [&_li]:flex [&_li]:gap-2 [&_li]:text-[14px] [&_li]:font-semibold [&_li]:leading-[120%] [&_li]:text-[rgba(51,51,51,0.55)] [&_li]:before:content-[\"\u2022\"]'\n dangerouslySetInnerHTML={{ __html: copy?.authCodeContent }}\n />\n )}\n </div>\n <div className=\"mt-4 min-l:mt-6\">\n <Text className=\"text-base font-semibold leading-[100%] text-[#333]\" html={copy?.authCodeReceiveText} />{' '}\n {isStartCountDown ? (\n <Text\n html={copy?.retrieveText?.replace('%countdownTime%', countDown.toString())}\n className=\"cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline\"\n />\n ) : (\n <Text\n onClick={handleSendAgain}\n className={cn(\n 'cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline',\n {\n 'pointer-events-none': isStartCountDown || isSendingEmail,\n }\n )}\n html={copy?.sendAgainText}\n />\n )}\n <Button\n type=\"submit\"\n loading={emailValidationLoading}\n className=\"mt-6 w-full min-l:mt-8\"\n size=\"base\"\n onClick={handleAuthCodeSubmit}\n >\n {copy.buttonText}\n </Button>\n </div>\n <Message status={messageStatus} message={messageText} />\n </div>\n )\n}\n"],
5
- "mappings": "yaAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,IAAA,eAAAC,EAAAH,IA6OM,IAAAI,EAAA,6BA7ONC,EAAyD,iBACzDC,EAA6B,iCAC7BC,EAOO,2BACPC,EAAwB,0DAExBC,EAAgC,iCAChCC,EAAsC,kCACtCC,EAA+B,iCAOhB,SAART,EAA+B,CAAE,KAAAU,EAAM,QAAAC,CAAQ,EAAU,CAC9D,KAAM,CAAE,qBAAAC,EAAsB,gBAAAC,EAAiB,QAAAC,CAAQ,KAAI,yBAAsB,EAC3E,CAAE,OAAAC,EAAQ,MAAAC,CAAM,KAAI,sBAAmB,EACvC,CAAE,MAAAC,CAAM,KAAI,mBAAgB,EAC5BC,EAAU,iBAAe,SAASF,CAAK,EAEvC,CACJ,WAAYG,EACZ,QAASC,EACT,KAAMC,CACR,KAAI,0BAAuB,EAErB,CAAE,WAAYC,EAAwB,QAASC,CAAuB,KAAI,sBAAmB,EAE7F,CAACC,EAAaC,CAAc,KAAI,YAAS,EAAE,EAC3C,CAACC,EAAeC,CAAgB,KAAI,YAAS,EAAE,EAC/C,CAAE,eAAgBC,EAAkB,YAAaC,EAAgB,UAAAC,CAAU,KAAI,gBAAa,EAAE,EAE9F,CAACC,EAAOC,CAAQ,KAAI,YAAS,EAAE,EAC/B,CAACC,EAAYC,CAAa,KAAI,YAAS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", "ActivatePanel", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_Message", "import_registration", "import_provider", "import_constants", "copy", "onClose", "setIsActivateSuccess", "fetchCreditInfo", "profile", "locale", "brand", "email", "rounded", "isSendingEmail", "triggerSendValidationEmail", "sendEmailData", "emailValidationLoading", "triggerEmailValidation", "messageText", "setMessageText", "messageStatus", "setMessageStatus", "isStartCountDown", "startCountDown", "countDown", "error", "setError", "focusIndex", "setFocusIndex", "codeArray", "setCodeArray", "inputRefs", "code", "handleSendAgain", "handleInputCodeChange", "event", "index", "value", "old", "newCode", "handleAuthCodeSubmit", "token", "data", "errorCode", "timer", "item", "inputRef", "cn", "paste", "pastedCode"]
4
+ "sourcesContent": ["import { useState, useCallback, useRef, useEffect } from 'react'\nimport { Button, Text } from '@anker-in/headless-ui'\nimport {\n useSendEmailValidation,\n gaTrack,\n classNames as cn,\n useHeadlessContext,\n useEmailValidation,\n useCountDown,\n} from '../../../../lib'\nimport { Message } from '../../../registration/authCodeActivate/Message'\nimport type { AuthCodeActivateCopy } from '../../type'\nimport { useRegistration } from '../../../registration'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n copy: AuthCodeActivateCopy\n onClose: () => void\n}\n\nexport default function ActivatePanel({ copy, onClose }: Props) {\n const { setIsActivateSuccess, fetchCreditInfo, profile, alpcConfig } = useMemberPopupContext()\n const { locale, brand } = useHeadlessContext()\n const { email } = useRegistration()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const {\n isMutating: isSendingEmail,\n trigger: triggerSendValidationEmail,\n data: sendEmailData,\n } = useSendEmailValidation(alpcConfig.apiBaseUrl)\n\n const { isMutating: emailValidationLoading, trigger: triggerEmailValidation } = useEmailValidation(undefined, alpcConfig.apiBaseUrl)\n\n const [messageText, setMessageText] = useState('')\n const [messageStatus, setMessageStatus] = useState('')\n const { startCountDown: isStartCountDown, startAction: startCountDown, countDown } = useCountDown(60)\n\n const [error, setError] = useState('')\n const [focusIndex, setFocusIndex] = useState(0)\n const [codeArray, setCodeArray] = useState(new Array(6).fill(''))\n\n const inputRefs = useRef<HTMLInputElement[]>([])\n const code = codeArray.join('')\n\n useEffect(() => {\n if (inputRefs.current[focusIndex]) {\n inputRefs.current[focusIndex].focus()\n }\n }, [focusIndex])\n\n useEffect(() => {\n if (email) {\n triggerSendValidationEmail(\n {\n email: email,\n data: {\n redirect_url: `${window?.location?.origin}${window?.location?.pathname}`,\n },\n },\n {\n onSuccess: () => {\n setMessageStatus('success')\n setMessageText(copy?.sendEmailSuccessMessage || '')\n startCountDown()\n setTimeout(() => {\n setMessageStatus('')\n setMessageText('')\n }, 5000)\n },\n }\n )\n }\n }, [email])\n\n const handleSendAgain = useCallback(async () => {\n if (!email) return\n await triggerSendValidationEmail(\n {\n email: email,\n data: {\n redirect_url: `${window?.location?.origin}${window?.location?.pathname}`,\n },\n },\n {\n onSuccess: () => {\n setMessageStatus('success')\n setMessageText(copy?.sendEmailSuccessMessage || '')\n startCountDown()\n setTimeout(() => {\n setMessageStatus('')\n setMessageText('')\n }, 5000)\n },\n }\n )\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n page_group: 'reg_sub_pop',\n position: 'auth_code',\n button_name: 'sent_again',\n },\n })\n }, [email, triggerSendValidationEmail])\n\n const handleInputCodeChange = (event: React.ChangeEvent<HTMLInputElement>, index: number) => {\n const { value } = event.target\n\n setError('')\n\n if (Number.isNaN(Number(value))) {\n return\n }\n\n if (value.length > 1) {\n if (index < codeArray.length - 1) {\n if (!codeArray[index + 1]) {\n setFocusIndex(index + 1)\n setCodeArray(old => {\n const newCode = [...old]\n newCode[index] = value[0]\n if (value.length > 1) {\n newCode[index + 1] = value[1]\n }\n return newCode\n })\n }\n }\n return\n }\n const newCode = [...codeArray]\n newCode[index] = value\n setCodeArray(newCode)\n if (value) {\n if (index < codeArray.length - 1 && !codeArray[index + 1]) {\n setFocusIndex(index + 1)\n }\n } else if (index > 0) {\n setFocusIndex(index - 1)\n }\n }\n\n const handleAuthCodeSubmit = useCallback(async () => {\n if (!code?.length) {\n setError(copy?.codeEmptyError || '')\n return\n }\n\n if (code.length < 6) {\n setError(copy?.incorrectCodeError || '')\n return\n }\n\n const token = sendEmailData?.data?.data?.active_token ?? sendEmailData?.data?.active_token\n if (token) {\n await triggerEmailValidation(\n {\n token: token,\n code: code,\n },\n {\n onSuccess: data => {\n if (data.status >= 200 && data.status < 300) {\n setMessageStatus('success')\n setMessageText(copy?.authSuccessMessage || '')\n setIsActivateSuccess(true)\n if (profile?.user_id) setTimeout(() => fetchCreditInfo(profile.user_id), 3000)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n page_group: 'reg_sub_pop',\n position: 'auth_code',\n button_name: 'check_and_active',\n info: 'Member Floating Window',\n },\n })\n setTimeout(() => {\n onClose()\n }, 3000)\n } else {\n const errorCode = data?.data?.error_code ?? data?.error_code\n if (errorCode === '104') {\n setIsActivateSuccess(true)\n if (profile?.user_id) setTimeout(() => fetchCreditInfo(profile.user_id), 3000)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n page_group: 'reg_sub_pop',\n position: 'auth_code',\n button_name: 'check_and_active',\n info: 'Member Floating Window',\n },\n })\n setTimeout(() => {\n onClose()\n }, 3000)\n } else if (errorCode === '142') {\n setError(copy?.incorrectCodeError || 'Invalid verification code.')\n } else if (errorCode === '154') {\n setError(copy?.expiredCodeMessage || '')\n } else {\n setError(copy?.sendEmailErrorMessage || '')\n }\n }\n },\n }\n )\n }\n\n let timer = setTimeout(() => {\n setMessageStatus('')\n setMessageText('')\n clearTimeout(timer)\n }, 5000)\n }, [\n code,\n copy?.codeEmptyError,\n copy?.authSuccessMessage,\n copy?.incorrectCodeError,\n copy?.expiredCodeMessage,\n copy?.sendEmailErrorMessage,\n locale,\n sendEmailData,\n triggerEmailValidation,\n onClose,\n setIsActivateSuccess,\n fetchCreditInfo,\n profile,\n ])\n\n return (\n <div className=\"relative\">\n <div>\n <Text\n className=\"text-[22px] font-extrabold leading-[120%] text-[#333] min-l:text-[24px] [&_abbr]:text-[#005d8e]\"\n html={copy?.authCodeTitle}\n />\n <Text\n as=\"p\"\n className=\"mt-3 text-[14px] font-semibold leading-[140%] text-[rgba(51,51,51,0.75)] min-l:text-base [&_abbr]:text-[#333]\"\n html={copy?.authCodeDesc?.replace('%email%', email || '')}\n />\n </div>\n <div className=\"mt-6\">\n <Text\n className=\"mt-4 text-[14px] !font-bold font-semibold leading-[140%] text-[#333] min-l:mt-6\"\n html={copy?.enterActiveCodeText}\n />\n <div className=\"my-3 grid grid-cols-6 gap-2\">\n {codeArray.map((item, index) => (\n <div key={index} className=\"col-span-1 aspect-1 text-[#555]\">\n <input\n ref={inputRef => {\n if (inputRef) {\n inputRefs.current[index] = inputRef\n }\n }}\n key={index}\n type=\"tel\"\n className={cn(\n 'flex size-full items-center justify-center border border-[#333333]/20 bg-[#EEEEEE] text-center text-[24px] font-medium focus:border-[#333]/50 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none [&:focus-visible]:outline-none',\n rounded && 'rounded-[12px]'\n )}\n value={item}\n autoComplete=\"false\"\n autoCorrect=\"false\"\n spellCheck=\"false\"\n autoCapitalize=\"false\"\n onChange={event => handleInputCodeChange(event, index)}\n onFocus={() => {\n setFocusIndex(index)\n }}\n onPaste={event => {\n const paste = event.clipboardData.getData('text')\n if (!Number.isNaN(Number(paste))) {\n const pastedCode = paste.split('').slice(0, 6)\n setCodeArray(pastedCode.concat(Array(6 - pastedCode.length).fill('')))\n if (pastedCode.length <= codeArray.length) {\n setFocusIndex(pastedCode.length - 1)\n }\n }\n }}\n onKeyDown={event => {\n const { value } = event.target as HTMLInputElement\n if (event.key === 'Backspace' && !value && index > 0) {\n setFocusIndex(index - 1)\n }\n }}\n />\n </div>\n ))}\n </div>\n\n {error && <Text className=\"mb-3 text-[14px] font-semibold leading-[120%] text-[#f84d4f]\" html={error} />}\n {copy?.authCodeContent && (\n <ul\n className='flex flex-col gap-1 [&_li]:flex [&_li]:gap-2 [&_li]:text-[14px] [&_li]:font-semibold [&_li]:leading-[120%] [&_li]:text-[rgba(51,51,51,0.55)] [&_li]:before:content-[\"\u2022\"]'\n dangerouslySetInnerHTML={{ __html: copy?.authCodeContent }}\n />\n )}\n </div>\n <div className=\"mt-4 min-l:mt-6\">\n <Text className=\"text-base font-semibold leading-[100%] text-[#333]\" html={copy?.authCodeReceiveText} />{' '}\n {isStartCountDown ? (\n <Text\n html={copy?.retrieveText?.replace('%countdownTime%', countDown.toString())}\n className=\"cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline\"\n />\n ) : (\n <Text\n onClick={handleSendAgain}\n className={cn(\n 'cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline',\n {\n 'pointer-events-none': isStartCountDown || isSendingEmail,\n }\n )}\n html={copy?.sendAgainText}\n />\n )}\n <Button\n type=\"submit\"\n loading={emailValidationLoading}\n className=\"mt-6 w-full min-l:mt-8\"\n size=\"base\"\n onClick={handleAuthCodeSubmit}\n >\n {copy.buttonText}\n </Button>\n </div>\n <Message status={messageStatus} message={messageText} />\n </div>\n )\n}\n"],
5
+ "mappings": "0aAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,IAAA,eAAAC,GAAAH,IA6OM,IAAAI,EAAA,6BA7ONC,EAAyD,iBACzDC,EAA6B,iCAC7BC,EAOO,2BACPC,EAAwB,0DAExBC,EAAgC,iCAChCC,EAAsC,kCACtCC,EAA+B,iCAOhB,SAART,EAA+B,CAAE,KAAAU,EAAM,QAAAC,CAAQ,EAAU,CAC9D,KAAM,CAAE,qBAAAC,EAAsB,gBAAAC,EAAiB,QAAAC,EAAS,WAAAC,CAAW,KAAI,yBAAsB,EACvF,CAAE,OAAAC,EAAQ,MAAAC,CAAM,KAAI,sBAAmB,EACvC,C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QAAC,OAAI,UAAU,kBACb,oBAAC,QAAK,UAAU,qDAAqD,KAAMA,GAAM,oBAAqB,EAAG,IACxGmB,KACC,OAAC,QACC,KAAMnB,GAAM,cAAc,QAAQ,kBAAmBqB,EAAU,SAAS,CAAC,EACzE,UAAU,yGACZ,KAEA,OAAC,QACC,QAASS,EACT,aAAW,EAAAc,YACT,yGACA,CACE,sBAAuBzB,GAAoBT,CAC7C,CACF,EACA,KAAMV,GAAM,cACd,KAEF,OAAC,UACC,KAAK,SACL,QAASa,EACT,UAAU,yBACV,KAAK,OACL,QAASwB,EAER,SAAArC,EAAK,WACR,GACF,KACA,OAAC,WAAQ,OAAQiB,EAAe,QAASF,EAAa,GACxD,CAEJ",
6
+ "names": ["ActivatePanel_exports", "__export", "ActivatePanel", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_Message", "import_registration", "import_provider", "import_constants", "copy", "onClose", "setIsActivateSuccess", "fetchCreditInfo", "profile", "alpcConfig", "locale", "brand", "email", "rounded", "isSendingEmail", "triggerSendValidationEmail", "sendEmailData", "emailValidationLoading", "triggerEmailValidation", "messageText", "setMessageText", "messageStatus", "setMessageStatus", "isStartCountDown", "startCountDown", "countDown", "error", "setError", "focusIndex", "setFocusIndex", "codeArray", "setCodeArray", "inputRefs", "code", "handleSendAgain", "handleInputCodeChange", "event", "index", "value", "old", "newCode", "handleAuthCodeSubmit", "token", "data", "errorCode", "timer", "item", "inputRef", "cn", "paste", "pastedCode"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var H=Object.create;var c=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var K=(t,n)=>{for(var a in n)c(t,a,{get:n[a],enumerable:!0})},q=(t,n,a,p)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of W(n))!J.call(t,l)&&l!==a&&c(t,l,{get:()=>n[l],enumerable:!(p=O(n,l))||p.enumerable});return t};var Q=(t,n,a)=>(a=t!=null?H(G(t)):{},q(n||!t||!t.__esModule?c(a,"default",{value:t,enumerable:!0}):a,t)),V=t=>q(c({},"__esModule",{value:!0}),t);var X={};K(X,{default:()=>I});module.exports=V(X);var e=require("react/jsx-runtime"),r=require("react"),d=require("@anker-in/headless-ui"),s=require("../../../../lib"),F=require("./hooks/useUpdateProfile"),L=Q(require("../../../credits/context/hooks/useCountries")),T=require("../../context/provider"),z=require("../../../../constants");function I({copy:t,onClose:n}){const{profile:a,fetchCreditInfo:p,alpcConfig:l,setIsProfileCompleteSuccess:k}=(0,T.useMemberPopupContext)(),{locale:M}=l,{brand:R,storeDomain:U}=(0,s.useHeadlessContext)(),i=z.ROUNDED_BRANDS.includes(R),[m,P]=(0,r.useState)(""),[x,w]=(0,r.useState)(""),[b,E]=(0,r.useState)(""),[v,y]=(0,r.useState)(""),[u,N]=(0,r.useState)(""),[h,g]=(0,r.useState)(""),[C,_]=(0,r.useState)(""),{updateProfile:D,isLoading:B}=(0,F.useUpdateProfile)({locale:M,appName:l.appName}),{countries:f}=(0,L.default)({shopifyStoreDomain:U});(0,r.useEffect)(()=>{a&&(P(a.first_name??""),w(a.last_name??""),E(a.phone_number??""),y(a.dob??""),N(a.country?.id??""))},[a]),(0,r.useEffect)(()=>{f.length>0&&!u&&N(f[0].id)},[f]);const S=(0,r.useCallback)(()=>{let o=!1;return m.trim()?g(""):(g(t.required),o=!0),x.trim()?_(""):(_(t.required),o=!0),o},[m,x,t.required]),A=(0,r.useCallback)(async()=>{if(S())return;await D({first_name:m.trim(),last_name:x.trim(),phone_number:b,country:u,dob:v})&&(setTimeout(()=>p(a?.user_id),3e3),k(!0),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"earn_credits",button_name:"complete_profile_success",info:"Member Floating Window"}}),n())},[S,D,m,x,b,u,v,p,a,k,n]);return(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[t.subtitle&&(0,e.jsx)(d.Text,{className:"text-[14px] text-[#1d1d1f]",html:t.subtitle}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.email}),(0,e.jsx)("input",{className:(0,s.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] bg-[#f5f5f5] px-[12px] text-[14px] text-[#999]",i?"rounded-[4px]":"rounded-none"),value:a?.email??"",disabled:!0})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:[t.firstName," ",(0,e.jsx)("span",{className:"text-[#f84d4f]",children:"*"})]}),(0,e.jsx)("input",{className:(0,s.classNames)("mt-[8px] h-[46px] w-full border px-[12px] text-[14px] outline-none",h?"border-[#f84d4f]":"border-[#d8d8d8]",i?"rounded-[4px]":"rounded-none"),value:m,onChange:o=>{P(o.target.value),g("")}}),h&&(0,e.jsx)(d.Text,{className:"mt-[4px] text-[12px] text-[#f84d4f]",html:h})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:[t.lastName," ",(0,e.jsx)("span",{className:"text-[#f84d4f]",children:"*"})]}),(0,e.jsx)("input",{className:(0,s.classNames)("mt-[8px] h-[46px] w-full border px-[12px] text-[14px] outline-none",C?"border-[#f84d4f]":"border-[#d8d8d8]",i?"rounded-[4px]":"rounded-none"),value:x,onChange:o=>{w(o.target.value),_("")}}),C&&(0,e.jsx)(d.Text,{className:"mt-[4px] text-[12px] text-[#f84d4f]",html:C})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.birthday}),(0,e.jsx)("input",{className:(0,s.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none",i?"rounded-[4px]":"rounded-none"),type:"date",value:v,onChange:o=>y(o.target.value)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.phone}),(0,e.jsx)("input",{className:(0,s.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none",i?"rounded-[4px]":"rounded-none"),value:b,onChange:o=>E(o.target.value)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.country}),(0,e.jsx)("select",{className:(0,s.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none",i?"rounded-[4px]":"rounded-none"),value:u,onChange:o=>N(o.target.value),children:f.map(o=>(0,e.jsx)("option",{value:o.id,children:o.name},o.id))})]}),(0,e.jsxs)("div",{className:"flex gap-[12px]",children:[(0,e.jsx)(d.Button,{variant:"secondary",size:"base",className:"flex-1",onClick:n,disabled:B,children:t.cancel}),(0,e.jsx)(d.Button,{variant:"primary",size:"base",className:"flex-1",loading:B,onClick:A,children:t.save})]})]})}
1
+ "use strict";var H=Object.create;var c=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var K=(t,r)=>{for(var a in r)c(t,a,{get:r[a],enumerable:!0})},S=(t,r,a,p)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of W(r))!J.call(t,l)&&l!==a&&c(t,l,{get:()=>r[l],enumerable:!(p=O(r,l))||p.enumerable});return t};var Q=(t,r,a)=>(a=t!=null?H(G(t)):{},S(r||!t||!t.__esModule?c(a,"default",{value:t,enumerable:!0}):a,t)),V=t=>S(c({},"__esModule",{value:!0}),t);var X={};K(X,{default:()=>z});module.exports=V(X);var e=require("react/jsx-runtime"),n=require("react"),d=require("@anker-in/headless-ui"),s=require("../../../../lib"),q=require("./hooks/useUpdateProfile"),F=Q(require("../../../credits/context/hooks/useCountries")),L=require("../../context/provider"),T=require("../../../../constants");function z({copy:t,onClose:r}){const{profile:a,fetchCreditInfo:p,alpcConfig:l,setIsProfileCompleteSuccess:k}=(0,L.useMemberPopupContext)(),{locale:I}=l,{brand:M,storeDomain:R}=(0,s.useHeadlessContext)(),i=T.ROUNDED_BRANDS.includes(M),[m,P]=(0,n.useState)(""),[x,B]=(0,n.useState)(""),[b,w]=(0,n.useState)(""),[v,E]=(0,n.useState)(""),[u,N]=(0,n.useState)(""),[h,g]=(0,n.useState)(""),[C,_]=(0,n.useState)(""),{updateProfile:y,isLoading:D}=(0,q.useUpdateProfile)({locale:I,appName:l.appName,apiBaseUrl:l.apiBaseUrl}),{countries:f}=(0,F.default)({shopifyStoreDomain:R,apiBaseUrl:l.apiBaseUrl});(0,n.useEffect)(()=>{a&&(P(a.first_name??""),B(a.last_name??""),w(a.phone_number??""),E(a.dob??""),N(a.country?.id??""))},[a]),(0,n.useEffect)(()=>{f.length>0&&!u&&N(f[0].id)},[f]);const U=(0,n.useCallback)(()=>{let o=!1;return m.trim()?g(""):(g(t.required),o=!0),x.trim()?_(""):(_(t.required),o=!0),o},[m,x,t.required]),A=(0,n.useCallback)(async()=>{if(U())return;await y({first_name:m.trim(),last_name:x.trim(),phone_number:b,country:u,dob:v})&&(setTimeout(()=>p(a?.user_id),3e3),k(!0),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"earn_credits",button_name:"complete_profile_success",info:"Member Floating Window"}}),r())},[U,y,m,x,b,u,v,p,a,k,r]);return(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[t.subtitle&&(0,e.jsx)(d.Text,{className:"text-[14px] text-[#1d1d1f]",html:t.subtitle}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.email}),(0,e.jsx)("input",{className:(0,s.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] bg-[#f5f5f5] px-[12px] text-[14px] text-[#999]",i?"rounded-[4px]":"rounded-none"),value:a?.email??"",disabled:!0})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:[t.firstName," ",(0,e.jsx)("span",{className:"text-[#f84d4f]",children:"*"})]}),(0,e.jsx)("input",{className:(0,s.classNames)("mt-[8px] h-[46px] w-full border px-[12px] text-[14px] outline-none",h?"border-[#f84d4f]":"border-[#d8d8d8]",i?"rounded-[4px]":"rounded-none"),value:m,onChange:o=>{P(o.target.value),g("")}}),h&&(0,e.jsx)(d.Text,{className:"mt-[4px] text-[12px] text-[#f84d4f]",html:h})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:[t.lastName," ",(0,e.jsx)("span",{className:"text-[#f84d4f]",children:"*"})]}),(0,e.jsx)("input",{className:(0,s.classNames)("mt-[8px] h-[46px] w-full border px-[12px] text-[14px] outline-none",C?"border-[#f84d4f]":"border-[#d8d8d8]",i?"rounded-[4px]":"rounded-none"),value:x,onChange:o=>{B(o.target.value),_("")}}),C&&(0,e.jsx)(d.Text,{className:"mt-[4px] text-[12px] text-[#f84d4f]",html:C})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.birthday}),(0,e.jsx)("input",{className:(0,s.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none",i?"rounded-[4px]":"rounded-none"),type:"date",value:v,onChange:o=>E(o.target.value)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.phone}),(0,e.jsx)("input",{className:(0,s.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none",i?"rounded-[4px]":"rounded-none"),value:b,onChange:o=>w(o.target.value)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.country}),(0,e.jsx)("select",{className:(0,s.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none",i?"rounded-[4px]":"rounded-none"),value:u,onChange:o=>N(o.target.value),children:f.map(o=>(0,e.jsx)("option",{value:o.id,children:o.name},o.id))})]}),(0,e.jsxs)("div",{className:"flex gap-[12px]",children:[(0,e.jsx)(d.Button,{variant:"secondary",size:"base",className:"flex-1",onClick:r,disabled:D,children:t.cancel}),(0,e.jsx)(d.Button,{variant:"primary",size:"base",className:"flex-1",loading:D,onClick:A,children:t.save})]})]})}
2
2
  //# sourceMappingURL=CompleteProfilePanel.js.map