@anker-in/campaign-ui 0.2.11-beta.2 → 0.2.11-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/credits/context/hooks/useFunctionMemberPrice.d.ts +2 -2
- package/dist/cjs/components/credits/context/hooks/useFunctionMemberPrice.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useFunctionMemberPrice.js.map +2 -2
- package/dist/cjs/components/credits/context/memberPriceConst.d.ts +0 -5
- package/dist/cjs/components/credits/context/memberPriceConst.js +1 -1
- package/dist/cjs/components/credits/context/memberPriceConst.js.map +3 -3
- package/dist/cjs/components/credits/context/memberPriceTypes.d.ts +1 -22
- package/dist/cjs/components/credits/context/memberPriceTypes.js +1 -1
- package/dist/cjs/components/credits/context/memberPriceTypes.js.map +1 -1
- package/dist/cjs/components/credits/context/provider.d.ts +15 -1
- package/dist/cjs/components/credits/context/provider.js +1 -1
- package/dist/cjs/components/credits/context/provider.js.map +3 -3
- package/dist/cjs/components/credits/context/utils/getFunctionMemberPrice.d.ts +2 -2
- package/dist/cjs/components/credits/context/utils/getFunctionMemberPrice.js +1 -1
- package/dist/cjs/components/credits/context/utils/getFunctionMemberPrice.js.map +1 -1
- package/dist/cjs/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.d.ts +2 -2
- package/dist/cjs/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.js +1 -1
- package/dist/cjs/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.js.map +1 -1
- package/dist/cjs/components/credits/context/utils/variantGetCoupon.d.ts +2 -2
- package/dist/cjs/components/credits/context/utils/variantGetCoupon.js +1 -1
- package/dist/cjs/components/credits/context/utils/variantGetCoupon.js.map +1 -1
- package/dist/cjs/components/credits/context/utils.d.ts +4 -0
- package/dist/cjs/components/credits/context/utils.js +1 -1
- package/dist/cjs/components/credits/context/utils.js.map +3 -3
- package/dist/cjs/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.js +1 -1
- package/dist/cjs/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.js.map +3 -3
- package/dist/cjs/components/credits/creditsBanner/index.d.ts +2 -0
- package/dist/cjs/components/credits/creditsBanner/index.js +12 -1
- package/dist/cjs/components/credits/creditsBanner/index.js.map +3 -3
- package/dist/cjs/components/credits/creditsBenefits/BenefitItem.js +1 -1
- package/dist/cjs/components/credits/creditsBenefits/BenefitItem.js.map +3 -3
- package/dist/cjs/components/credits/creditsBenefits/IconInfo.js +1 -1
- package/dist/cjs/components/credits/creditsBenefits/IconInfo.js.map +1 -1
- package/dist/cjs/components/credits/creditsBenefits/index.js +3 -3
- package/dist/cjs/components/credits/creditsBenefits/index.js.map +2 -2
- package/dist/cjs/components/credits/creditsCash/CreditsCash.js +1 -1
- package/dist/cjs/components/credits/creditsCash/CreditsCash.js.map +2 -2
- package/dist/cjs/components/credits/creditsCash/RedeemableItem.js +1 -1
- package/dist/cjs/components/credits/creditsCash/RedeemableItem.js.map +3 -3
- package/dist/cjs/components/credits/creditsCash/type.d.ts +1 -0
- package/dist/cjs/components/credits/creditsCash/type.js +1 -1
- package/dist/cjs/components/credits/creditsCash/type.js.map +1 -1
- package/dist/cjs/components/credits/creditsFaq/faqItem/FaqItem.js +1 -1
- package/dist/cjs/components/credits/creditsFaq/faqItem/FaqItem.js.map +3 -3
- package/dist/cjs/components/credits/creditsFaq/index.js +1 -1
- package/dist/cjs/components/credits/creditsFaq/index.js.map +3 -3
- package/dist/cjs/components/credits/creditsInfoCard/index.js +1 -1
- package/dist/cjs/components/credits/creditsInfoCard/index.js.map +3 -3
- package/dist/cjs/components/credits/creditsMemberPrice/CreditsMemberPrice.js +1 -1
- package/dist/cjs/components/credits/creditsMemberPrice/CreditsMemberPrice.js.map +3 -3
- package/dist/cjs/components/credits/creditsMemberPrice/MemberPriceItem.js +1 -1
- package/dist/cjs/components/credits/creditsMemberPrice/MemberPriceItem.js.map +3 -3
- package/dist/cjs/components/credits/creditsMemberPrice/Pagination.d.ts +7 -0
- package/dist/cjs/components/credits/creditsMemberPrice/Pagination.js +2 -0
- package/dist/cjs/components/credits/creditsMemberPrice/Pagination.js.map +7 -0
- package/dist/cjs/components/credits/creditsMemberPrice/type.d.ts +3 -5
- package/dist/cjs/components/credits/creditsMemberPrice/type.js +1 -1
- package/dist/cjs/components/credits/creditsMemberPrice/type.js.map +1 -1
- package/dist/cjs/components/credits/creditsNavigation/CreditsNavigation.js +1 -1
- package/dist/cjs/components/credits/creditsNavigation/CreditsNavigation.js.map +2 -2
- package/dist/cjs/components/credits/creditsRedeemList/AddressForm/CountrySelect.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/AddressForm/CountrySelect.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/AddressForm/StateSelect.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/AddressForm/StateSelect.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/AddressForm/index.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/AddressForm/index.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/CreditsRedeemList.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/CreditsRedeemList.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Address.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Address.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Success.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Success.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/RedeemableItem.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/RedeemableItem.js.map +3 -3
- package/dist/cjs/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js +1 -1
- package/dist/cjs/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js.map +3 -3
- package/dist/cjs/components/credits/modal/MyRewardsModal.js +1 -1
- package/dist/cjs/components/credits/modal/MyRewardsModal.js.map +3 -3
- package/dist/cjs/components/credits/modal/activitiesModal.js +1 -1
- package/dist/cjs/components/credits/modal/activitiesModal.js.map +3 -3
- package/dist/cjs/components/credits/modal/creditsUploadReceiptModal.js +1 -1
- package/dist/cjs/components/credits/modal/creditsUploadReceiptModal.js.map +3 -3
- package/dist/cjs/components/credits/modal/modalContainer.js +1 -1
- package/dist/cjs/components/credits/modal/modalContainer.js.map +3 -3
- package/dist/cjs/components/credits/modal/subscribeModal.js +1 -1
- package/dist/cjs/components/credits/modal/subscribeModal.js.map +3 -3
- package/dist/cjs/components/credits/modal/tip.js +1 -1
- package/dist/cjs/components/credits/modal/tip.js.map +3 -3
- package/dist/cjs/components/index.d.ts +2 -2
- package/dist/cjs/components/index.js +1 -1
- package/dist/cjs/components/index.js.map +2 -2
- package/dist/cjs/components/registration/authCodeActivate/index.js +1 -1
- package/dist/cjs/components/registration/authCodeActivate/index.js.map +3 -3
- package/dist/cjs/components/registration/modalContainer.js +1 -1
- package/dist/cjs/components/registration/modalContainer.js.map +3 -3
- package/dist/cjs/constants.d.ts +1 -0
- package/dist/cjs/constants.js +2 -0
- package/dist/cjs/constants.js.map +7 -0
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/templates/Credits.d.ts +15 -1
- package/dist/cjs/templates/Credits.js +1 -1
- package/dist/cjs/templates/Credits.js.map +3 -3
- package/dist/esm/components/credits/context/hooks/useFunctionMemberPrice.d.ts +2 -2
- package/dist/esm/components/credits/context/hooks/useFunctionMemberPrice.js +1 -1
- package/dist/esm/components/credits/context/hooks/useFunctionMemberPrice.js.map +2 -2
- package/dist/esm/components/credits/context/memberPriceConst.d.ts +0 -5
- package/dist/esm/components/credits/context/memberPriceConst.js +1 -1
- package/dist/esm/components/credits/context/memberPriceConst.js.map +3 -3
- package/dist/esm/components/credits/context/memberPriceTypes.d.ts +1 -22
- package/dist/esm/components/credits/context/provider.d.ts +15 -1
- package/dist/esm/components/credits/context/provider.js +1 -1
- package/dist/esm/components/credits/context/provider.js.map +3 -3
- package/dist/esm/components/credits/context/utils/getFunctionMemberPrice.d.ts +2 -2
- package/dist/esm/components/credits/context/utils/getFunctionMemberPrice.js +1 -1
- package/dist/esm/components/credits/context/utils/getFunctionMemberPrice.js.map +1 -1
- package/dist/esm/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.d.ts +2 -2
- package/dist/esm/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.js +1 -1
- package/dist/esm/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.js.map +1 -1
- package/dist/esm/components/credits/context/utils/variantGetCoupon.d.ts +2 -2
- package/dist/esm/components/credits/context/utils/variantGetCoupon.js +1 -1
- package/dist/esm/components/credits/context/utils/variantGetCoupon.js.map +1 -1
- package/dist/esm/components/credits/context/utils.d.ts +4 -0
- package/dist/esm/components/credits/context/utils.js +1 -1
- package/dist/esm/components/credits/context/utils.js.map +3 -3
- package/dist/esm/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.js +1 -1
- package/dist/esm/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.js.map +3 -3
- package/dist/esm/components/credits/creditsBanner/index.d.ts +2 -0
- package/dist/esm/components/credits/creditsBanner/index.js +12 -1
- package/dist/esm/components/credits/creditsBanner/index.js.map +3 -3
- package/dist/esm/components/credits/creditsBenefits/BenefitItem.js +1 -1
- package/dist/esm/components/credits/creditsBenefits/BenefitItem.js.map +3 -3
- package/dist/esm/components/credits/creditsBenefits/IconInfo.js +1 -1
- package/dist/esm/components/credits/creditsBenefits/IconInfo.js.map +1 -1
- package/dist/esm/components/credits/creditsBenefits/index.js +3 -3
- package/dist/esm/components/credits/creditsBenefits/index.js.map +2 -2
- package/dist/esm/components/credits/creditsCash/CreditsCash.js +1 -1
- package/dist/esm/components/credits/creditsCash/CreditsCash.js.map +2 -2
- package/dist/esm/components/credits/creditsCash/RedeemableItem.js +1 -1
- package/dist/esm/components/credits/creditsCash/RedeemableItem.js.map +3 -3
- package/dist/esm/components/credits/creditsCash/type.d.ts +1 -0
- package/dist/esm/components/credits/creditsFaq/faqItem/FaqItem.js +1 -1
- package/dist/esm/components/credits/creditsFaq/faqItem/FaqItem.js.map +3 -3
- package/dist/esm/components/credits/creditsFaq/index.js +1 -1
- package/dist/esm/components/credits/creditsFaq/index.js.map +3 -3
- package/dist/esm/components/credits/creditsInfoCard/index.js +1 -1
- package/dist/esm/components/credits/creditsInfoCard/index.js.map +2 -2
- package/dist/esm/components/credits/creditsMemberPrice/CreditsMemberPrice.js +1 -1
- package/dist/esm/components/credits/creditsMemberPrice/CreditsMemberPrice.js.map +3 -3
- package/dist/esm/components/credits/creditsMemberPrice/MemberPriceItem.js +1 -1
- package/dist/esm/components/credits/creditsMemberPrice/MemberPriceItem.js.map +3 -3
- package/dist/esm/components/credits/creditsMemberPrice/Pagination.d.ts +7 -0
- package/dist/esm/components/credits/creditsMemberPrice/Pagination.js +2 -0
- package/dist/esm/components/credits/creditsMemberPrice/Pagination.js.map +7 -0
- package/dist/esm/components/credits/creditsMemberPrice/type.d.ts +3 -5
- package/dist/esm/components/credits/creditsNavigation/CreditsNavigation.js +1 -1
- package/dist/esm/components/credits/creditsNavigation/CreditsNavigation.js.map +2 -2
- package/dist/esm/components/credits/creditsRedeemList/AddressForm/CountrySelect.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/AddressForm/CountrySelect.js.map +2 -2
- package/dist/esm/components/credits/creditsRedeemList/AddressForm/StateSelect.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/AddressForm/StateSelect.js.map +2 -2
- package/dist/esm/components/credits/creditsRedeemList/AddressForm/index.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/AddressForm/index.js.map +2 -2
- package/dist/esm/components/credits/creditsRedeemList/CreditsRedeemList.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/CreditsRedeemList.js.map +3 -3
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Address.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Address.js.map +3 -3
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Success.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Success.js.map +2 -2
- package/dist/esm/components/credits/creditsRedeemList/RedeemableItem.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemableItem.js.map +3 -3
- package/dist/esm/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js +1 -1
- package/dist/esm/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js.map +3 -3
- package/dist/esm/components/credits/modal/MyRewardsModal.js +1 -1
- package/dist/esm/components/credits/modal/MyRewardsModal.js.map +2 -2
- package/dist/esm/components/credits/modal/activitiesModal.js +1 -1
- package/dist/esm/components/credits/modal/activitiesModal.js.map +3 -3
- package/dist/esm/components/credits/modal/creditsUploadReceiptModal.js +1 -1
- package/dist/esm/components/credits/modal/creditsUploadReceiptModal.js.map +3 -3
- package/dist/esm/components/credits/modal/modalContainer.js +1 -1
- package/dist/esm/components/credits/modal/modalContainer.js.map +3 -3
- package/dist/esm/components/credits/modal/subscribeModal.js +1 -1
- package/dist/esm/components/credits/modal/subscribeModal.js.map +3 -3
- package/dist/esm/components/credits/modal/tip.js +1 -1
- package/dist/esm/components/credits/modal/tip.js.map +3 -3
- package/dist/esm/components/index.d.ts +2 -2
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/index.js.map +2 -2
- package/dist/esm/components/registration/authCodeActivate/index.js +1 -1
- package/dist/esm/components/registration/authCodeActivate/index.js.map +3 -3
- package/dist/esm/components/registration/modalContainer.js +1 -1
- package/dist/esm/components/registration/modalContainer.js.map +3 -3
- package/dist/esm/constants.d.ts +1 -0
- package/dist/esm/constants.js +2 -0
- package/dist/esm/constants.js.map +7 -0
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/templates/Credits.d.ts +15 -1
- package/dist/esm/templates/Credits.js +1 -1
- package/dist/esm/templates/Credits.js.map +3 -3
- package/package.json +3 -3
- package/src/components/credits/context/memberPriceConst.ts +0 -7
- package/src/components/credits/context/memberPriceTypes.ts +1 -26
- package/src/components/credits/context/provider.tsx +14 -0
- package/src/components/credits/context/utils.ts +9 -0
- package/src/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.tsx +43 -40
- package/src/components/credits/creditsBanner/index.tsx +31 -2
- package/src/components/credits/creditsBenefits/BenefitItem.tsx +13 -5
- package/src/components/credits/creditsBenefits/IconInfo.tsx +1 -1
- package/src/components/credits/creditsBenefits/index.tsx +1 -1
- package/src/components/credits/creditsCash/CreditsCash.tsx +1 -1
- package/src/components/credits/creditsCash/RedeemableItem.tsx +25 -7
- package/src/components/credits/creditsCash/type.ts +1 -0
- package/src/components/credits/creditsFaq/faqItem/FaqItem.tsx +25 -23
- package/src/components/credits/creditsFaq/index.tsx +2 -1
- package/src/components/credits/creditsInfoCard/index.tsx +3 -2
- package/src/components/credits/creditsMemberPrice/CreditsMemberPrice.tsx +94 -117
- package/src/components/credits/creditsMemberPrice/MemberPriceItem.tsx +127 -27
- package/src/components/credits/creditsMemberPrice/Pagination.tsx +113 -0
- package/src/components/credits/creditsMemberPrice/type.ts +3 -5
- package/src/components/credits/creditsNavigation/CreditsNavigation.tsx +3 -3
- package/src/components/credits/creditsRedeemList/AddressForm/CountrySelect.tsx +2 -1
- package/src/components/credits/creditsRedeemList/AddressForm/StateSelect.tsx +2 -1
- package/src/components/credits/creditsRedeemList/AddressForm/index.tsx +2 -1
- package/src/components/credits/creditsRedeemList/CreditsRedeemList.tsx +27 -13
- package/src/components/credits/creditsRedeemList/RedeemProductModal/Address.tsx +2 -1
- package/src/components/credits/creditsRedeemList/RedeemProductModal/Success.tsx +2 -1
- package/src/components/credits/creditsRedeemList/RedeemableItem.tsx +3 -2
- package/src/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.tsx +34 -20
- package/src/components/credits/modal/MyRewardsModal.tsx +2 -1
- package/src/components/credits/modal/activitiesModal.tsx +2 -1
- package/src/components/credits/modal/creditsUploadReceiptModal.tsx +2 -1
- package/src/components/credits/modal/modalContainer.tsx +2 -1
- package/src/components/credits/modal/subscribeModal.tsx +2 -1
- package/src/components/credits/modal/tip.tsx +2 -1
- package/src/components/index.ts +2 -2
- package/src/components/registration/authCodeActivate/index.tsx +1 -1
- package/src/components/registration/modalContainer.tsx +2 -1
- package/src/constants.ts +1 -0
- package/src/index.ts +3 -2
- package/src/templates/Credits.tsx +26 -9
- package/src/components/credits/context/hooks/useFunctionMemberPrice.ts +0 -33
- package/src/components/credits/context/utils/atobID.ts +0 -8
- package/src/components/credits/context/utils/functionDiscountCalculate.ts +0 -57
- package/src/components/credits/context/utils/getFunctionMemberPrice.ts +0 -135
- package/src/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.ts +0 -51
- package/src/components/credits/context/utils/variantGetCoupon.ts +0 -34
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { default as Chat } from './chat/index'\n\nexport {\n Role,\n ActionExecutionMessage,\n TextMessage,\n useCopilotChat,\n useCopilotAction,\n useCopilotReadable,\n} from './chat/utils'\n\nexport * from './credits/index'\n\nexport * from './registration/index'\n"],
|
|
5
|
-
"mappings": "wmBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+PAAAE,EAAAF,GAAA,IAAAG,EAAgC,2BAEhCC,EAOO,wBAEPC,EAAAL,EAAc,
|
|
4
|
+
"sourcesContent": ["export { default as Chat } from './chat/index'\n\nexport {\n Role,\n ActionExecutionMessage,\n TextMessage,\n useCopilotChat,\n useCopilotAction,\n useCopilotReadable,\n} from './chat/utils'\n\nexport * from './credits/index.js'\n\nexport * from './registration/index.js'\n"],
|
|
5
|
+
"mappings": "wmBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+PAAAE,EAAAF,GAAA,IAAAG,EAAgC,2BAEhCC,EAOO,wBAEPC,EAAAL,EAAc,8BAXd,gBAaAK,EAAAL,EAAc,mCAbd",
|
|
6
6
|
"names": ["components_exports", "__export", "__toCommonJS", "import_chat", "import_utils", "__reExport"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty;var
|
|
1
|
+
"use strict";var k=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var y=(e,i)=>{for(var m in i)k(e,m,{get:i[m],enumerable:!0})},ee=(e,i,m,l)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of Y(i))!Z.call(e,r)&&r!==m&&k(e,r,{get:()=>i[r],enumerable:!(l=X(i,r))||l.enumerable});return e};var te=e=>ee(k({},"__esModule",{value:!0}),e);var se={};y(se,{AuthCodeActivate:()=>ae});module.exports=te(se);var a=require("react/jsx-runtime"),c=require("@anker-in/headless-ui"),o=require("@anker-in/lib"),n=require("react"),V=require("./Message"),B=require("../context"),$=require("../modalContainer"),F=require("../../../constants");const ae=({copy:e})=>{const{locale:i,brand:m}=(0,o.useHeadlessContext)(),{email:l,authCodeActivate:r}=(0,B.useRegistration)(),O=F.ROUNDED_BRANDS.includes(m),{activeToken:E,setActiveToken:P,setIsSendingActivateEmail:D,setIsActivateSuccess:j,onAuthSuccess:v,autoSendEmail:I}=r,{isMutating:z,trigger:K}=(0,o.useEmailValidation)(),{isMutating:N,trigger:C,data:w}=(0,o.useSendEmailValidation)(),[U,g]=(0,n.useState)(""),[q,f]=(0,n.useState)(""),{startCountDown:R,startAction:H,countDown:G}=(0,o.useCountDown)(60),[L,p]=(0,n.useState)(""),[S,b]=(0,n.useState)(0),[u,T]=(0,n.useState)(new Array(6).fill("")),A=(0,n.useRef)([]),_=u.join("");(0,n.useEffect)(()=>{A.current[S]&&A.current[S].focus()},[S]),(0,n.useEffect)(()=>{w?.data?.data?.active_token&&P(w.data.data.active_token)},[w?.data?.data?.active_token]),(0,n.useEffect)(()=>{D(N)},[N,D]),(0,n.useEffect)(()=>{I&&l&&C({email:l,data:{redirect_url:`${window?.location?.origin}${window?.location?.pathname}`}},{onSuccess:()=>{f("success"),g(e?.sendEmailSuccessMessage||""),H(),setTimeout(()=>{f(""),g("")},5e3)}})},[I,l,C]);const J=(0,n.useCallback)(async()=>{l&&(await C({email:l,data:{redirect_url:`${window?.location?.origin}${window?.location?.pathname}`}},{onSuccess:()=>{f("success"),g(e?.sendEmailSuccessMessage||""),H(),setTimeout(()=>{f(""),g("")},5e3)}}),(0,o.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{page_group:"reg_sub_pop",position:"auth_code",button_name:"sent_again"}}))},[l,C]),Q=(x,t)=>{const{value:s}=x.target;if(p(""),Number.isNaN(Number(s)))return;if(s.length>1){t<u.length-1&&(u[t+1]||(b(t+1),T(h=>{const M=[...h];return M[t]=s[0],s.length>1&&(M[t+1]=s[1]),M})));return}const d=[...u];d[t]=s,T(d),s?t<u.length-1&&!u[t+1]&&b(t+1):t>0&&b(t-1)},W=(0,n.useCallback)(async()=>{if(!_?.length){p(e?.codeEmptyError||"");return}if(_.length<6){p(e?.incorrectCodeError||"");return}E&&await K({token:E,code:_},{onSuccess:t=>{t.status>=200&&t.status<300?(f("success"),g(e?.authSuccessMessage||""),j(!0),v?v():setTimeout(()=>{r.close()},3e3)):t?.data?.error_code==="104"?v?v():setTimeout(()=>{r.close()},3e3):t?.data?.error_code==="142"?p(e?.incorrectCodeError||"Invalid verification code."):t?.data?.error_code==="154"?p(e?.expiredCodeMessage||""):p(e?.sendEmailErrorMessage||"")}});let x=setTimeout(()=>{f(""),g(""),clearTimeout(x)},5e3);(0,o.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{page_group:"reg_sub_pop",position:"auth_code",button_name:"check_and_active"}})},[_,e?.codeEmptyError,e?.authSuccessMessage,e?.incorrectCodeError,e?.expiredCodeMessage,e?.sendEmailErrorMessage,i,E]);return(0,a.jsx)($.RegistrationModalContainer,{isOpen:r.isOpen,onClose:r.close,children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(c.Text,{className:"text-[22px] font-extrabold leading-[120%] text-[#333] min-l:text-[24px] [&_abbr]:text-[#005d8e]",html:e?.authCodeTitle}),(0,a.jsx)(c.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%",l||"")})]}),(0,a.jsxs)("div",{className:"mt-6",children:[(0,a.jsx)(c.Text,{className:"mt-4 text-[14px] !font-bold font-semibold leading-[140%] text-[#333] min-l:mt-6",html:e?.enterActiveCodeText}),(0,a.jsx)("div",{className:"my-3 grid grid-cols-6 gap-2",children:u.map((x,t)=>(0,a.jsx)("div",{className:"col-span-1 aspect-1 text-[#555]",children:(0,a.jsx)("input",{ref:s=>{s&&(A.current[t]=s)},type:"tel",className:(0,o.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",O&&"rounded-[12px]"),value:x,autoComplete:"false",autoCorrect:"false",spellCheck:"false",autoCapitalize:"false",onChange:s=>Q(s,t),onFocus:()=>{b(t)},onPaste:s=>{const d=s.clipboardData.getData("text");if(!Number.isNaN(Number(d))){const h=d.split("").slice(0,6);T(h.concat(Array(6-h.length).fill(""))),h.length<=u.length&&b(h.length-1)}},onKeyDown:s=>{const{value:d}=s.target;s.key==="Backspace"&&!d&&t>0&&b(t-1)}},t)},t))}),L&&(0,a.jsx)(c.Text,{className:"mb-3 text-[14px] font-semibold leading-[120%] text-[#f84d4f]",html:L}),e?.authCodeContent&&(0,a.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,a.jsxs)("div",{className:"mt-4 min-l:mt-6",children:[(0,a.jsx)(c.Text,{className:"text-base font-semibold leading-[100%] text-[#333]",html:e?.authCodeReceiveText})," ",R?(0,a.jsx)(c.Text,{html:e?.retrieveText?.replace("%countdownTime%",G.toString()),className:"cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline"}):(0,a.jsx)(c.Text,{onClick:J,className:(0,o.classNames)("cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline",{"pointer-events-none":R||N}),html:e?.sendAgainText}),(0,a.jsx)(c.Button,{type:"submit",loading:z,className:"mt-6 flex h-[54px] w-full cursor-pointer items-center justify-center px-8 py-[15px] text-center text-base font-bold leading-[100%] text-white min-l:mt-8",onClick:W,children:e.buttonText})]}),(0,a.jsx)(V.Message,{status:q,message:U})]})})};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/registration/authCodeActivate/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Button, Text } from '@anker-in/headless-ui'\nimport {\n useSendEmailValidation,\n gaTrack,\n classNames as cn,\n useHeadlessContext,\n useEmailValidation,\n useCountDown,\n ROUNDED_BRANDS,\n} from '@anker-in/lib'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { Message } from './Message'\nimport { AuthCodeActivateProps } from './type'\nimport { useRegistration } from '../context'\nimport { RegistrationModalContainer } from '../modalContainer'\n\nexport const AuthCodeActivate: React.FC<AuthCodeActivateProps> = ({ copy }) => {\n const { locale, brand } = useHeadlessContext()\n const { email, authCodeActivate } = useRegistration()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const { activeToken, setActiveToken, setIsSendingActivateEmail, setIsActivateSuccess, onAuthSuccess, autoSendEmail } =\n authCodeActivate\n\n const { isMutating: emailValidationLoading, trigger: triggerEmailValidation } = useEmailValidation()\n\n const {\n isMutating: isSendingEmail,\n trigger: triggerSendValidationEmail,\n data: sendEmailData,\n } = useSendEmailValidation()\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 (sendEmailData?.data?.data?.active_token) {\n setActiveToken(sendEmailData.data.data.active_token)\n }\n }, [sendEmailData?.data?.data?.active_token])\n\n useEffect(() => {\n setIsSendingActivateEmail(isSendingEmail)\n }, [isSendingEmail, setIsSendingActivateEmail])\n\n // \u81EA\u52A8\u53D1\u9001\u90AE\u7BB1\u9A8C\u8BC1\u7801\n useEffect(() => {\n if (autoSendEmail && 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 }, [autoSendEmail, email, triggerSendValidationEmail])\n\n const handleSendAgain = useCallback(async () => {\n if (!email) return\n // \u53D1\u8D77\u7F51\u7EDC\u8BF7\u6C42\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 if (activeToken) {\n await triggerEmailValidation(\n {\n token: activeToken,\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 (onAuthSuccess) {\n onAuthSuccess()\n } else {\n setTimeout(() => {\n authCodeActivate.close()\n }, 3000)\n }\n } else {\n if (data?.data?.error_code === '104') {\n if (onAuthSuccess) {\n onAuthSuccess()\n } else {\n setTimeout(() => {\n authCodeActivate.close()\n }, 3000)\n }\n } else if (data?.data?.error_code === '142') {\n setError(copy?.incorrectCodeError || 'Invalid verification code.')\n } else if (data?.data?.error_code === '154') {\n setError(copy?.expiredCodeMessage || '')\n } else {\n setError(copy?.sendEmailErrorMessage || '')\n }\n }\n },\n }\n )\n }\n\n // \u8BBE\u7F6E\u5B9A\u65F6\u5668\u6E05\u9664\u72B6\u6001\u4FE1\u606F\n let timer = setTimeout(() => {\n setMessageStatus('')\n setMessageText('')\n clearTimeout(timer)\n }, 5000)\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: 'check_and_active',\n },\n })\n }, [\n code,\n copy?.codeEmptyError,\n copy?.authSuccessMessage,\n copy?.incorrectCodeError,\n copy?.expiredCodeMessage,\n copy?.sendEmailErrorMessage,\n locale,\n activeToken,\n ])\n\n return (\n <RegistrationModalContainer isOpen={authCodeActivate.isOpen} onClose={authCodeActivate.close}>\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 flex h-[54px] w-full cursor-pointer items-center justify-center px-8 py-[15px] text-center text-base font-bold leading-[100%] text-white min-l:mt-8\"\n onClick={handleAuthCodeSubmit}\n >\n {copy.buttonText}\n </Button>\n </div>\n <Message status={messageStatus} message={messageText} />\n </div>\n </RegistrationModalContainer>\n )\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["authCodeActivate_exports", "__export", "AuthCodeActivate", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_lib", "import_react", "import_Message", "import_context", "import_modalContainer", "copy", "locale", "brand", "email", "authCodeActivate", "rounded", "activeToken", "setActiveToken", "setIsSendingActivateEmail", "setIsActivateSuccess", "onAuthSuccess", "autoSendEmail", "emailValidationLoading", "triggerEmailValidation", "isSendingEmail", "triggerSendValidationEmail", "sendEmailData", "messageText", "setMessageText", "messageStatus", "setMessageStatus", "isStartCountDown", "startCountDown", "countDown", "error", "setError", "focusIndex", "setFocusIndex", "codeArray", "setCodeArray", "inputRefs", "code", "handleSendAgain", "handleInputCodeChange", "event", "index", "value", "old", "newCode", "handleAuthCodeSubmit", "data", "timer", "item", "inputRef", "cn", "paste", "pastedCode"]
|
|
4
|
+
"sourcesContent": ["import { Button, Text } from '@anker-in/headless-ui'\nimport {\n useSendEmailValidation,\n gaTrack,\n classNames as cn,\n useHeadlessContext,\n useEmailValidation,\n useCountDown,\n} from '@anker-in/lib'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { Message } from './Message'\nimport { AuthCodeActivateProps } from './type'\nimport { useRegistration } from '../context'\nimport { RegistrationModalContainer } from '../modalContainer'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\nexport const AuthCodeActivate: React.FC<AuthCodeActivateProps> = ({ copy }) => {\n const { locale, brand } = useHeadlessContext()\n const { email, authCodeActivate } = useRegistration()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const { activeToken, setActiveToken, setIsSendingActivateEmail, setIsActivateSuccess, onAuthSuccess, autoSendEmail } =\n authCodeActivate\n\n const { isMutating: emailValidationLoading, trigger: triggerEmailValidation } = useEmailValidation()\n\n const {\n isMutating: isSendingEmail,\n trigger: triggerSendValidationEmail,\n data: sendEmailData,\n } = useSendEmailValidation()\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 (sendEmailData?.data?.data?.active_token) {\n setActiveToken(sendEmailData.data.data.active_token)\n }\n }, [sendEmailData?.data?.data?.active_token])\n\n useEffect(() => {\n setIsSendingActivateEmail(isSendingEmail)\n }, [isSendingEmail, setIsSendingActivateEmail])\n\n // \u81EA\u52A8\u53D1\u9001\u90AE\u7BB1\u9A8C\u8BC1\u7801\n useEffect(() => {\n if (autoSendEmail && 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 }, [autoSendEmail, email, triggerSendValidationEmail])\n\n const handleSendAgain = useCallback(async () => {\n if (!email) return\n // \u53D1\u8D77\u7F51\u7EDC\u8BF7\u6C42\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 if (activeToken) {\n await triggerEmailValidation(\n {\n token: activeToken,\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 (onAuthSuccess) {\n onAuthSuccess()\n } else {\n setTimeout(() => {\n authCodeActivate.close()\n }, 3000)\n }\n } else {\n if (data?.data?.error_code === '104') {\n if (onAuthSuccess) {\n onAuthSuccess()\n } else {\n setTimeout(() => {\n authCodeActivate.close()\n }, 3000)\n }\n } else if (data?.data?.error_code === '142') {\n setError(copy?.incorrectCodeError || 'Invalid verification code.')\n } else if (data?.data?.error_code === '154') {\n setError(copy?.expiredCodeMessage || '')\n } else {\n setError(copy?.sendEmailErrorMessage || '')\n }\n }\n },\n }\n )\n }\n\n // \u8BBE\u7F6E\u5B9A\u65F6\u5668\u6E05\u9664\u72B6\u6001\u4FE1\u606F\n let timer = setTimeout(() => {\n setMessageStatus('')\n setMessageText('')\n clearTimeout(timer)\n }, 5000)\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: 'check_and_active',\n },\n })\n }, [\n code,\n copy?.codeEmptyError,\n copy?.authSuccessMessage,\n copy?.incorrectCodeError,\n copy?.expiredCodeMessage,\n copy?.sendEmailErrorMessage,\n locale,\n activeToken,\n ])\n\n return (\n <RegistrationModalContainer isOpen={authCodeActivate.isOpen} onClose={authCodeActivate.close}>\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 flex h-[54px] w-full cursor-pointer items-center justify-center px-8 py-[15px] text-center text-base font-bold leading-[100%] text-white min-l:mt-8\"\n onClick={handleAuthCodeSubmit}\n >\n {copy.buttonText}\n </Button>\n </div>\n <Message status={messageStatus} message={messageText} />\n </div>\n </RegistrationModalContainer>\n )\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["authCodeActivate_exports", "__export", "AuthCodeActivate", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_lib", "import_react", "import_Message", "import_context", "import_modalContainer", "import_constants", "copy", "locale", "brand", "email", "authCodeActivate", "rounded", "activeToken", "setActiveToken", "setIsSendingActivateEmail", "setIsActivateSuccess", "onAuthSuccess", "autoSendEmail", "emailValidationLoading", "triggerEmailValidation", "isSendingEmail", "triggerSendValidationEmail", "sendEmailData", "messageText", "setMessageText", "messageStatus", "setMessageStatus", "isStartCountDown", "startCountDown", "countDown", "error", "setError", "focusIndex", "setFocusIndex", "codeArray", "setCodeArray", "inputRefs", "code", "handleSendAgain", "handleInputCodeChange", "event", "index", "value", "old", "newCode", "handleAuthCodeSubmit", "data", "timer", "item", "inputRef", "cn", "paste", "pastedCode"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var N=Object.create;var d=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var H=(e,t)=>{for(var n in t)d(e,n,{get:t[n],enumerable:!0})},f=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of R(t))!D.call(e,o)&&o!==n&&d(e,o,{get:()=>t[o],enumerable:!(r=M(t,o))||r.enumerable});return e};var k=(e,t,n)=>(n=e!=null?N(E(e)):{},f(t||!e||!e.__esModule?d(n,"default",{value:e,enumerable:!0}):n,e)),S=e=>f(d({},"__esModule",{value:!0}),e);var I={};H(I,{RegistrationModalContainer:()=>Z});module.exports=S(I);var l=require("react/jsx-runtime"),i=require("@anker-in/lib"),m=require("react"),v=k(require("react-modal")),C=require("../../constants");const Z=({isOpen:e,title:t,className:n="",overlayClassName:r="",scrollClassName:o="",onClose:c,onScrollEnd:x,children:u,useAnimation:p=!0,titleClassName:h="",...L})=>{const{brand:g}=(0,i.useHeadlessContext)(),w=C.ROUNDED_BRANDS.includes(g),[b,y]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{p&&requestAnimationFrame(()=>{y(e??!1)})},[e,p]),(0,l.jsxs)(v.default,{isOpen:e??!1,overlayClassName:(0,i.classNames)("fixed inset-0 z-[999] flex items-center justify-center bg-black/70 leading-[1.2] md:items-end",r),className:(0,i.classNames)("min-md:max-h-[calc(100vh-96px)] w-[540px] relative flex min-h-[200px] flex-col overflow-hidden bg-white outline-none transition-all duration-300 md:h-auto md:w-full",w&&"rounded-[16px] md:rounded-b-none",p&&"md:translate-y-[100vh]",b&&"md:translate-y-0",n),onRequestClose:c,...L,children:[(0,l.jsxs)("div",{className:(0,i.classNames)("flex w-full shrink-0 items-center justify-between",t?"min-l:px-[32px] h-[70px] border-b border-[#e2e2e2] px-[24px]":"h-[48px] px-[16px]",h),children:[(0,l.jsx)("div",{className:"text-[18px] font-bold",children:t}),(0,l.jsx)("div",{className:"size-[22px] cursor-pointer",onClick:c,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),c?.())},role:"button",tabIndex:0,children:(0,l.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",viewBox:"0 0 22 22",fill:"none",children:(0,l.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.8525 5.31015C16.4558 4.91337 15.8125 4.91338 15.4157 5.31015L11.1268 9.5991L6.83815 5.31049C6.44138 4.91372 5.79808 4.91372 5.40131 5.31049C5.00454 5.70726 5.00455 6.35055 5.40131 6.74732L9.68993 11.0359L5.40105 15.3248C5.00428 15.7216 5.00428 16.3649 5.40105 16.7616C5.79782 17.1584 6.44111 17.1584 6.83788 16.7616L11.1268 12.4728L15.416 16.762C15.8128 17.1588 16.456 17.1588 16.8528 16.762C17.2496 16.3652 17.2496 15.7219 16.8528 15.3252L12.5636 11.0359L16.8525 6.74698C17.2493 6.35021 17.2493 5.70692 16.8525 5.31015ZM16.921 6.02856C16.921 6.22992 16.8441 6.43127 16.6905 6.5849L14.465 8.8104L12.2395 11.0359L12.2395 11.0359L16.6905 6.58493C16.8441 6.43129 16.921 6.22993 16.921 6.02856ZM5.34966 6.19087C5.37992 6.3354 5.45115 6.47307 5.56336 6.58528L10.014 11.0359L10.014 11.0359L5.56336 6.58524C5.45116 6.47304 5.37992 6.33539 5.34966 6.19087ZM5.35087 16.2121C5.38193 16.3541 5.45267 16.4891 5.56309 16.5996C5.87037 16.9068 6.36856 16.9068 6.67583 16.5996L11.1268 12.1486L15.578 16.5999C15.8853 16.9072 16.3835 16.9072 16.6908 16.5999C16.8498 16.4409 16.9265 16.2307 16.9209 16.0223C16.9265 16.2307 16.8498 16.4409 16.6908 16.5999C16.3835 16.9072 15.8853 16.9072 15.578 16.5999L11.1268 12.1487L6.67583 16.5996C6.36856 16.9069 5.87037 16.9069 5.56309 16.5996C5.45267 16.4892 5.38192 16.3541 5.35087 16.2121Z",fill:"#333333"})})})]}),(0,l.jsx)("div",{className:(0,i.classNames)("my-[32px] flex-1 overflow-auto overscroll-contain px-[24px] md:mb-[48px]",!t&&"mt-0","min-l:px-[32px]",o),onScroll:a=>{const s=a.target;s.scrollHeight<=s.clientHeight||s.scrollTop+s.clientHeight>=s.scrollHeight-50&&x&&x(a)},children:u})]})};
|
|
2
2
|
//# sourceMappingURL=modalContainer.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/registration/modalContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["import { classNames as cn, useHeadlessContext
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["modalContainer_exports", "__export", "RegistrationModalContainer", "__toCommonJS", "import_jsx_runtime", "import_lib", "import_react", "import_react_modal", "isOpen", "title", "className", "overlayClassName", "scrollClassName", "onClose", "onScrollEnd", "children", "useAnimation", "titleClassName", "props", "brand", "rounded", "animationShow", "setAnimationShow", "ReactModal", "cn", "e", "event", "targetElement"]
|
|
4
|
+
"sourcesContent": ["import { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useEffect, useState, type UIEvent } from 'react'\nimport ReactModal from 'react-modal'\nimport { ROUNDED_BRANDS } from '../../constants'\n\nexport type ModalContainerProps = {\n overlayClassName?: string\n className?: string\n scrollClassName?: string\n title?: string\n titleClassName?: string\n useAnimation?: boolean // \u4F7F\u7528\u52A8\u753B\u5C55\u793A\n isOpen: boolean\n children?: any\n onClose: () => void\n onScrollEnd?: (event: UIEvent<HTMLDivElement>) => void\n}\n\nexport const RegistrationModalContainer = ({\n isOpen,\n title,\n className = '',\n overlayClassName = '',\n scrollClassName = '',\n onClose,\n onScrollEnd,\n children,\n useAnimation = true,\n titleClassName = '',\n ...props\n}: ModalContainerProps): React.ReactElement => {\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const [animationShow, setAnimationShow] = useState(false)\n\n useEffect(() => {\n if (!useAnimation) {\n return\n }\n requestAnimationFrame(() => {\n setAnimationShow(isOpen ?? false)\n })\n }, [isOpen, useAnimation])\n\n return (\n <ReactModal\n isOpen={isOpen ?? false}\n overlayClassName={cn(\n 'fixed inset-0 z-[999] flex items-center justify-center bg-black/70 leading-[1.2] md:items-end',\n overlayClassName\n )}\n className={cn(\n 'min-md:max-h-[calc(100vh-96px)] w-[540px] relative flex min-h-[200px] flex-col overflow-hidden bg-white outline-none transition-all duration-300 md:h-auto md:w-full',\n rounded && 'rounded-[16px] md:rounded-b-none',\n useAnimation && 'md:translate-y-[100vh]',\n animationShow && 'md:translate-y-0',\n className\n )}\n onRequestClose={onClose}\n {...props}\n >\n <div\n className={cn(\n 'flex w-full shrink-0 items-center justify-between',\n title ? 'min-l:px-[32px] h-[70px] border-b border-[#e2e2e2] px-[24px]' : 'h-[48px] px-[16px]',\n titleClassName\n )}\n >\n <div className=\"text-[18px] font-bold\">{title}</div>\n <div\n className=\"size-[22px] cursor-pointer\"\n onClick={onClose}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n onClose?.()\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"22\" height=\"22\" viewBox=\"0 0 22 22\" fill=\"none\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M16.8525 5.31015C16.4558 4.91337 15.8125 4.91338 15.4157 5.31015L11.1268 9.5991L6.83815 5.31049C6.44138 4.91372 5.79808 4.91372 5.40131 5.31049C5.00454 5.70726 5.00455 6.35055 5.40131 6.74732L9.68993 11.0359L5.40105 15.3248C5.00428 15.7216 5.00428 16.3649 5.40105 16.7616C5.79782 17.1584 6.44111 17.1584 6.83788 16.7616L11.1268 12.4728L15.416 16.762C15.8128 17.1588 16.456 17.1588 16.8528 16.762C17.2496 16.3652 17.2496 15.7219 16.8528 15.3252L12.5636 11.0359L16.8525 6.74698C17.2493 6.35021 17.2493 5.70692 16.8525 5.31015ZM16.921 6.02856C16.921 6.22992 16.8441 6.43127 16.6905 6.5849L14.465 8.8104L12.2395 11.0359L12.2395 11.0359L16.6905 6.58493C16.8441 6.43129 16.921 6.22993 16.921 6.02856ZM5.34966 6.19087C5.37992 6.3354 5.45115 6.47307 5.56336 6.58528L10.014 11.0359L10.014 11.0359L5.56336 6.58524C5.45116 6.47304 5.37992 6.33539 5.34966 6.19087ZM5.35087 16.2121C5.38193 16.3541 5.45267 16.4891 5.56309 16.5996C5.87037 16.9068 6.36856 16.9068 6.67583 16.5996L11.1268 12.1486L15.578 16.5999C15.8853 16.9072 16.3835 16.9072 16.6908 16.5999C16.8498 16.4409 16.9265 16.2307 16.9209 16.0223C16.9265 16.2307 16.8498 16.4409 16.6908 16.5999C16.3835 16.9072 15.8853 16.9072 15.578 16.5999L11.1268 12.1487L6.67583 16.5996C6.36856 16.9069 5.87037 16.9069 5.56309 16.5996C5.45267 16.4892 5.38192 16.3541 5.35087 16.2121Z\"\n fill=\"#333333\"\n />\n </svg>\n </div>\n </div>\n <div\n className={cn(\n 'my-[32px] flex-1 overflow-auto overscroll-contain px-[24px] md:mb-[48px]',\n !title && 'mt-0',\n 'min-l:px-[32px]',\n scrollClassName\n )}\n onScroll={event => {\n const targetElement = event.target as HTMLDivElement\n\n if (targetElement.scrollHeight <= targetElement.clientHeight) {\n return\n }\n\n if (targetElement.scrollTop + targetElement.clientHeight >= targetElement.scrollHeight - 50) {\n onScrollEnd && onScrollEnd(event)\n }\n }}\n >\n {children}\n </div>\n </ReactModal>\n )\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,IAAA,eAAAC,EAAAH,GA6DM,IAAAI,EAAA,6BA7DNC,EAAqD,yBACrDC,EAAkD,iBAClDC,EAAuB,0BACvBC,EAA+B,2BAexB,MAAMN,EAA6B,CAAC,CACzC,OAAAO,EACA,MAAAC,EACA,UAAAC,EAAY,GACZ,iBAAAC,EAAmB,GACnB,gBAAAC,EAAkB,GAClB,QAAAC,EACA,YAAAC,EACA,SAAAC,EACA,aAAAC,EAAe,GACf,eAAAC,EAAiB,GACjB,GAAGC,CACL,IAA+C,CAC7C,KAAM,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CAAK,EACvC,CAACE,EAAeC,CAAgB,KAAI,YAAS,EAAK,EAExD,sBAAU,IAAM,CACTN,GAGL,sBAAsB,IAAM,CAC1BM,EAAiBd,GAAU,EAAK,CAClC,CAAC,CACH,EAAG,CAACA,EAAQQ,CAAY,CAAC,KAGvB,QAAC,EAAAO,QAAA,CACC,OAAQf,GAAU,GAClB,oBAAkB,EAAAgB,YAChB,gGACAb,CACF,EACA,aAAW,EAAAa,YACT,uKACAJ,GAAW,mCACXJ,GAAgB,yBAChBK,GAAiB,mBACjBX,CACF,EACA,eAAgBG,EACf,GAAGK,EAEJ,qBAAC,OACC,aAAW,EAAAM,YACT,oDACAf,EAAQ,+DAAiE,qBACzEQ,CACF,EAEA,oBAAC,OAAI,UAAU,wBAAyB,SAAAR,EAAM,KAC9C,OAAC,OACC,UAAU,6BACV,QAASI,EACT,UAAWY,GAAK,EACVA,EAAE,MAAQ,SAAWA,EAAE,MAAQ,OACjCA,EAAE,eAAe,EACjBZ,IAAU,EAEd,EACA,KAAK,SACL,SAAU,EAEV,mBAAC,OAAI,MAAM,6BAA6B,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACtF,mBAAC,QACC,SAAS,UACT,SAAS,UACT,EAAE,syCACF,KAAK,UACP,EACF,EACF,GACF,KACA,OAAC,OACC,aAAW,EAAAW,YACT,2EACA,CAACf,GAAS,OACV,kBACAG,CACF,EACA,SAAUc,GAAS,CACjB,MAAMC,EAAgBD,EAAM,OAExBC,EAAc,cAAgBA,EAAc,cAI5CA,EAAc,UAAYA,EAAc,cAAgBA,EAAc,aAAe,IACvFb,GAAeA,EAAYY,CAAK,CAEpC,EAEC,SAAAX,EACH,GACF,CAEJ",
|
|
6
|
+
"names": ["modalContainer_exports", "__export", "RegistrationModalContainer", "__toCommonJS", "import_jsx_runtime", "import_lib", "import_react", "import_react_modal", "import_constants", "isOpen", "title", "className", "overlayClassName", "scrollClassName", "onClose", "onScrollEnd", "children", "useAnimation", "titleClassName", "props", "brand", "rounded", "animationShow", "setAnimationShow", "ReactModal", "cn", "e", "event", "targetElement"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ROUNDED_BRANDS: string[];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var t=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var N=(e,o)=>{for(var c in o)n(e,c,{get:o[c],enumerable:!0})},R=(e,o,c,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let D of t(o))!u.call(e,D)&&D!==c&&n(e,D,{get:()=>o[D],enumerable:!(r=s(o,D))||r.enumerable});return e};var d=e=>R(n({},"__esModule",{value:!0}),e);var p={};N(p,{ROUNDED_BRANDS:()=>f});module.exports=d(p);const f=["eufy","soundcore"];
|
|
2
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/constants.ts"],
|
|
4
|
+
"sourcesContent": ["export const ROUNDED_BRANDS = ['eufy', 'soundcore']\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAAO,MAAME,EAAiB,CAAC,OAAQ,WAAW",
|
|
6
|
+
"names": ["constants_exports", "__export", "ROUNDED_BRANDS", "__toCommonJS"]
|
|
7
|
+
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from './components';
|
|
2
|
-
export * from './templates';
|
|
1
|
+
export * from './components/index.js';
|
|
2
|
+
export * from './templates/index.js';
|
|
3
|
+
export * from './constants.js';
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(r,
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,r,p,x)=>{if(r&&typeof r=="object"||typeof r=="function")for(let m of c(r))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>r[m],enumerable:!(x=b(r,m))||x.enumerable});return f},e=(f,r,p)=>(t(f,r,"default"),p&&t(p,r,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);e(o,require("./components/index.js"),module.exports);e(o,require("./templates/index.js"),module.exports);e(o,require("./constants.js"),module.exports);
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './components'\nexport * from './templates'\n"],
|
|
5
|
-
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,
|
|
4
|
+
"sourcesContent": ["export * from './components/index.js'\nexport * from './templates/index.js'\nexport * from './constants.js'\n"],
|
|
5
|
+
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,iCAAd,gBACAE,EAAAF,EAAc,gCADd,gBAEAE,EAAAF,EAAc,0BAFd",
|
|
6
6
|
"names": ["src_exports", "__toCommonJS", "__reExport"]
|
|
7
7
|
}
|
|
@@ -69,5 +69,19 @@ export type CreditsTemplateProps = {
|
|
|
69
69
|
gtm: {
|
|
70
70
|
pageGroup: string;
|
|
71
71
|
};
|
|
72
|
+
cartConfig?: {
|
|
73
|
+
addToCart: (params: {
|
|
74
|
+
variantList: Array<{
|
|
75
|
+
variant: any;
|
|
76
|
+
quantity: number;
|
|
77
|
+
attributes?: Array<{
|
|
78
|
+
key: string;
|
|
79
|
+
value: string;
|
|
80
|
+
}>;
|
|
81
|
+
}>;
|
|
82
|
+
cartAttributes?: Record<string, string>;
|
|
83
|
+
discountCodes?: string[];
|
|
84
|
+
}) => void | Promise<any>;
|
|
85
|
+
};
|
|
72
86
|
};
|
|
73
|
-
export declare const CreditsTemplate: ({ headlessConfig, siteConfig, creditsConfig, userContext, pageConfig, registrationContext, gtm, }: CreditsTemplateProps) => import("react/jsx-runtime").JSX.Element;
|
|
87
|
+
export declare const CreditsTemplate: ({ headlessConfig, siteConfig, creditsConfig, userContext, pageConfig, registrationContext, gtm, cartConfig, }: CreditsTemplateProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var C=Object.defineProperty;var
|
|
1
|
+
"use strict";var C=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var N=(s,i)=>{for(var d in i)C(s,d,{get:i[d],enumerable:!0})},S=(s,i,d,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of F(i))!M.call(s,t)&&t!==d&&C(s,t,{get:()=>i[t],enumerable:!(r=K(i,t))||r.enumerable});return s};var x=s=>S(C({},"__esModule",{value:!0}),s);var q={};N(q,{ComponentKey:()=>B,CreditsTemplate:()=>R});module.exports=x(q);var o=require("react/jsx-runtime"),p=require("@anker-in/lib"),c=require("../components/registration/context/provider"),f=require("../components/credits/context/provider"),y=require("../components/credits/creditsBanner"),l=require("../components/credits/creditsInfoCard"),g=require("../components/credits/creditsBenefits"),P=require("../components/credits/creditsWaysToGetCredits"),T=require("../components/credits/creditsAnkersolixTask"),v=require("../components/credits/creditsRedeemList"),u=require("../components/credits/creditsCash"),b=require("../components/credits/creditsMemberPrice"),h=require("../components/credits/creditsFaq"),A=require("../components/credits/creditsNavigation"),B=(a=>(a.Navigation="creditsNavigation",a.Banner="creditsBanner",a.InfoCard="creditsInfoCard",a.Benefits="creditsBenefits",a.WaysToGetCredits="creditsWaysToGetCredits",a.AnkersolixTask="creditsAnkersolixTask",a.RedeemList="creditsRedeemList",a.SpendCreditsLikeCash="creditsCash",a.MemberPrice="creditsMemberPrice",a.Faqs="creditsFaq",a))(B||{});const R=({headlessConfig:s,siteConfig:i,creditsConfig:d,userContext:r,pageConfig:t,registrationContext:m,gtm:I,cartConfig:L})=>(console.log("siteConfig",i),(0,o.jsx)(p.HeadlessProvider,{headlessConfig:s,children:(0,o.jsx)(c.RegistrationProvider,{copy:i.registrationsSettings,email:r?.profile?.email,children:(0,o.jsxs)(f.CreditsProvider,{profile:r?.profile,removeProfile:r?.removeProfile,isLoadingProfile:r?.isLoadingProfile,openSignInPopup:m.openSignInPopup,openSignUpPopup:m.openSignUpPopup,creditInfo:r?.creditInfo,taskIdToTypeMapping:i.taskIdToTypeMapping,customer:r?.customer,fetchCreditInfo:r?.fetchCreditInfo,customerLoading:r?.customerLoading,gtm:I,pageCommon:t.common,memberPriceDiscount:i.memberPriceDiscount,alpcBrand:d?.alpcBrand,cartConfig:L,children:[t.components.creditsNavigation&&(0,o.jsx)(A.CreditsNavigation,{copy:t.components.creditsNavigation}),(0,o.jsx)("div",{className:(0,p.classNames)("bg-[#f5f5f7] leading-[1.2]"),children:t.order.map(e=>{if(e==="creditsNavigation")return null;const n=t.components?.[e];return n?(0,o.jsxs)(o.Fragment,{children:[e==="creditsBanner"&&(0,o.jsx)(y.CreditsBanner,{copy:n,id:e}),e==="creditsInfoCard"&&r?.profile&&(0,o.jsx)(l.CreditsInfoCard,{copy:n,id:e}),e==="creditsBenefits"&&(0,o.jsx)(g.CreditsBenefits,{copy:n,id:e}),e==="creditsWaysToGetCredits"&&(0,o.jsx)(P.CreditsWaysToGetCredits,{copy:n,id:e,classNames:s.brand==="anker"?{subtitle:"text-white",equalCreditsText:"bg-gradient-to-r from-[#3AD1FF] to-[#008CD6] bg-clip-text text-transparent"}:{subtitle:"text-[#D1D1D1]",equalCreditsText:"text-[#F6EAD0]"}}),e==="creditsAnkersolixTask"&&(0,o.jsx)(T.CreditsAnkersolixTask,{copy:n,id:e}),e==="creditsRedeemList"&&(0,o.jsx)(v.CreditsRedeemList,{copy:n,id:e}),e==="creditsCash"&&(0,o.jsx)(u.CreditsCash,{copy:n,id:e}),e==="creditsMemberPrice"&&(0,o.jsx)(b.CreditsMemberPrice,{copy:n,id:e}),e==="creditsFaq"&&(0,o.jsx)(h.CreditsFaq,{copy:n,id:e}),e!=="creditsBanner"&&(0,o.jsx)("div",{className:"laptop:h-16 desktop:h-[96px] lg-desktop:h-[128px] tablet:h-16 h-16"})]}):null})})]})})}));
|
|
2
2
|
//# sourceMappingURL=Credits.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/templates/Credits.tsx"],
|
|
4
|
-
"sourcesContent": ["import { classNames, HeadlessConfig, HeadlessProvider } from '@anker-in/lib'\nimport { RegistrationProvider } from '../components/registration/context/provider'\n\nimport { DTC_TASK_TYPE } from '../components/credits/context/const'\nimport { CreditsProvider } from '../components/credits/context/provider'\nimport { CreditsPageCommon } from '../components/credits/type'\nimport { FunctionMemberPriceConfig } from '../components/credits/context/memberPriceTypes'\n\nimport { CreditsBanner, CreditsBannerCopy } from '../components/credits/creditsBanner'\nimport { CreditsInfoCard, CreditsInfoCardCopy } from '../components/credits/creditsInfoCard'\nimport { CreditsBenefits, CreditsBenefitsCopy } from '../components/credits/creditsBenefits'\nimport { CreditsWaysToGetCredits, CreditsWaysToGetCreditsCopy } from '../components/credits/creditsWaysToGetCredits'\nimport { CreditsAnkersolixTask, CreditsAnkersolixTaskCopy } from '../components/credits/creditsAnkersolixTask'\nimport { CreditsRedeemList, CreditsRedeemListCopy } from '../components/credits/creditsRedeemList'\nimport { CreditsCash, CreditsCashCopy } from '../components/credits/creditsCash'\nimport { CreditsMemberPrice, CreditsMemberPriceCopy } from '../components/credits/creditsMemberPrice'\nimport { CreditsFaq, CreditsFaqCopy } from '../components/credits/creditsFaq'\nimport { CreditsNavigation, CreditsNavigationCopy } from '../components/credits/creditsNavigation'\nimport { AuthCodeActivateCopy } from 'src/components/registration/authCodeActivate/type'\n\nexport enum ComponentKey {\n Navigation = 'creditsNavigation',\n Banner = 'creditsBanner',\n InfoCard = 'creditsInfoCard',\n Benefits = 'creditsBenefits',\n WaysToGetCredits = 'creditsWaysToGetCredits',\n AnkersolixTask = 'creditsAnkersolixTask',\n RedeemList = 'creditsRedeemList',\n SpendCreditsLikeCash = 'creditsCash',\n MemberPrice = 'creditsMemberPrice',\n Faqs = 'creditsFaq',\n}\nexport type CreditsTemplateProps = {\n headlessConfig: HeadlessConfig\n siteConfig: {\n registrationsSettings: {\n authCodeActivate: AuthCodeActivateCopy\n }\n taskIdToTypeMapping: Record<string, DTC_TASK_TYPE>\n memberPriceDiscount?: FunctionMemberPriceConfig[]\n }\n creditsConfig?: {\n alpcBrand?: string\n }\n pageConfig: {\n order: ComponentKey[]\n common: CreditsPageCommon\n components: {\n [ComponentKey.Navigation]?: CreditsNavigationCopy\n [ComponentKey.Banner]?: CreditsBannerCopy\n [ComponentKey.InfoCard]?: CreditsInfoCardCopy\n [ComponentKey.Benefits]?: CreditsBenefitsCopy\n [ComponentKey.WaysToGetCredits]?: CreditsWaysToGetCreditsCopy\n [ComponentKey.AnkersolixTask]?: CreditsAnkersolixTaskCopy\n [ComponentKey.RedeemList]?: CreditsRedeemListCopy\n [ComponentKey.SpendCreditsLikeCash]?: CreditsCashCopy\n [ComponentKey.MemberPrice]?: CreditsMemberPriceCopy\n [ComponentKey.Faqs]?: CreditsFaqCopy\n }\n }\n userContext: {\n profile: any\n removeProfile: () => void\n isLoadingProfile: boolean\n creditInfo: any\n customer: any\n customerLoading: boolean\n fetchCreditInfo: () => void\n }\n registrationContext: {\n openSignUpPopup: () => void\n openSignInPopup: () => void\n }\n gtm: {\n pageGroup: string\n }\n}\n\nexport const CreditsTemplate = ({\n headlessConfig,\n siteConfig,\n creditsConfig,\n userContext,\n pageConfig,\n registrationContext,\n gtm,\n}: CreditsTemplateProps) => {\n
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,oBAAAC,IAAA,eAAAC,EAAAJ,
|
|
6
|
-
"names": ["Credits_exports", "__export", "ComponentKey", "CreditsTemplate", "__toCommonJS", "import_jsx_runtime", "import_lib", "import_provider", "import_creditsBanner", "import_creditsInfoCard", "import_creditsBenefits", "import_creditsWaysToGetCredits", "import_creditsAnkersolixTask", "import_creditsRedeemList", "import_creditsCash", "import_creditsMemberPrice", "import_creditsFaq", "import_creditsNavigation", "headlessConfig", "siteConfig", "creditsConfig", "userContext", "pageConfig", "registrationContext", "gtm", "key", "componentCopy"]
|
|
4
|
+
"sourcesContent": ["import { classNames, HeadlessConfig, HeadlessProvider } from '@anker-in/lib'\nimport { RegistrationProvider } from '../components/registration/context/provider'\n\nimport { DTC_TASK_TYPE } from '../components/credits/context/const'\nimport { CreditsProvider } from '../components/credits/context/provider'\nimport { CreditsPageCommon } from '../components/credits/type'\nimport { FunctionMemberPriceConfig } from '../components/credits/context/memberPriceTypes'\n\nimport { CreditsBanner, CreditsBannerCopy } from '../components/credits/creditsBanner'\nimport { CreditsInfoCard, CreditsInfoCardCopy } from '../components/credits/creditsInfoCard'\nimport { CreditsBenefits, CreditsBenefitsCopy } from '../components/credits/creditsBenefits'\nimport { CreditsWaysToGetCredits, CreditsWaysToGetCreditsCopy } from '../components/credits/creditsWaysToGetCredits'\nimport { CreditsAnkersolixTask, CreditsAnkersolixTaskCopy } from '../components/credits/creditsAnkersolixTask'\nimport { CreditsRedeemList, CreditsRedeemListCopy } from '../components/credits/creditsRedeemList'\nimport { CreditsCash, CreditsCashCopy } from '../components/credits/creditsCash'\nimport { CreditsMemberPrice, CreditsMemberPriceCopy } from '../components/credits/creditsMemberPrice'\nimport { CreditsFaq, CreditsFaqCopy } from '../components/credits/creditsFaq'\nimport { CreditsNavigation, CreditsNavigationCopy } from '../components/credits/creditsNavigation'\nimport { AuthCodeActivateCopy } from 'src/components/registration/authCodeActivate/type'\n\nexport enum ComponentKey {\n Navigation = 'creditsNavigation',\n Banner = 'creditsBanner',\n InfoCard = 'creditsInfoCard',\n Benefits = 'creditsBenefits',\n WaysToGetCredits = 'creditsWaysToGetCredits',\n AnkersolixTask = 'creditsAnkersolixTask',\n RedeemList = 'creditsRedeemList',\n SpendCreditsLikeCash = 'creditsCash',\n MemberPrice = 'creditsMemberPrice',\n Faqs = 'creditsFaq',\n}\nexport type CreditsTemplateProps = {\n headlessConfig: HeadlessConfig\n siteConfig: {\n registrationsSettings: {\n authCodeActivate: AuthCodeActivateCopy\n }\n taskIdToTypeMapping: Record<string, DTC_TASK_TYPE>\n memberPriceDiscount?: FunctionMemberPriceConfig[]\n }\n creditsConfig?: {\n alpcBrand?: string\n }\n pageConfig: {\n order: ComponentKey[]\n common: CreditsPageCommon\n components: {\n [ComponentKey.Navigation]?: CreditsNavigationCopy\n [ComponentKey.Banner]?: CreditsBannerCopy\n [ComponentKey.InfoCard]?: CreditsInfoCardCopy\n [ComponentKey.Benefits]?: CreditsBenefitsCopy\n [ComponentKey.WaysToGetCredits]?: CreditsWaysToGetCreditsCopy\n [ComponentKey.AnkersolixTask]?: CreditsAnkersolixTaskCopy\n [ComponentKey.RedeemList]?: CreditsRedeemListCopy\n [ComponentKey.SpendCreditsLikeCash]?: CreditsCashCopy\n [ComponentKey.MemberPrice]?: CreditsMemberPriceCopy\n [ComponentKey.Faqs]?: CreditsFaqCopy\n }\n }\n userContext: {\n profile: any\n removeProfile: () => void\n isLoadingProfile: boolean\n creditInfo: any\n customer: any\n customerLoading: boolean\n fetchCreditInfo: () => void\n }\n registrationContext: {\n openSignUpPopup: () => void\n openSignInPopup: () => void\n }\n gtm: {\n pageGroup: string\n }\n cartConfig?: {\n addToCart: (params: {\n variantList: Array<{\n variant: any\n quantity: number\n attributes?: Array<{ key: string; value: string }>\n }>\n cartAttributes?: Record<string, string>\n discountCodes?: string[]\n }) => void | Promise<any>\n }\n}\n\nexport const CreditsTemplate = ({\n headlessConfig,\n siteConfig,\n creditsConfig,\n userContext,\n pageConfig,\n registrationContext,\n gtm,\n cartConfig,\n}: CreditsTemplateProps) => {\n console.log('siteConfig', siteConfig)\n return (\n <HeadlessProvider headlessConfig={headlessConfig}>\n <RegistrationProvider copy={siteConfig.registrationsSettings} email={userContext?.profile?.email}>\n <CreditsProvider\n profile={userContext?.profile}\n removeProfile={userContext?.removeProfile}\n isLoadingProfile={userContext?.isLoadingProfile}\n openSignInPopup={registrationContext.openSignInPopup}\n openSignUpPopup={registrationContext.openSignUpPopup}\n creditInfo={userContext?.creditInfo}\n taskIdToTypeMapping={siteConfig.taskIdToTypeMapping}\n customer={userContext?.customer}\n fetchCreditInfo={userContext?.fetchCreditInfo}\n customerLoading={userContext?.customerLoading}\n gtm={gtm}\n pageCommon={pageConfig.common}\n memberPriceDiscount={siteConfig.memberPriceDiscount}\n alpcBrand={creditsConfig?.alpcBrand}\n cartConfig={cartConfig}\n >\n {/* \u5BFC\u822A\u7EC4\u4EF6 - \u56FA\u5B9A\u4F4D\u7F6E\uFF0C\u4E0D\u53C2\u4E0E order \u6392\u5E8F */}\n {pageConfig.components[ComponentKey.Navigation] && (\n <CreditsNavigation copy={pageConfig.components[ComponentKey.Navigation]} />\n )}\n <div className={classNames('bg-[#f5f5f7] leading-[1.2]')}>\n {pageConfig.order.map(key => {\n // \u8DF3\u8FC7\u5BFC\u822A\u7EC4\u4EF6\uFF0C\u56E0\u4E3A\u5B83\u5DF2\u7ECF\u56FA\u5B9A\u6E32\u67D3\u5728\u4E0A\u65B9\n if (key === ComponentKey.Navigation) return null\n const componentCopy = pageConfig.components?.[key]\n if (!componentCopy) return null\n return (\n <>\n {key === ComponentKey.Banner && <CreditsBanner copy={componentCopy as CreditsBannerCopy} id={key} />}\n {key === ComponentKey.InfoCard && userContext?.profile && (\n <CreditsInfoCard copy={componentCopy as CreditsInfoCardCopy} id={key} />\n )}\n {key === ComponentKey.Benefits && (\n <CreditsBenefits copy={componentCopy as CreditsBenefitsCopy} id={key} />\n )}\n {key === ComponentKey.WaysToGetCredits && (\n <CreditsWaysToGetCredits\n copy={componentCopy as CreditsWaysToGetCreditsCopy}\n id={key}\n classNames={\n headlessConfig.brand === 'anker'\n ? {\n subtitle: 'text-white',\n equalCreditsText:\n 'bg-gradient-to-r from-[#3AD1FF] to-[#008CD6] bg-clip-text text-transparent',\n }\n : {\n subtitle: 'text-[#D1D1D1]',\n equalCreditsText: 'text-[#F6EAD0]',\n }\n }\n />\n )}\n {key === ComponentKey.AnkersolixTask && (\n <CreditsAnkersolixTask copy={componentCopy as CreditsAnkersolixTaskCopy} id={key} />\n )}\n {key === ComponentKey.RedeemList && (\n <CreditsRedeemList copy={componentCopy as CreditsRedeemListCopy} id={key} />\n )}\n {key === ComponentKey.SpendCreditsLikeCash && (\n <CreditsCash copy={componentCopy as CreditsCashCopy} id={key} />\n )}\n {key === ComponentKey.MemberPrice && (\n <CreditsMemberPrice copy={componentCopy as CreditsMemberPriceCopy} id={key} />\n )}\n {key === ComponentKey.Faqs && <CreditsFaq copy={componentCopy as CreditsFaqCopy} id={key} />}\n {key !== ComponentKey.Banner && (\n <div className=\"laptop:h-16 desktop:h-[96px] lg-desktop:h-[128px] tablet:h-16 h-16\" />\n )}\n </>\n )\n })}\n </div>\n </CreditsProvider>\n </RegistrationProvider>\n </HeadlessProvider>\n )\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,oBAAAC,IAAA,eAAAC,EAAAJ,GA0HY,IAAAK,EAAA,6BA1HZC,EAA6D,yBAC7DC,EAAqC,uDAGrCA,EAAgC,kDAIhCC,EAAiD,+CACjDC,EAAqD,iDACrDC,EAAqD,iDACrDC,EAAqE,yDACrEC,EAAiE,uDACjEC,EAAyD,mDACzDC,EAA6C,6CAC7CC,EAA2D,oDAC3DC,EAA2C,4CAC3CC,EAAyD,mDAG7Cf,OACVA,EAAA,WAAa,oBACbA,EAAA,OAAS,gBACTA,EAAA,SAAW,kBACXA,EAAA,SAAW,kBACXA,EAAA,iBAAmB,0BACnBA,EAAA,eAAiB,wBACjBA,EAAA,WAAa,oBACbA,EAAA,qBAAuB,cACvBA,EAAA,YAAc,qBACdA,EAAA,KAAO,aAVGA,OAAA,IAqEL,MAAMC,EAAkB,CAAC,CAC9B,eAAAe,EACA,WAAAC,EACA,cAAAC,EACA,YAAAC,EACA,WAAAC,EACA,oBAAAC,EACA,IAAAC,EACA,WAAAC,CACF,KACE,QAAQ,IAAI,aAAcN,CAAU,KAElC,OAAC,oBAAiB,eAAgBD,EAChC,mBAAC,wBAAqB,KAAMC,EAAW,sBAAuB,MAAOE,GAAa,SAAS,MACzF,oBAAC,mBACC,QAASA,GAAa,QACtB,cAAeA,GAAa,cAC5B,iBAAkBA,GAAa,iBAC/B,gBAAiBE,EAAoB,gBACrC,gBAAiBA,EAAoB,gBACrC,WAAYF,GAAa,WACzB,oBAAqBF,EAAW,oBAChC,SAAUE,GAAa,SACvB,gBAAiBA,GAAa,gBAC9B,gBAAiBA,GAAa,gBAC9B,IAAKG,EACL,WAAYF,EAAW,OACvB,oBAAqBH,EAAW,oBAChC,UAAWC,GAAe,UAC1B,WAAYK,EAGX,UAAAH,EAAW,WAAW,sBACrB,OAAC,qBAAkB,KAAMA,EAAW,WAAW,kBAA0B,KAE3E,OAAC,OAAI,aAAW,cAAW,4BAA4B,EACpD,SAAAA,EAAW,MAAM,IAAII,GAAO,CAE3B,GAAIA,IAAQ,oBAAyB,OAAO,KAC5C,MAAMC,EAAgBL,EAAW,aAAaI,CAAG,EACjD,OAAKC,KAEH,oBACG,UAAAD,IAAQ,oBAAuB,OAAC,iBAAc,KAAMC,EAAoC,GAAID,EAAK,EACjGA,IAAQ,mBAAyBL,GAAa,YAC7C,OAAC,mBAAgB,KAAMM,EAAsC,GAAID,EAAK,EAEvEA,IAAQ,sBACP,OAAC,mBAAgB,KAAMC,EAAsC,GAAID,EAAK,EAEvEA,IAAQ,8BACP,OAAC,2BACC,KAAMC,EACN,GAAID,EACJ,WACER,EAAe,QAAU,QACrB,CACE,SAAU,aACV,iBACE,4EACJ,EACA,CACE,SAAU,iBACV,iBAAkB,gBACpB,EAER,EAEDQ,IAAQ,4BACP,OAAC,yBAAsB,KAAMC,EAA4C,GAAID,EAAK,EAEnFA,IAAQ,wBACP,OAAC,qBAAkB,KAAMC,EAAwC,GAAID,EAAK,EAE3EA,IAAQ,kBACP,OAAC,eAAY,KAAMC,EAAkC,GAAID,EAAK,EAE/DA,IAAQ,yBACP,OAAC,sBAAmB,KAAMC,EAAyC,GAAID,EAAK,EAE7EA,IAAQ,iBAAqB,OAAC,cAAW,KAAMC,EAAiC,GAAID,EAAK,EACzFA,IAAQ,oBACP,OAAC,OAAI,UAAU,qEAAqE,GAExF,EA5CyB,IA8C7B,CAAC,EACH,GACF,EACF,EACF",
|
|
6
|
+
"names": ["Credits_exports", "__export", "ComponentKey", "CreditsTemplate", "__toCommonJS", "import_jsx_runtime", "import_lib", "import_provider", "import_creditsBanner", "import_creditsInfoCard", "import_creditsBenefits", "import_creditsWaysToGetCredits", "import_creditsAnkersolixTask", "import_creditsRedeemList", "import_creditsCash", "import_creditsMemberPrice", "import_creditsFaq", "import_creditsNavigation", "headlessConfig", "siteConfig", "creditsConfig", "userContext", "pageConfig", "registrationContext", "gtm", "cartConfig", "key", "componentCopy"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NormalizedProductVariant } from '@anker-in/shopify-react';
|
|
2
2
|
import { FunctionMemberPriceResult } from '../memberPriceTypes';
|
|
3
3
|
export declare const useFunctionMemberPrice: ({ variant }: {
|
|
4
|
-
variant?:
|
|
4
|
+
variant?: NormalizedProductVariant;
|
|
5
5
|
}) => FunctionMemberPriceResult | (Partial<FunctionMemberPriceResult> & {
|
|
6
6
|
hasMemberPrice: false;
|
|
7
7
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getFunctionMemberPrice as c}from"../utils/getFunctionMemberPrice";import{useMemo as i}from"react";import{useCreditsContext as m}from"../provider";import{useHeadlessContext as n}from"@anker-in/lib";const
|
|
1
|
+
import{getFunctionMemberPrice as c}from"../utils/getFunctionMemberPrice";import{useMemo as i}from"react";import{useCreditsContext as m}from"../provider";import{useHeadlessContext as n}from"@anker-in/lib";const p=({variant:e})=>{const{memberPriceDiscount:r}=m(),{locale:t=""}=n();return i(()=>{const o=c({memberPriceDiscount:r,currencyCode:e?.price.currencyCode,variant:e,locale:t});return o||{hasMemberPrice:!1}},[t,r,e])};export{p as useFunctionMemberPrice};
|
|
2
2
|
//# sourceMappingURL=useFunctionMemberPrice.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useFunctionMemberPrice.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAEA,OAAS,0BAAAA,MAA8B,kCACvC,OAAS,WAAAC,MAAe,QACxB,OAAS,qBAAAC,MAAyB,cAClC,OAAS,sBAAAC,MAA0B,gBAG5B,MAAMC,EAAyB,CAAC,CAAE,QAAAC,CAAQ,
|
|
4
|
+
"sourcesContent": ["import { NormalizedProductVariant } from '@anker-in/shopify-react'\nimport { FunctionMemberPriceResult } from '../memberPriceTypes'\nimport { getFunctionMemberPrice } from '../utils/getFunctionMemberPrice'\nimport { useMemo } from 'react'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\n// \u8BA1\u7B97\u5355\u4EF6\u5546\u54C1\u7684\u4F1A\u5458\u4EF7\nexport const useFunctionMemberPrice = ({ variant }: { variant?: NormalizedProductVariant }) => {\n const { memberPriceDiscount } = useCreditsContext()\n const { locale = '' } = useHeadlessContext()\n\n const memberPrice:\n | FunctionMemberPriceResult\n | (Partial<FunctionMemberPriceResult> & {\n hasMemberPrice: false\n }) = useMemo(() => {\n const result = getFunctionMemberPrice({\n memberPriceDiscount: memberPriceDiscount,\n currencyCode: variant?.price.currencyCode,\n variant,\n locale,\n })\n\n if (result) {\n return result as FunctionMemberPriceResult\n }\n\n return { hasMemberPrice: false }\n }, [locale, memberPriceDiscount, variant])\n\n return memberPrice\n}\n"],
|
|
5
|
+
"mappings": "AAEA,OAAS,0BAAAA,MAA8B,kCACvC,OAAS,WAAAC,MAAe,QACxB,OAAS,qBAAAC,MAAyB,cAClC,OAAS,sBAAAC,MAA0B,gBAG5B,MAAMC,EAAyB,CAAC,CAAE,QAAAC,CAAQ,IAA8C,CAC7F,KAAM,CAAE,oBAAAC,CAAoB,EAAIJ,EAAkB,EAC5C,CAAE,OAAAK,EAAS,EAAG,EAAIJ,EAAmB,EAqB3C,OAfSF,EAAQ,IAAM,CACrB,MAAMO,EAASR,EAAuB,CACpC,oBAAqBM,EACrB,aAAcD,GAAS,MAAM,aAC7B,QAAAA,EACA,OAAAE,CACF,CAAC,EAED,OAAIC,GAIG,CAAE,eAAgB,EAAM,CACjC,EAAG,CAACD,EAAQD,EAAqBD,CAAO,CAAC,CAG3C",
|
|
6
6
|
"names": ["getFunctionMemberPrice", "useMemo", "useCreditsContext", "useHeadlessContext", "useFunctionMemberPrice", "variant", "memberPriceDiscount", "locale", "result"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var x=(r=>(r[r.Percentage=1]="Percentage",r[r.FixedAmount=2]="FixedAmount",r[r.FixedPrice=3]="FixedPrice",r))(x||{})
|
|
1
|
+
var x=(r=>(r[r.Percentage=1]="Percentage",r[r.FixedAmount=2]="FixedAmount",r[r.FixedPrice=3]="FixedPrice",r))(x||{});export{x as FunctionDiscountType};
|
|
2
2
|
//# sourceMappingURL=memberPriceConst.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/credits/context/memberPriceConst.ts"],
|
|
4
|
-
"sourcesContent": ["// Function \u6298\u6263\u7C7B\u578B\nexport enum FunctionDiscountType {\n Percentage = 1,\n FixedAmount,\n FixedPrice,\n}\n
|
|
5
|
-
"mappings": "AACO,IAAKA,OACVA,IAAA,WAAa,GAAb,aACAA,IAAA,6BACAA,IAAA,2BAHUA,OAAA
|
|
6
|
-
"names": ["FunctionDiscountType"
|
|
4
|
+
"sourcesContent": ["// Function \u6298\u6263\u7C7B\u578B\nexport enum FunctionDiscountType {\n Percentage = 1,\n FixedAmount,\n FixedPrice,\n}\n"],
|
|
5
|
+
"mappings": "AACO,IAAKA,OACVA,IAAA,WAAa,GAAb,aACAA,IAAA,6BACAA,IAAA,2BAHUA,OAAA",
|
|
6
|
+
"names": ["FunctionDiscountType"]
|
|
7
7
|
}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import { FunctionDiscountType
|
|
2
|
-
export type PriceEndingConf = {
|
|
3
|
-
apply_price_ending: boolean;
|
|
4
|
-
one_decimal_place: string;
|
|
5
|
-
two_decimal_place: string;
|
|
6
|
-
round_selected: RoundSelected;
|
|
7
|
-
};
|
|
1
|
+
import { FunctionDiscountType } from './memberPriceConst';
|
|
8
2
|
export type DiscountConfig = {
|
|
9
3
|
discount_type: FunctionDiscountType;
|
|
10
4
|
discount_value: number;
|
|
11
|
-
price_ending_conf?: PriceEndingConf;
|
|
12
5
|
};
|
|
13
6
|
export type FunctionMemberPriceConfig = {
|
|
14
7
|
rule_id: string;
|
|
@@ -30,17 +23,3 @@ export type FunctionMemberPriceConfig = {
|
|
|
30
23
|
other_product_discounts: boolean;
|
|
31
24
|
};
|
|
32
25
|
};
|
|
33
|
-
export type FunctionMemberPriceResult = {
|
|
34
|
-
hasMemberPrice: boolean;
|
|
35
|
-
useCoupon: boolean;
|
|
36
|
-
originalPrice: number;
|
|
37
|
-
originalPriceWithCurrency: string;
|
|
38
|
-
salePrice: number;
|
|
39
|
-
salePriceWithCurrency: string;
|
|
40
|
-
salePriceWithoutCoupon: number;
|
|
41
|
-
salePriceWithoutCouponWithCurrency: string;
|
|
42
|
-
savePrice: number;
|
|
43
|
-
savePriceWithCurrency: string;
|
|
44
|
-
savePriceWithoutCoupon: number;
|
|
45
|
-
savePriceWithoutCouponWithCurrency: string;
|
|
46
|
-
};
|
|
@@ -20,8 +20,22 @@ type Context = {
|
|
|
20
20
|
pageCommon: CreditsPageCommon;
|
|
21
21
|
memberPriceDiscount?: FunctionMemberPriceConfig[];
|
|
22
22
|
alpcBrand?: string;
|
|
23
|
+
cartConfig?: {
|
|
24
|
+
addToCart: (params: {
|
|
25
|
+
variantList: Array<{
|
|
26
|
+
variant: any;
|
|
27
|
+
quantity: number;
|
|
28
|
+
attributes?: Array<{
|
|
29
|
+
key: string;
|
|
30
|
+
value: string;
|
|
31
|
+
}>;
|
|
32
|
+
}>;
|
|
33
|
+
cartAttributes?: Record<string, string>;
|
|
34
|
+
discountCodes?: string[];
|
|
35
|
+
}) => void | Promise<any>;
|
|
36
|
+
};
|
|
23
37
|
};
|
|
24
38
|
export declare const CreditsContext: import("react").Context<Context>;
|
|
25
|
-
export declare function CreditsProvider({ children, profile, removeProfile, isLoadingProfile, openSignInPopup, openSignUpPopup, taskIdToTypeMapping, creditInfo, customer, customerLoading, fetchCreditInfo, gtm, pageCommon, memberPriceDiscount, alpcBrand, }: PropsWithChildren<Context>): import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
export declare function CreditsProvider({ children, profile, removeProfile, isLoadingProfile, openSignInPopup, openSignUpPopup, taskIdToTypeMapping, creditInfo, customer, customerLoading, fetchCreditInfo, gtm, pageCommon, memberPriceDiscount, alpcBrand, cartConfig, }: PropsWithChildren<Context>): import("react/jsx-runtime").JSX.Element;
|
|
26
40
|
export declare function useCreditsContext(): Context;
|
|
27
41
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as y}from"react/jsx-runtime";import{createContext as l,useContext as v}from"react";const o=l({profile:null,isLoadingProfile:!1,taskIdToTypeMapping:{},removeProfile:()=>{},openSignInPopup:()=>{},openSignUpPopup:()=>{},creditInfo:void 0,customerLoading:!1,fetchCreditInfo:e=>{},gtm:{pageGroup:""},pageCommon:{},memberPriceDiscount:void 0,alpcBrand:void 0,cartConfig:void 0});function _({children:e,profile:r,removeProfile:t,isLoadingProfile:n,openSignInPopup:i,openSignUpPopup:s,taskIdToTypeMapping:d,creditInfo:p,customer:a,customerLoading:u,fetchCreditInfo:C,gtm:m,pageCommon:f,memberPriceDiscount:g,alpcBrand:c,cartConfig:P}){return y(o.Provider,{value:{profile:r,isLoadingProfile:n,removeProfile:t,openSignInPopup:i,openSignUpPopup:s,taskIdToTypeMapping:d,creditInfo:p,fetchCreditInfo:C,customer:a,customerLoading:u,gtm:m,pageCommon:f,memberPriceDiscount:g,alpcBrand:c,cartConfig:P},children:e})}function A(){const e=v(o);if(!e)throw new Error("useCreditsContext must be used within a CreditsProvider");return e}export{o as CreditsContext,_ as CreditsProvider,A as useCreditsContext};
|
|
2
2
|
//# sourceMappingURL=provider.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/credits/context/provider.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createContext, PropsWithChildren, useContext } from 'react'\nimport type { DTC_TASK_TYPE } from './const'\nimport type { CreditInfoResponse } from './response'\nimport { CreditsPageCommon } from '../type'\nimport { FunctionMemberPriceConfig } from './memberPriceTypes'\n\ntype Context = {\n profile: any\n isLoadingProfile: boolean\n removeProfile: () => void\n taskIdToTypeMapping: Record<string, DTC_TASK_TYPE>\n openSignInPopup: () => void\n openSignUpPopup: () => void\n creditInfo?: CreditInfoResponse\n customer?: any\n customerLoading: boolean\n fetchCreditInfo: (user_id: string) => void\n gtm: {\n pageGroup: string\n }\n pageCommon: CreditsPageCommon\n memberPriceDiscount?: FunctionMemberPriceConfig[]\n alpcBrand?: string\n}\n\nexport const CreditsContext = createContext<Context>({\n profile: null,\n isLoadingProfile: false,\n taskIdToTypeMapping: {},\n removeProfile: () => {},\n openSignInPopup: () => {},\n openSignUpPopup: () => {},\n creditInfo: undefined,\n customerLoading: false,\n fetchCreditInfo: (user_id: string) => {},\n gtm: {\n pageGroup: '',\n },\n pageCommon: {},\n memberPriceDiscount: undefined,\n alpcBrand: undefined,\n})\n\nexport function CreditsProvider({\n children,\n profile,\n removeProfile,\n isLoadingProfile,\n openSignInPopup,\n openSignUpPopup,\n taskIdToTypeMapping,\n creditInfo,\n customer,\n customerLoading,\n fetchCreditInfo,\n gtm,\n pageCommon,\n memberPriceDiscount,\n alpcBrand,\n}: PropsWithChildren<Context>) {\n return (\n <CreditsContext.Provider\n value={{\n profile,\n isLoadingProfile,\n removeProfile,\n openSignInPopup,\n openSignUpPopup,\n taskIdToTypeMapping,\n creditInfo,\n fetchCreditInfo,\n customer,\n customerLoading,\n gtm,\n pageCommon,\n memberPriceDiscount,\n alpcBrand,\n }}\n >\n {children}\n </CreditsContext.Provider>\n )\n}\n\nexport function useCreditsContext() {\n const context = useContext(CreditsContext)\n if (!context) {\n throw new Error('useCreditsContext must be used within a CreditsProvider')\n }\n return context\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "createContext", "useContext", "CreditsContext", "user_id", "CreditsProvider", "children", "profile", "removeProfile", "isLoadingProfile", "openSignInPopup", "openSignUpPopup", "taskIdToTypeMapping", "creditInfo", "customer", "customerLoading", "fetchCreditInfo", "gtm", "pageCommon", "memberPriceDiscount", "alpcBrand", "useCreditsContext", "context"]
|
|
4
|
+
"sourcesContent": ["import { createContext, PropsWithChildren, useContext } from 'react'\nimport type { DTC_TASK_TYPE } from './const'\nimport type { CreditInfoResponse } from './response'\nimport { CreditsPageCommon } from '../type'\nimport { FunctionMemberPriceConfig } from './memberPriceTypes'\n\ntype Context = {\n profile: any\n isLoadingProfile: boolean\n removeProfile: () => void\n taskIdToTypeMapping: Record<string, DTC_TASK_TYPE>\n openSignInPopup: () => void\n openSignUpPopup: () => void\n creditInfo?: CreditInfoResponse\n customer?: any\n customerLoading: boolean\n fetchCreditInfo: (user_id: string) => void\n gtm: {\n pageGroup: string\n }\n pageCommon: CreditsPageCommon\n memberPriceDiscount?: FunctionMemberPriceConfig[]\n alpcBrand?: string\n cartConfig?: {\n addToCart: (params: {\n variantList: Array<{\n variant: any\n quantity: number\n attributes?: Array<{ key: string; value: string }>\n }>\n cartAttributes?: Record<string, string>\n discountCodes?: string[]\n }) => void | Promise<any>\n }\n}\n\nexport const CreditsContext = createContext<Context>({\n profile: null,\n isLoadingProfile: false,\n taskIdToTypeMapping: {},\n removeProfile: () => {},\n openSignInPopup: () => {},\n openSignUpPopup: () => {},\n creditInfo: undefined,\n customerLoading: false,\n fetchCreditInfo: (user_id: string) => {},\n gtm: {\n pageGroup: '',\n },\n pageCommon: {},\n memberPriceDiscount: undefined,\n alpcBrand: undefined,\n cartConfig: undefined,\n})\n\nexport function CreditsProvider({\n children,\n profile,\n removeProfile,\n isLoadingProfile,\n openSignInPopup,\n openSignUpPopup,\n taskIdToTypeMapping,\n creditInfo,\n customer,\n customerLoading,\n fetchCreditInfo,\n gtm,\n pageCommon,\n memberPriceDiscount,\n alpcBrand,\n cartConfig,\n}: PropsWithChildren<Context>) {\n return (\n <CreditsContext.Provider\n value={{\n profile,\n isLoadingProfile,\n removeProfile,\n openSignInPopup,\n openSignUpPopup,\n taskIdToTypeMapping,\n creditInfo,\n fetchCreditInfo,\n customer,\n customerLoading,\n gtm,\n pageCommon,\n memberPriceDiscount,\n alpcBrand,\n cartConfig,\n }}\n >\n {children}\n </CreditsContext.Provider>\n )\n}\n\nexport function useCreditsContext() {\n const context = useContext(CreditsContext)\n if (!context) {\n throw new Error('useCreditsContext must be used within a CreditsProvider')\n }\n return context\n}\n"],
|
|
5
|
+
"mappings": "AA0EI,cAAAA,MAAA,oBA1EJ,OAAS,iBAAAC,EAAkC,cAAAC,MAAkB,QAoCtD,MAAMC,EAAiBF,EAAuB,CACnD,QAAS,KACT,iBAAkB,GAClB,oBAAqB,CAAC,EACtB,cAAe,IAAM,CAAC,EACtB,gBAAiB,IAAM,CAAC,EACxB,gBAAiB,IAAM,CAAC,EACxB,WAAY,OACZ,gBAAiB,GACjB,gBAAkBG,GAAoB,CAAC,EACvC,IAAK,CACH,UAAW,EACb,EACA,WAAY,CAAC,EACb,oBAAqB,OACrB,UAAW,OACX,WAAY,MACd,CAAC,EAEM,SAASC,EAAgB,CAC9B,SAAAC,EACA,QAAAC,EACA,cAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,oBAAAC,EACA,WAAAC,EACA,SAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,IAAAC,EACA,WAAAC,EACA,oBAAAC,EACA,UAAAC,EACA,WAAAC,CACF,EAA+B,CAC7B,OACErB,EAACG,EAAe,SAAf,CACC,MAAO,CACL,QAAAI,EACA,iBAAAE,EACA,cAAAD,EACA,gBAAAE,EACA,gBAAAC,EACA,oBAAAC,EACA,WAAAC,EACA,gBAAAG,EACA,SAAAF,EACA,gBAAAC,EACA,IAAAE,EACA,WAAAC,EACA,oBAAAC,EACA,UAAAC,EACA,WAAAC,CACF,EAEC,SAAAf,EACH,CAEJ,CAEO,SAASgB,GAAoB,CAClC,MAAMC,EAAUrB,EAAWC,CAAc,EACzC,GAAI,CAACoB,EACH,MAAM,IAAI,MAAM,yDAAyD,EAE3E,OAAOA,CACT",
|
|
6
|
+
"names": ["jsx", "createContext", "useContext", "CreditsContext", "user_id", "CreditsProvider", "children", "profile", "removeProfile", "isLoadingProfile", "openSignInPopup", "openSignUpPopup", "taskIdToTypeMapping", "creditInfo", "customer", "customerLoading", "fetchCreditInfo", "gtm", "pageCommon", "memberPriceDiscount", "alpcBrand", "cartConfig", "useCreditsContext", "context"]
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FunctionMemberPriceConfig, FunctionMemberPriceResult } from '../memberPriceTypes';
|
|
2
|
-
import {
|
|
2
|
+
import { NormalizedProductVariant } from '@anker-in/shopify-react';
|
|
3
3
|
export declare const getFunctionMemberPrice: ({ memberPriceDiscount, currencyCode, variant, locale, }: {
|
|
4
4
|
memberPriceDiscount?: FunctionMemberPriceConfig[];
|
|
5
5
|
currencyCode?: string;
|
|
6
|
-
variant?:
|
|
6
|
+
variant?: NormalizedProductVariant;
|
|
7
7
|
locale: string;
|
|
8
8
|
}) => false | FunctionMemberPriceResult;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{formatPrice as
|
|
1
|
+
import{formatPrice as t}from"../utils";import{functionDiscountCalculate as b}from"./functionDiscountCalculate";import n from"decimal.js";import{getFunctionMemberPriceDiscountConfig as D}from"./getFunctionMemberPriceDiscountConfig";import d from"./variantGetCoupon";const R=({memberPriceDiscount:g,currencyCode:r,variant:e,locale:i})=>{const m=d({variant:e}),{memberPriceDiscountConfig:c,activeMemberPriceConfig:y}=D({config:g,variant:e}),s=!!y?.discount_combinations.other_product_discounts;if(!c)return!1;const u={amount:e?.price.amount||0,priceWithCurrency:t({amount:e?.price.amount||0,currencyCode:r||"USD",locale:i})},o=c?b({config:c,price:e?.price.amount||0}):e?.price.amount||0,a={amount:o,priceWithCurrency:t({amount:o,currencyCode:r||"USD",locale:i})};let p=o;if(m?.variant_price4wscode&&e&&s)if(s){const P=new n(e.price.amount).minus(m.variant_price4wscode);p=new n(o).minus(P).toNumber()}else{const P=new n(e.price.amount).minus(m.variant_price4wscode);if(o>P.toNumber())return!1}const C={amount:p,priceWithCurrency:t({amount:p,currencyCode:r||"USD",locale:i})},h=new n(u.amount).minus(C.amount).toNumber(),f={amount:h,priceWithCurrency:t({amount:h,currencyCode:r||"USD",locale:i,maximumFractionDigits:2})},W=new n(u.amount).minus(a.amount).toNumber(),l={amount:W,priceWithCurrency:t({amount:W,currencyCode:r||"USD",locale:i,maximumFractionDigits:2})};return{hasMemberPrice:!!c,useCoupon:s,originalPrice:u.amount,originalPriceWithCurrency:u.priceWithCurrency,salePrice:C.amount,salePriceWithCurrency:C.priceWithCurrency,salePriceWithoutCoupon:a.amount,salePriceWithoutCouponWithCurrency:a.priceWithCurrency,savePrice:f.amount,savePriceWithCurrency:f.priceWithCurrency,savePriceWithoutCoupon:l.amount,savePriceWithoutCouponWithCurrency:l.priceWithCurrency}};export{R as getFunctionMemberPrice};
|
|
2
2
|
//# sourceMappingURL=getFunctionMemberPrice.js.map
|