@anker-in/campaign-ui 0.2.1 → 0.2.2-beta.1
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/useActivities.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useActivities.js.map +3 -3
- package/dist/cjs/components/credits/context/hooks/useAlpcFetch.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useAlpcFetch.js.map +3 -3
- package/dist/cjs/components/credits/context/hooks/useFunctionMemberPrice.d.ts +7 -0
- package/dist/cjs/components/credits/context/hooks/useFunctionMemberPrice.js +2 -0
- package/dist/cjs/components/credits/context/hooks/useFunctionMemberPrice.js.map +7 -0
- package/dist/cjs/components/credits/context/hooks/useMyRewards.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useMyRewards.js.map +3 -3
- package/dist/cjs/components/credits/context/hooks/useRedeemCoupon.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useRedeemCoupon.js.map +3 -3
- package/dist/cjs/components/credits/context/hooks/useRedeemProduct.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useRedeemProduct.js.map +3 -3
- package/dist/cjs/components/credits/context/hooks/useRedeemableList.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useRedeemableList.js.map +3 -3
- package/dist/cjs/components/credits/context/memberPriceConst.d.ts +10 -0
- package/dist/cjs/components/credits/context/memberPriceConst.js +2 -0
- package/dist/cjs/components/credits/context/memberPriceConst.js.map +7 -0
- package/dist/cjs/components/credits/context/memberPriceTypes.d.ts +46 -0
- package/dist/cjs/components/credits/context/memberPriceTypes.js +2 -0
- package/dist/cjs/components/credits/context/memberPriceTypes.js.map +7 -0
- package/dist/cjs/components/credits/context/provider.d.ts +4 -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/atobID.d.ts +1 -0
- package/dist/cjs/components/credits/context/utils/atobID.js +2 -0
- package/dist/cjs/components/credits/context/utils/atobID.js.map +7 -0
- package/dist/cjs/components/credits/context/utils/functionDiscountCalculate.d.ts +5 -0
- package/dist/cjs/components/credits/context/utils/functionDiscountCalculate.js +2 -0
- package/dist/cjs/components/credits/context/utils/functionDiscountCalculate.js.map +7 -0
- package/dist/cjs/components/credits/context/utils/getFunctionMemberPrice.d.ts +8 -0
- package/dist/cjs/components/credits/context/utils/getFunctionMemberPrice.js +2 -0
- package/dist/cjs/components/credits/context/utils/getFunctionMemberPrice.js.map +7 -0
- package/dist/cjs/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.d.ts +9 -0
- package/dist/cjs/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.js +2 -0
- package/dist/cjs/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.js.map +7 -0
- package/dist/cjs/components/credits/context/utils/variantGetCoupon.d.ts +6 -0
- package/dist/cjs/components/credits/context/utils/variantGetCoupon.js +2 -0
- package/dist/cjs/components/credits/context/utils/variantGetCoupon.js.map +7 -0
- package/dist/cjs/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.d.ts +4 -0
- package/dist/cjs/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.js +2 -0
- package/dist/cjs/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.js.map +7 -0
- package/dist/cjs/components/credits/creditsAnkersolixTask/index.d.ts +2 -0
- package/dist/cjs/components/credits/creditsAnkersolixTask/index.js +2 -0
- package/dist/cjs/components/credits/creditsAnkersolixTask/index.js.map +7 -0
- package/dist/cjs/components/credits/creditsAnkersolixTask/type.d.ts +1 -0
- package/dist/cjs/components/credits/creditsAnkersolixTask/type.js +2 -0
- package/dist/cjs/components/credits/creditsAnkersolixTask/type.js.map +7 -0
- package/dist/cjs/components/credits/creditsBanner/index.d.ts +2 -1
- package/dist/cjs/components/credits/creditsBanner/index.js +1 -1
- package/dist/cjs/components/credits/creditsBanner/index.js.map +3 -3
- package/dist/cjs/components/credits/creditsBenefits/benefitItem.d.ts +4 -1
- package/dist/cjs/components/credits/creditsBenefits/benefitItem.js +2 -2
- package/dist/cjs/components/credits/creditsBenefits/benefitItem.js.map +4 -4
- package/dist/cjs/components/credits/creditsBenefits/iconInfo.js +1 -1
- package/dist/cjs/components/credits/creditsBenefits/iconInfo.js.map +2 -2
- package/dist/cjs/components/credits/creditsBenefits/index.d.ts +6 -2
- package/dist/cjs/components/credits/creditsBenefits/index.js +3 -3
- package/dist/cjs/components/credits/creditsBenefits/index.js.map +3 -3
- package/dist/cjs/components/credits/creditsCash/CreditsCash.d.ts +2 -1
- package/dist/cjs/components/credits/creditsCash/CreditsCash.js +1 -1
- package/dist/cjs/components/credits/creditsCash/CreditsCash.js.map +3 -3
- package/dist/cjs/components/credits/creditsCash/RedeemableItem.js +1 -1
- package/dist/cjs/components/credits/creditsCash/RedeemableItem.js.map +2 -2
- package/dist/cjs/components/credits/creditsFaq/index.d.ts +2 -1
- 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.d.ts +2 -1
- 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.d.ts +5 -0
- package/dist/cjs/components/credits/creditsMemberPrice/CreditsMemberPrice.js +2 -0
- package/dist/cjs/components/credits/creditsMemberPrice/CreditsMemberPrice.js.map +7 -0
- package/dist/cjs/components/credits/creditsMemberPrice/MemberPriceItem.d.ts +7 -0
- package/dist/cjs/components/credits/creditsMemberPrice/MemberPriceItem.js +2 -0
- package/dist/cjs/components/credits/creditsMemberPrice/MemberPriceItem.js.map +7 -0
- package/dist/cjs/components/credits/creditsMemberPrice/index.d.ts +2 -0
- package/dist/cjs/components/credits/creditsMemberPrice/index.js +2 -0
- package/dist/cjs/components/credits/creditsMemberPrice/index.js.map +7 -0
- package/dist/cjs/components/credits/creditsMemberPrice/type.d.ts +64 -0
- package/dist/cjs/components/credits/creditsMemberPrice/type.js +2 -0
- package/dist/cjs/components/credits/creditsMemberPrice/type.js.map +7 -0
- package/dist/cjs/components/credits/creditsNavigation/CreditsNavigation.d.ts +4 -0
- package/dist/cjs/components/credits/creditsNavigation/CreditsNavigation.js +2 -0
- package/dist/cjs/components/credits/creditsNavigation/CreditsNavigation.js.map +7 -0
- package/dist/cjs/components/credits/creditsNavigation/index.d.ts +2 -0
- package/dist/cjs/components/credits/creditsNavigation/index.js +2 -0
- package/dist/cjs/components/credits/creditsNavigation/index.js.map +7 -0
- package/dist/cjs/components/credits/creditsNavigation/type.d.ts +7 -0
- package/dist/cjs/components/credits/creditsNavigation/type.js +2 -0
- package/dist/cjs/components/credits/creditsNavigation/type.js.map +7 -0
- package/dist/cjs/components/credits/creditsRedeemList/CreditsRedeemList.d.ts +2 -1
- 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/Error.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Error.js.map +2 -2
- package/dist/cjs/components/credits/creditsRedeemList/type.d.ts +1 -0
- package/dist/cjs/components/credits/creditsRedeemList/type.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/type.js.map +1 -1
- package/dist/cjs/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.d.ts +3 -1
- package/dist/cjs/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js +1 -1
- package/dist/cjs/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js.map +3 -3
- package/dist/cjs/templates/credits.d.ts +15 -1
- package/dist/cjs/templates/credits.js +2 -2
- package/dist/cjs/templates/credits.js.map +4 -4
- package/dist/cjs/templates/index.d.ts +1 -1
- package/dist/cjs/templates/index.js +1 -1
- package/dist/cjs/templates/index.js.map +1 -1
- package/dist/esm/components/credits/context/hooks/useActivities.js +1 -1
- package/dist/esm/components/credits/context/hooks/useActivities.js.map +3 -3
- package/dist/esm/components/credits/context/hooks/useAlpcFetch.js +1 -1
- package/dist/esm/components/credits/context/hooks/useAlpcFetch.js.map +3 -3
- package/dist/esm/components/credits/context/hooks/useFunctionMemberPrice.d.ts +7 -0
- package/dist/esm/components/credits/context/hooks/useFunctionMemberPrice.js +2 -0
- package/dist/esm/components/credits/context/hooks/useFunctionMemberPrice.js.map +7 -0
- package/dist/esm/components/credits/context/hooks/useMyRewards.js +1 -1
- package/dist/esm/components/credits/context/hooks/useMyRewards.js.map +3 -3
- package/dist/esm/components/credits/context/hooks/useRedeemCoupon.js +1 -1
- package/dist/esm/components/credits/context/hooks/useRedeemCoupon.js.map +3 -3
- package/dist/esm/components/credits/context/hooks/useRedeemProduct.js +1 -1
- package/dist/esm/components/credits/context/hooks/useRedeemProduct.js.map +3 -3
- package/dist/esm/components/credits/context/hooks/useRedeemableList.js +1 -1
- package/dist/esm/components/credits/context/hooks/useRedeemableList.js.map +3 -3
- package/dist/esm/components/credits/context/memberPriceConst.d.ts +10 -0
- package/dist/esm/components/credits/context/memberPriceConst.js +2 -0
- package/dist/esm/components/credits/context/memberPriceConst.js.map +7 -0
- package/dist/esm/components/credits/context/memberPriceTypes.d.ts +46 -0
- package/dist/esm/components/credits/context/memberPriceTypes.js +1 -0
- package/dist/esm/components/credits/context/memberPriceTypes.js.map +7 -0
- package/dist/esm/components/credits/context/provider.d.ts +4 -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/atobID.d.ts +1 -0
- package/dist/esm/components/credits/context/utils/atobID.js +2 -0
- package/dist/esm/components/credits/context/utils/atobID.js.map +7 -0
- package/dist/esm/components/credits/context/utils/functionDiscountCalculate.d.ts +5 -0
- package/dist/esm/components/credits/context/utils/functionDiscountCalculate.js +2 -0
- package/dist/esm/components/credits/context/utils/functionDiscountCalculate.js.map +7 -0
- package/dist/esm/components/credits/context/utils/getFunctionMemberPrice.d.ts +8 -0
- package/dist/esm/components/credits/context/utils/getFunctionMemberPrice.js +2 -0
- package/dist/esm/components/credits/context/utils/getFunctionMemberPrice.js.map +7 -0
- package/dist/esm/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.d.ts +9 -0
- package/dist/esm/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.js +2 -0
- package/dist/esm/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.js.map +7 -0
- package/dist/esm/components/credits/context/utils/variantGetCoupon.d.ts +6 -0
- package/dist/esm/components/credits/context/utils/variantGetCoupon.js +2 -0
- package/dist/esm/components/credits/context/utils/variantGetCoupon.js.map +7 -0
- package/dist/esm/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.d.ts +4 -0
- package/dist/esm/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.js +2 -0
- package/dist/esm/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.js.map +7 -0
- package/dist/esm/components/credits/creditsAnkersolixTask/index.d.ts +2 -0
- package/dist/esm/components/credits/creditsAnkersolixTask/index.js +2 -0
- package/dist/esm/components/credits/creditsAnkersolixTask/index.js.map +7 -0
- package/dist/esm/components/credits/creditsAnkersolixTask/type.d.ts +1 -0
- package/dist/esm/components/credits/creditsAnkersolixTask/type.js +2 -0
- package/dist/esm/components/credits/creditsAnkersolixTask/type.js.map +7 -0
- package/dist/esm/components/credits/creditsBanner/index.d.ts +2 -1
- package/dist/esm/components/credits/creditsBanner/index.js +1 -1
- package/dist/esm/components/credits/creditsBanner/index.js.map +3 -3
- package/dist/esm/components/credits/creditsBenefits/benefitItem.d.ts +4 -1
- package/dist/esm/components/credits/creditsBenefits/benefitItem.js +2 -2
- package/dist/esm/components/credits/creditsBenefits/benefitItem.js.map +4 -4
- package/dist/esm/components/credits/creditsBenefits/iconInfo.js +1 -1
- package/dist/esm/components/credits/creditsBenefits/iconInfo.js.map +2 -2
- package/dist/esm/components/credits/creditsBenefits/index.d.ts +6 -2
- package/dist/esm/components/credits/creditsBenefits/index.js +3 -3
- package/dist/esm/components/credits/creditsBenefits/index.js.map +3 -3
- package/dist/esm/components/credits/creditsCash/CreditsCash.d.ts +2 -1
- package/dist/esm/components/credits/creditsCash/CreditsCash.js +1 -1
- package/dist/esm/components/credits/creditsCash/CreditsCash.js.map +3 -3
- package/dist/esm/components/credits/creditsCash/RedeemableItem.js +1 -1
- package/dist/esm/components/credits/creditsCash/RedeemableItem.js.map +2 -2
- package/dist/esm/components/credits/creditsFaq/index.d.ts +2 -1
- 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.d.ts +2 -1
- package/dist/esm/components/credits/creditsInfoCard/index.js +1 -1
- package/dist/esm/components/credits/creditsInfoCard/index.js.map +3 -3
- package/dist/esm/components/credits/creditsMemberPrice/CreditsMemberPrice.d.ts +5 -0
- package/dist/esm/components/credits/creditsMemberPrice/CreditsMemberPrice.js +2 -0
- package/dist/esm/components/credits/creditsMemberPrice/CreditsMemberPrice.js.map +7 -0
- package/dist/esm/components/credits/creditsMemberPrice/MemberPriceItem.d.ts +7 -0
- package/dist/esm/components/credits/creditsMemberPrice/MemberPriceItem.js +2 -0
- package/dist/esm/components/credits/creditsMemberPrice/MemberPriceItem.js.map +7 -0
- package/dist/esm/components/credits/creditsMemberPrice/index.d.ts +2 -0
- package/dist/esm/components/credits/creditsMemberPrice/index.js +2 -0
- package/dist/esm/components/credits/creditsMemberPrice/index.js.map +7 -0
- package/dist/esm/components/credits/creditsMemberPrice/type.d.ts +64 -0
- package/dist/esm/components/credits/creditsMemberPrice/type.js +1 -0
- package/dist/esm/components/credits/creditsMemberPrice/type.js.map +7 -0
- package/dist/esm/components/credits/creditsNavigation/CreditsNavigation.d.ts +4 -0
- package/dist/esm/components/credits/creditsNavigation/CreditsNavigation.js +2 -0
- package/dist/esm/components/credits/creditsNavigation/CreditsNavigation.js.map +7 -0
- package/dist/esm/components/credits/creditsNavigation/index.d.ts +2 -0
- package/dist/esm/components/credits/creditsNavigation/index.js +2 -0
- package/dist/esm/components/credits/creditsNavigation/index.js.map +7 -0
- package/dist/esm/components/credits/creditsNavigation/type.d.ts +7 -0
- package/dist/esm/components/credits/creditsNavigation/type.js +1 -0
- package/dist/esm/components/credits/creditsNavigation/type.js.map +7 -0
- package/dist/esm/components/credits/creditsRedeemList/CreditsRedeemList.d.ts +2 -1
- 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/Error.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Error.js.map +2 -2
- package/dist/esm/components/credits/creditsRedeemList/type.d.ts +1 -0
- package/dist/esm/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.d.ts +3 -1
- package/dist/esm/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js +1 -1
- package/dist/esm/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js.map +3 -3
- package/dist/esm/templates/credits.d.ts +15 -1
- package/dist/esm/templates/credits.js +2 -2
- package/dist/esm/templates/credits.js.map +4 -4
- package/dist/esm/templates/index.d.ts +1 -1
- package/dist/esm/templates/index.js +1 -1
- package/dist/esm/templates/index.js.map +1 -1
- package/dist/index.js +40660 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +40648 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +21 -20
- package/src/components/credits/context/hooks/useActivities.ts +3 -2
- package/src/components/credits/context/hooks/useAlpcFetch.ts +8 -4
- package/src/components/credits/context/hooks/useFunctionMemberPrice.ts +33 -0
- package/src/components/credits/context/hooks/useMyRewards.ts +3 -2
- package/src/components/credits/context/hooks/useRedeemCoupon.ts +4 -1
- package/src/components/credits/context/hooks/useRedeemProduct.ts +4 -1
- package/src/components/credits/context/hooks/useRedeemableList.ts +3 -3
- package/src/components/credits/context/memberPriceConst.ts +13 -0
- package/src/components/credits/context/memberPriceTypes.ts +54 -0
- package/src/components/credits/context/provider.tsx +9 -0
- package/src/components/credits/context/utils/atobID.ts +8 -0
- package/src/components/credits/context/utils/functionDiscountCalculate.ts +57 -0
- package/src/components/credits/context/utils/getFunctionMemberPrice.ts +135 -0
- package/src/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.ts +51 -0
- package/src/components/credits/context/utils/variantGetCoupon.ts +34 -0
- package/src/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.tsx +270 -0
- package/src/components/credits/creditsAnkersolixTask/index.ts +2 -0
- package/src/components/credits/creditsAnkersolixTask/type.ts +7 -0
- package/src/components/credits/creditsBanner/index.tsx +2 -2
- package/src/components/credits/creditsBenefits/{benefitItem.tsx → BenefitItem.tsx} +28 -9
- package/src/components/credits/creditsBenefits/index.tsx +12 -3
- package/src/components/credits/creditsCash/CreditsCash.tsx +5 -3
- package/src/components/credits/creditsCash/RedeemableItem.tsx +19 -15
- package/src/components/credits/creditsFaq/index.tsx +2 -2
- package/src/components/credits/creditsInfoCard/index.tsx +2 -2
- package/src/components/credits/creditsMemberPrice/CreditsMemberPrice.tsx +389 -0
- package/src/components/credits/creditsMemberPrice/MemberPriceItem.tsx +158 -0
- package/src/components/credits/creditsMemberPrice/index.ts +2 -0
- package/src/components/credits/creditsMemberPrice/type.ts +75 -0
- package/src/components/credits/creditsNavigation/CreditsNavigation.tsx +123 -0
- package/src/components/credits/creditsNavigation/index.ts +2 -0
- package/src/components/credits/creditsNavigation/type.ts +10 -0
- package/src/components/credits/creditsRedeemList/CreditsRedeemList.tsx +17 -3
- package/src/components/credits/creditsRedeemList/RedeemProductModal/Error.tsx +1 -1
- package/src/components/credits/creditsRedeemList/type.ts +1 -0
- package/src/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.tsx +2 -2
- package/src/templates/{credits.tsx → Credits.tsx} +38 -7
- package/src/templates/index.ts +1 -1
- package/dist/cjs/components/credits/const.d.ts +0 -1
- package/dist/cjs/components/credits/const.js +0 -2
- package/dist/cjs/components/credits/const.js.map +0 -7
- package/dist/esm/components/credits/const.d.ts +0 -1
- package/dist/esm/components/credits/const.js +0 -2
- package/dist/esm/components/credits/const.js.map +0 -7
- /package/src/components/credits/creditsBenefits/{iconInfo.tsx → IconInfo.tsx} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var z=(t,e)=>{for(var r in e)c(t,r,{get:e[r],enumerable:!0})},B=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of R(e))!h.call(t,s)&&s!==r&&c(t,s,{get:()=>e[s],enumerable:!(o=P(e,s))||o.enumerable});return t};var M=t=>B(c({},"__esModule",{value:!0}),t);var E={};z(E,{default:()=>k});module.exports=M(E);var i=require("react"),p=require("./useAlpcFetch"),f=require("../provider"),b=require("@anker-in/lib");function S({page:t,pageSize:e,options:r={}}){const{profile:o,isLoadingProfile:s,alpcBrand:C}=(0,f.useCreditsContext)(),{brand:L}=(0,b.useHeadlessContext)(),v=C||L,[n,_]=(0,i.useState)([]),[u,x]=(0,i.useState)(0),[d,A]=(0,i.useState)(0),{isMutating:a,trigger:g}=(0,p.useAlpcMutation)({url:"/v1/credit/log",initData:{brand:v}}),l=(0,i.useCallback)(async()=>{const y={page:t,page_size:e,user_id:o?.user_id,...r};g(y,{onSuccess(m){A(t),x(m?.data?.total),_(n.concat(m?.data?.creditLogs||[]))}})},[n,o,t,e,r,g]);return(0,i.useEffect)(()=>{s||!o||a||t!==d&&t&&l()},[l,s,a,o,t,d]),{activities:n,isLoading:a,total:u,canNext:u>n.length&&!a}}var k=S;
|
|
2
2
|
//# sourceMappingURL=useActivities.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useActivities.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { useAlpcMutation } from './useAlpcFetch'\nimport type { CreditLogResponse } from '../response'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useActivities({ page, pageSize, options = {} }: { page: number; pageSize: number; options?: any }) {\n const { profile, isLoadingProfile } = useCreditsContext()\n const { brand } = useHeadlessContext()\n const [activities, setActivities] = useState<CreditLogResponse[]>([])\n const [total, setTotal] = useState(0)\n\n const [currentPage, setCurrentPage] = useState(0)\n\n const { isMutating: isLoading, trigger } = useAlpcMutation<\n {\n data: {\n total: number\n creditLogs: CreditLogResponse[]\n }\n },\n {\n page: number\n page_size: number\n user_id: string\n }\n >({\n url: `/v1/credit/log`,\n initData: {\n brand,\n },\n })\n\n const getActivities = useCallback(async () => {\n const params = {\n page: page,\n page_size: pageSize,\n user_id: profile?.user_id,\n ...options,\n }\n\n trigger(params, {\n onSuccess(responseData) {\n setCurrentPage(page)\n setTotal(responseData?.data?.total)\n setActivities(activities.concat(responseData?.data?.creditLogs || []))\n },\n })\n }, [activities, profile, page, pageSize, options, trigger])\n\n useEffect(() => {\n if (isLoadingProfile || !profile || isLoading) {\n return\n }\n\n if (page !== currentPage && page) {\n getActivities()\n }\n }, [getActivities, isLoadingProfile, isLoading, profile, page, currentPage])\n\n return {\n activities,\n isLoading,\n total,\n canNext: total > activities.length && !isLoading,\n }\n}\n\nexport default useActivities\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiD,iBAEjDC,EAAgC,0BAEhCC,EAAkC,uBAClCC,EAAmC,yBAEnC,SAASC,EAAc,CAAE,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAU,CAAC,CAAE,EAAsD,CAC1G,KAAM,CAAE,QAAAC,EAAS,iBAAAC,
|
|
6
|
-
"names": ["useActivities_exports", "__export", "useActivities_default", "__toCommonJS", "import_react", "import_useAlpcFetch", "import_provider", "import_lib", "useActivities", "page", "pageSize", "options", "profile", "isLoadingProfile", "brand", "activities", "setActivities", "total", "setTotal", "currentPage", "setCurrentPage", "isLoading", "trigger", "getActivities", "params", "responseData"]
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { useAlpcMutation } from './useAlpcFetch'\nimport type { CreditLogResponse } from '../response'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useActivities({ page, pageSize, options = {} }: { page: number; pageSize: number; options?: any }) {\n const { profile, isLoadingProfile, alpcBrand } = useCreditsContext()\n const { brand: headlessBrand } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n const [activities, setActivities] = useState<CreditLogResponse[]>([])\n const [total, setTotal] = useState(0)\n\n const [currentPage, setCurrentPage] = useState(0)\n\n const { isMutating: isLoading, trigger } = useAlpcMutation<\n {\n data: {\n total: number\n creditLogs: CreditLogResponse[]\n }\n },\n {\n page: number\n page_size: number\n user_id: string\n }\n >({\n url: `/v1/credit/log`,\n initData: {\n brand,\n },\n })\n\n const getActivities = useCallback(async () => {\n const params = {\n page: page,\n page_size: pageSize,\n user_id: profile?.user_id,\n ...options,\n }\n\n trigger(params, {\n onSuccess(responseData) {\n setCurrentPage(page)\n setTotal(responseData?.data?.total)\n setActivities(activities.concat(responseData?.data?.creditLogs || []))\n },\n })\n }, [activities, profile, page, pageSize, options, trigger])\n\n useEffect(() => {\n if (isLoadingProfile || !profile || isLoading) {\n return\n }\n\n if (page !== currentPage && page) {\n getActivities()\n }\n }, [getActivities, isLoadingProfile, isLoading, profile, page, currentPage])\n\n return {\n activities,\n isLoading,\n total,\n canNext: total > activities.length && !isLoading,\n }\n}\n\nexport default useActivities\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiD,iBAEjDC,EAAgC,0BAEhCC,EAAkC,uBAClCC,EAAmC,yBAEnC,SAASC,EAAc,CAAE,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAU,CAAC,CAAE,EAAsD,CAC1G,KAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,UAAAC,CAAU,KAAI,qBAAkB,EAC7D,CAAE,MAAOC,CAAc,KAAI,sBAAmB,EAC9CC,EAAQF,GAAaC,EACrB,CAACE,EAAYC,CAAa,KAAI,YAA8B,CAAC,CAAC,EAC9D,CAACC,EAAOC,CAAQ,KAAI,YAAS,CAAC,EAE9B,CAACC,EAAaC,CAAc,KAAI,YAAS,CAAC,EAE1C,CAAE,WAAYC,EAAW,QAAAC,CAAQ,KAAI,mBAYzC,CACA,IAAK,iBACL,SAAU,CACR,MAAAR,CACF,CACF,CAAC,EAEKS,KAAgB,eAAY,SAAY,CAC5C,MAAMC,EAAS,CACb,KAAMjB,EACN,UAAWC,EACX,QAASE,GAAS,QAClB,GAAGD,CACL,EAEAa,EAAQE,EAAQ,CACd,UAAUC,EAAc,CACtBL,EAAeb,CAAI,EACnBW,EAASO,GAAc,MAAM,KAAK,EAClCT,EAAcD,EAAW,OAAOU,GAAc,MAAM,YAAc,CAAC,CAAC,CAAC,CACvE,CACF,CAAC,CACH,EAAG,CAACV,EAAYL,EAASH,EAAMC,EAAUC,EAASa,CAAO,CAAC,EAE1D,sBAAU,IAAM,CACVX,GAAoB,CAACD,GAAWW,GAIhCd,IAASY,GAAeZ,GAC1BgB,EAAc,CAElB,EAAG,CAACA,EAAeZ,EAAkBU,EAAWX,EAASH,EAAMY,CAAW,CAAC,EAEpE,CACL,WAAAJ,EACA,UAAAM,EACA,MAAAJ,EACA,QAASA,EAAQF,EAAW,QAAU,CAACM,CACzC,CACF,CAEA,IAAOrB,EAAQM",
|
|
6
|
+
"names": ["useActivities_exports", "__export", "useActivities_default", "__toCommonJS", "import_react", "import_useAlpcFetch", "import_provider", "import_lib", "useActivities", "page", "pageSize", "options", "profile", "isLoadingProfile", "alpcBrand", "headlessBrand", "brand", "activities", "setActivities", "total", "setTotal", "currentPage", "setCurrentPage", "isLoading", "trigger", "getActivities", "params", "responseData"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var P=Object.create;var
|
|
1
|
+
"use strict";var P=Object.create;var O=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var I=(t,e)=>{for(var r in e)O(t,r,{get:e[r],enumerable:!0})},S=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of q(e))!v.call(t,a)&&a!==r&&O(t,a,{get:()=>e[a],enumerable:!(n=F(e,a))||n.enumerable});return t};var x=(t,e,r)=>(r=t!=null?P(j(t)):{},S(e||!t||!t.__esModule?O(r,"default",{value:t,enumerable:!0}):r,t)),$=t=>S(O({},"__esModule",{value:!0}),t);var J={};I(J,{useAlpcFetch:()=>N,useAlpcMutation:()=>W});module.exports=$(J);var A=x(require("js-cookie")),o=require("react"),C=x(require("swr")),U=require("@anker-in/lib"),m=require("../utils"),b=require("../provider");let R;const B=t=>fetch((0,m.getAlpcPath)(t.locale)+t.url,t.fetchOptions).then(async e=>{if(e.status<300)return(await e.json()).data;if(e.status===401&&t.onReAuth){R||(R=t.onReAuth());const r=await R;if(R=void 0,r)return fetch((0,m.getAlpcPath)(t.locale)+t.url,t.fetchOptions).then(async n=>{if(n.status<300)return(await n.json()).data;if(n.status===401){t.onUnAuth&&t.onUnAuth();return}});t.onUnAuth&&t.onUnAuth();return}}),w=async(t,e,r)=>{let n=await fetch(`${(0,m.getAlpcPath)(t)}/cloud/login`,{method:"POST"}),a=await n.json();if(n.status<300&&!e&&a?.data?.code===27004){const s=A.default.get("alpcEU");if(Number(s)===1?A.default.set("alpcEU","0",{expires:30,domain:`.${r}.com`}):A.default.set("alpcEU","1",{expires:30,domain:`.${r}.com`}),n=await fetch(`${(0,m.getAlpcPath)(t)}/cloud/login`,{method:"POST"}),a=await n.json(),n.status>300)return!1}return!a?.data?.code},k=(t,e,r={})=>{const n=(0,o.useRef)(!1),[a,s]=(0,o.useState)(),[c,i]=(0,o.useState)(!1),u=(0,o.useRef)(t),d=(0,o.useRef)(e),h=(0,o.useRef)(r),g=(0,o.useCallback)(async(y,D={})=>{if(n.current)return;n.current=!0,i(!0);const p={...h.current,...D},{onSuccess:f,onError:T}=p||{};try{const l=await d.current(u.current,{arg:y});return s(l),i(!1),n.current=!1,f&&f(l),l}catch(l){i(!1),n.current=!1,T&&T(l)}},[]);return{isMutating:c,trigger:g,data:a}},N=(t,e)=>{const[r,n]=(0,o.useState)(!1),{removeProfile:a,alpcBrand:s}=(0,b.useCreditsContext)(),{enable:c,...i}=e||{},{locale:u="",brand:d}=(0,U.useHeadlessContext)(),h=s||d,{queryKey:g=[],body:y={},headers:D,...p}=t,f=c??!0,[T,l]=g;return(0,C.default)([T,l],f?([E,M])=>B({url:E,locale:u,fetchOptions:{method:"POST",headers:{"current-language":u,...D},body:JSON.stringify({...y,...M}),...p},onReAuth:async()=>await w(u,r,h)?(n(!0),!0):!1,onUnAuth(){a()}}):null,{revalidateOnFocus:!1,...i})},W=(t,e)=>{const[r,n]=(0,o.useState)(!1),{removeProfile:a,alpcBrand:s}=(0,b.useCreditsContext)(),{locale:c="",brand:i}=(0,U.useHeadlessContext)(),u=s||i,{url:d,initData:h,headers:g,...y}=t;return k(d,(p,f)=>B({url:p,locale:c,fetchOptions:{method:"POST",headers:{"current-language":c,...g},...y,body:JSON.stringify({...h,...f.arg})},onReAuth:async()=>await w(c,r,u)?(n(!0),!0):!1,onUnAuth(){a()}}),e)};
|
|
2
2
|
//# sourceMappingURL=useAlpcFetch.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useAlpcFetch.ts"],
|
|
4
|
-
"sourcesContent": ["import Cookies from 'js-cookie'\nimport { useCallback, useRef, useState } from 'react'\nimport useSWR, { type SWRConfiguration } from 'swr'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nimport { getAlpcPath } from '../utils'\nimport { useCreditsContext } from '../provider'\n\ninterface UseAlpcFetchOptionsSwrOptions<TData, Error> extends SWRConfiguration<TData, Error> {\n enable?: boolean\n}\n\ninterface FetchOptions extends RequestInit {\n queryKey: [string, Record<string, any>]\n data?: Record<string, any>\n}\n\ninterface MutationOptions extends RequestInit {\n url: string\n initData: Record<string, any>\n}\n\ninterface FetcherOptions {\n url: string\n locale: string\n fetchOptions: RequestInit\n onReAuth: () => Promise<boolean>\n onUnAuth: () => void\n}\n\nlet reAuthPromise: Promise<boolean> | undefined\n\ntype Fetcher<TData, TBody> = (url: string, data: { arg: TBody }) => Promise<TData>\n\nconst fetcher = (options: FetcherOptions) => {\n return fetch(getAlpcPath(options.locale) + options.url, options.fetchOptions).then(async response => {\n if (response.status < 300) {\n const responseData = await response.json()\n return responseData.data\n }\n\n // \u9519\u8BEF\u5904\u7406\n if (response.status === 401) {\n // \u91CD\u65B0\u767B\u5F55\u5C1D\u8BD5\n if (options.onReAuth) {\n if (!reAuthPromise) {\n reAuthPromise = options.onReAuth()\n }\n\n const result = await reAuthPromise\n\n reAuthPromise = undefined\n\n if (result) {\n // \u8DE8\u533A\u91CD\u65B0\u767B\u5F55\u540E\u9700\u8981\u66FF\u6362\u533A\u57DF\u6807\u5FD7\uFF0C\u6240\u4EE5\u4E0D\u80FD\u7528\u6700\u5F00\u59CB\u8BF7\u6C42\u7684\u90A3\u4E2A\u94FE\u63A5\n return fetch(getAlpcPath(options.locale) + options.url, options.fetchOptions).then(async response => {\n if (response.status < 300) {\n const responseData = await response.json()\n return responseData.data\n }\n\n if (response.status === 401) {\n if (options.onUnAuth) {\n options.onUnAuth()\n }\n return\n }\n })\n } else {\n if (options.onUnAuth) {\n options.onUnAuth()\n }\n return\n }\n }\n }\n })\n}\n\nconst reAuth = async (locale: string, retry: boolean, brand: string) => {\n let reloginResponse = await fetch(`${getAlpcPath(locale)}/cloud/login`, {\n method: 'POST',\n })\n let reloginResponseData = await reloginResponse.json()\n\n if (reloginResponse!.status < 300 && !retry) {\n if (reloginResponseData?.data?.code === 27004) {\n // \u8DE8\u533A\u767B\u5F55\u9519\u8BEF\n const alpcEUCookie = Cookies.get('alpcEU')\n\n if (Number(alpcEUCookie) === 1) {\n Cookies.set('alpcEU', '0', {\n expires: 30,\n domain: `.${brand}.com`,\n })\n } else {\n Cookies.set('alpcEU', '1', {\n expires: 30,\n domain: `.${brand}.com`,\n })\n }\n\n // \u91CD\u65B0\u5C1D\u8BD5\u6362\u533A\u767B\u5F55\n reloginResponse = await fetch(`${getAlpcPath(locale)}/cloud/login`, {\n method: 'POST',\n })\n reloginResponseData = await reloginResponse.json()\n\n if (reloginResponse.status > 300) {\n return false\n }\n }\n }\n if (!reloginResponseData?.data?.code) {\n // \u91CD\u65B0\u767B\u5F55\u6210\u529F\n return true\n }\n\n return false\n}\n\nexport interface UseMutationConfig<TData> {\n onSuccess?: (response: TData) => any\n onError?: (error: Error) => any\n}\n\nconst useMutation = <TData, TBody>(\n url: string,\n fetcher: Fetcher<TData, TBody>,\n mutationConfig: UseMutationConfig<TData> = {}\n) => {\n const innerMutating = useRef<boolean>(false)\n\n const [data, setData] = useState<TData>()\n const [isMutating, setIsMutating] = useState(false)\n\n const urlRef = useRef(url)\n const fetcherRef = useRef(fetcher)\n const configRef = useRef(mutationConfig)\n\n const trigger = useCallback(\n async (fetchData: TBody, opts: UseMutationConfig<TData> = {}) => {\n if (innerMutating.current) {\n return\n }\n\n innerMutating.current = true\n setIsMutating(true)\n\n const config = {\n ...configRef.current,\n ...opts,\n }\n\n const { onSuccess, onError } = config || {}\n\n try {\n const fetchResult = await fetcherRef.current(urlRef.current, {\n arg: fetchData,\n })\n setData(fetchResult)\n\n setIsMutating(false)\n innerMutating.current = false\n\n if (onSuccess) {\n onSuccess(fetchResult)\n }\n return fetchResult\n } catch (err: any) {\n setIsMutating(false)\n innerMutating.current = false\n\n if (onError) {\n onError(err)\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n )\n\n return {\n isMutating,\n trigger,\n data,\n }\n}\n\nexport const useAlpcFetch = <TData>(\n options: FetchOptions,\n swrOptions?: UseAlpcFetchOptionsSwrOptions<TData, Error>\n) => {\n const [retry, setRetry] = useState(false)\n const { removeProfile } = useCreditsContext()\n\n const { enable, ...otherSwrOptions } = swrOptions || {}\n\n const { locale = '', brand } = useHeadlessContext()\n\n const { queryKey = [], body: fetchBody = {}, headers, ...fetchOptions } = options\n const fetchEnable = enable ?? true\n\n const [url, requestBody] = queryKey\n\n const context = useSWR<TData>(\n [url, requestBody],\n !fetchEnable\n ? null\n : ([requestUrl, data]: [string, Record<string, any>]) =>\n fetcher({\n url: requestUrl,\n locale,\n fetchOptions: {\n method: 'POST',\n headers: {\n 'current-language': locale,\n ...headers,\n },\n body: JSON.stringify({\n ...fetchBody,\n ...data,\n }),\n ...fetchOptions,\n },\n onReAuth: async () => {\n const result = await reAuth(locale, retry, brand)\n\n if (result) {\n setRetry(true)\n return true\n }\n\n return false\n },\n onUnAuth() {\n // \u5931\u8D25\u540E\u9000\u51FA\u767B\u5F55\n removeProfile()\n },\n }),\n {\n revalidateOnFocus: false,\n ...otherSwrOptions,\n }\n )\n\n return context\n}\n\nexport const useAlpcMutation = <TData, TBody>(options: MutationOptions, mutationOptions?: UseMutationConfig<TData>) => {\n const [retry, setRetry] = useState(false)\n const { removeProfile } = useCreditsContext()\n\n const { locale = '', brand } = useHeadlessContext()\n\n const { url, initData, headers, ...fetchOptions } = options\n\n const context = useMutation<TData, TBody>(\n url,\n (requestUrl, data: { arg: TBody }) =>\n fetcher({\n url: requestUrl,\n locale,\n fetchOptions: {\n method: 'POST',\n headers: {\n 'current-language': locale,\n ...headers,\n },\n ...fetchOptions,\n body: JSON.stringify({\n ...initData,\n ...data.arg,\n }),\n },\n onReAuth: async () => {\n const result = await reAuth(locale, retry, brand)\n\n if (result) {\n setRetry(true)\n return true\n }\n\n return false\n },\n onUnAuth() {\n // \u5931\u8D25\u540E\u9000\u51FA\u767B\u5F55\n removeProfile()\n },\n }),\n mutationOptions\n )\n\n return context\n}\n"],
|
|
5
|
-
"mappings": "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
|
|
6
|
-
"names": ["useAlpcFetch_exports", "__export", "useAlpcFetch", "useAlpcMutation", "__toCommonJS", "import_js_cookie", "import_react", "import_swr", "import_lib", "import_utils", "import_provider", "reAuthPromise", "fetcher", "options", "response", "result", "reAuth", "locale", "retry", "brand", "reloginResponse", "reloginResponseData", "alpcEUCookie", "Cookies", "useMutation", "url", "mutationConfig", "innerMutating", "data", "setData", "isMutating", "setIsMutating", "urlRef", "fetcherRef", "configRef", "trigger", "fetchData", "opts", "config", "onSuccess", "onError", "fetchResult", "err", "swrOptions", "setRetry", "removeProfile", "enable", "otherSwrOptions", "queryKey", "fetchBody", "headers", "fetchOptions", "fetchEnable", "requestBody", "useSWR", "requestUrl", "mutationOptions", "initData"]
|
|
4
|
+
"sourcesContent": ["import Cookies from 'js-cookie'\nimport { useCallback, useRef, useState } from 'react'\nimport useSWR, { type SWRConfiguration } from 'swr'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nimport { getAlpcPath } from '../utils'\nimport { useCreditsContext } from '../provider'\n\ninterface UseAlpcFetchOptionsSwrOptions<TData, Error> extends SWRConfiguration<TData, Error> {\n enable?: boolean\n}\n\ninterface FetchOptions extends RequestInit {\n queryKey: [string, Record<string, any>]\n data?: Record<string, any>\n}\n\ninterface MutationOptions extends RequestInit {\n url: string\n initData: Record<string, any>\n}\n\ninterface FetcherOptions {\n url: string\n locale: string\n fetchOptions: RequestInit\n onReAuth: () => Promise<boolean>\n onUnAuth: () => void\n}\n\nlet reAuthPromise: Promise<boolean> | undefined\n\ntype Fetcher<TData, TBody> = (url: string, data: { arg: TBody }) => Promise<TData>\n\nconst fetcher = (options: FetcherOptions) => {\n return fetch(getAlpcPath(options.locale) + options.url, options.fetchOptions).then(async response => {\n if (response.status < 300) {\n const responseData = await response.json()\n return responseData.data\n }\n\n // \u9519\u8BEF\u5904\u7406\n if (response.status === 401) {\n // \u91CD\u65B0\u767B\u5F55\u5C1D\u8BD5\n if (options.onReAuth) {\n if (!reAuthPromise) {\n reAuthPromise = options.onReAuth()\n }\n\n const result = await reAuthPromise\n\n reAuthPromise = undefined\n\n if (result) {\n // \u8DE8\u533A\u91CD\u65B0\u767B\u5F55\u540E\u9700\u8981\u66FF\u6362\u533A\u57DF\u6807\u5FD7\uFF0C\u6240\u4EE5\u4E0D\u80FD\u7528\u6700\u5F00\u59CB\u8BF7\u6C42\u7684\u90A3\u4E2A\u94FE\u63A5\n return fetch(getAlpcPath(options.locale) + options.url, options.fetchOptions).then(async response => {\n if (response.status < 300) {\n const responseData = await response.json()\n return responseData.data\n }\n\n if (response.status === 401) {\n if (options.onUnAuth) {\n options.onUnAuth()\n }\n return\n }\n })\n } else {\n if (options.onUnAuth) {\n options.onUnAuth()\n }\n return\n }\n }\n }\n })\n}\n\nconst reAuth = async (locale: string, retry: boolean, brand: string) => {\n let reloginResponse = await fetch(`${getAlpcPath(locale)}/cloud/login`, {\n method: 'POST',\n })\n let reloginResponseData = await reloginResponse.json()\n\n if (reloginResponse!.status < 300 && !retry) {\n if (reloginResponseData?.data?.code === 27004) {\n // \u8DE8\u533A\u767B\u5F55\u9519\u8BEF\n const alpcEUCookie = Cookies.get('alpcEU')\n\n if (Number(alpcEUCookie) === 1) {\n Cookies.set('alpcEU', '0', {\n expires: 30,\n domain: `.${brand}.com`,\n })\n } else {\n Cookies.set('alpcEU', '1', {\n expires: 30,\n domain: `.${brand}.com`,\n })\n }\n\n // \u91CD\u65B0\u5C1D\u8BD5\u6362\u533A\u767B\u5F55\n reloginResponse = await fetch(`${getAlpcPath(locale)}/cloud/login`, {\n method: 'POST',\n })\n reloginResponseData = await reloginResponse.json()\n\n if (reloginResponse.status > 300) {\n return false\n }\n }\n }\n if (!reloginResponseData?.data?.code) {\n // \u91CD\u65B0\u767B\u5F55\u6210\u529F\n return true\n }\n\n return false\n}\n\nexport interface UseMutationConfig<TData> {\n onSuccess?: (response: TData) => any\n onError?: (error: Error) => any\n}\n\nconst useMutation = <TData, TBody>(\n url: string,\n fetcher: Fetcher<TData, TBody>,\n mutationConfig: UseMutationConfig<TData> = {}\n) => {\n const innerMutating = useRef<boolean>(false)\n\n const [data, setData] = useState<TData>()\n const [isMutating, setIsMutating] = useState(false)\n\n const urlRef = useRef(url)\n const fetcherRef = useRef(fetcher)\n const configRef = useRef(mutationConfig)\n\n const trigger = useCallback(\n async (fetchData: TBody, opts: UseMutationConfig<TData> = {}) => {\n if (innerMutating.current) {\n return\n }\n\n innerMutating.current = true\n setIsMutating(true)\n\n const config = {\n ...configRef.current,\n ...opts,\n }\n\n const { onSuccess, onError } = config || {}\n\n try {\n const fetchResult = await fetcherRef.current(urlRef.current, {\n arg: fetchData,\n })\n setData(fetchResult)\n\n setIsMutating(false)\n innerMutating.current = false\n\n if (onSuccess) {\n onSuccess(fetchResult)\n }\n return fetchResult\n } catch (err: any) {\n setIsMutating(false)\n innerMutating.current = false\n\n if (onError) {\n onError(err)\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n )\n\n return {\n isMutating,\n trigger,\n data,\n }\n}\n\nexport const useAlpcFetch = <TData>(\n options: FetchOptions,\n swrOptions?: UseAlpcFetchOptionsSwrOptions<TData, Error>\n) => {\n const [retry, setRetry] = useState(false)\n const { removeProfile, alpcBrand } = useCreditsContext()\n\n const { enable, ...otherSwrOptions } = swrOptions || {}\n\n const { locale = '', brand: headlessBrand } = useHeadlessContext()\n // \u4F18\u5148\u4F7F\u7528 creditsContext \u4E2D\u7684 alpcBrand\uFF0C\u5982\u679C\u6CA1\u6709\u5219\u4F7F\u7528 headlessConfig \u4E2D\u7684 brand\n const brand = alpcBrand || headlessBrand\n\n const { queryKey = [], body: fetchBody = {}, headers, ...fetchOptions } = options\n const fetchEnable = enable ?? true\n\n const [url, requestBody] = queryKey\n\n const context = useSWR<TData>(\n [url, requestBody],\n !fetchEnable\n ? null\n : ([requestUrl, data]: [string, Record<string, any>]) =>\n fetcher({\n url: requestUrl,\n locale,\n fetchOptions: {\n method: 'POST',\n headers: {\n 'current-language': locale,\n ...headers,\n },\n body: JSON.stringify({\n ...fetchBody,\n ...data,\n }),\n ...fetchOptions,\n },\n onReAuth: async () => {\n const result = await reAuth(locale, retry, brand)\n\n if (result) {\n setRetry(true)\n return true\n }\n\n return false\n },\n onUnAuth() {\n // \u5931\u8D25\u540E\u9000\u51FA\u767B\u5F55\n removeProfile()\n },\n }),\n {\n revalidateOnFocus: false,\n ...otherSwrOptions,\n }\n )\n\n return context\n}\n\nexport const useAlpcMutation = <TData, TBody>(options: MutationOptions, mutationOptions?: UseMutationConfig<TData>) => {\n const [retry, setRetry] = useState(false)\n const { removeProfile, alpcBrand } = useCreditsContext()\n\n const { locale = '', brand: headlessBrand } = useHeadlessContext()\n // \u4F18\u5148\u4F7F\u7528 creditsContext \u4E2D\u7684 alpcBrand\uFF0C\u5982\u679C\u6CA1\u6709\u5219\u4F7F\u7528 headlessConfig \u4E2D\u7684 brand\n const brand = alpcBrand || headlessBrand\n\n const { url, initData, headers, ...fetchOptions } = options\n\n const context = useMutation<TData, TBody>(\n url,\n (requestUrl, data: { arg: TBody }) =>\n fetcher({\n url: requestUrl,\n locale,\n fetchOptions: {\n method: 'POST',\n headers: {\n 'current-language': locale,\n ...headers,\n },\n ...fetchOptions,\n body: JSON.stringify({\n ...initData,\n ...data.arg,\n }),\n },\n onReAuth: async () => {\n const result = await reAuth(locale, retry, brand)\n\n if (result) {\n setRetry(true)\n return true\n }\n\n return false\n },\n onUnAuth() {\n // \u5931\u8D25\u540E\u9000\u51FA\u767B\u5F55\n removeProfile()\n },\n }),\n mutationOptions\n )\n\n return context\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["useAlpcFetch_exports", "__export", "useAlpcFetch", "useAlpcMutation", "__toCommonJS", "import_js_cookie", "import_react", "import_swr", "import_lib", "import_utils", "import_provider", "reAuthPromise", "fetcher", "options", "response", "result", "reAuth", "locale", "retry", "brand", "reloginResponse", "reloginResponseData", "alpcEUCookie", "Cookies", "useMutation", "url", "mutationConfig", "innerMutating", "data", "setData", "isMutating", "setIsMutating", "urlRef", "fetcherRef", "configRef", "trigger", "fetchData", "opts", "config", "onSuccess", "onError", "fetchResult", "err", "swrOptions", "setRetry", "removeProfile", "alpcBrand", "enable", "otherSwrOptions", "headlessBrand", "queryKey", "fetchBody", "headers", "fetchOptions", "fetchEnable", "requestBody", "useSWR", "requestUrl", "mutationOptions", "initData"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProductVariant } from '@anker-in/lib';
|
|
2
|
+
import { FunctionMemberPriceResult } from '../memberPriceTypes';
|
|
3
|
+
export declare const useFunctionMemberPrice: ({ variant }: {
|
|
4
|
+
variant?: ProductVariant;
|
|
5
|
+
}) => FunctionMemberPriceResult | (Partial<FunctionMemberPriceResult> & {
|
|
6
|
+
hasMemberPrice: false;
|
|
7
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var l=(r,e)=>{for(var o in e)i(r,o,{get:e[o],enumerable:!0})},f=(r,e,o,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of b(e))!a.call(r,t)&&t!==o&&i(r,t,{get:()=>e[t],enumerable:!(c=P(e,t))||c.enumerable});return r};var M=r=>f(i({},"__esModule",{value:!0}),r);var d={};l(d,{useFunctionMemberPrice:()=>p});module.exports=M(d);var m=require("../utils/getFunctionMemberPrice"),n=require("react"),s=require("../provider"),u=require("@anker-in/lib");const p=({variant:r})=>{const{memberPriceDiscount:e}=(0,s.useCreditsContext)(),{locale:o=""}=(0,u.useHeadlessContext)();return(0,n.useMemo)(()=>{const t=(0,m.getFunctionMemberPrice)({memberPriceDiscount:e,currencyCode:r?.price.currencyCode,variant:r,locale:o});return t||{hasMemberPrice:!1}},[o,e,r])};
|
|
2
|
+
//# sourceMappingURL=useFunctionMemberPrice.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/components/credits/context/hooks/useFunctionMemberPrice.ts"],
|
|
4
|
+
"sourcesContent": ["import { ProductVariant } from '@anker-in/lib'\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?: ProductVariant }) => {\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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAEA,IAAAI,EAAuC,2CACvCC,EAAwB,iBACxBC,EAAkC,uBAClCC,EAAmC,yBAG5B,MAAML,EAAyB,CAAC,CAAE,QAAAM,CAAQ,IAAoC,CACnF,KAAM,CAAE,oBAAAC,CAAoB,KAAI,qBAAkB,EAC5C,CAAE,OAAAC,EAAS,EAAG,KAAI,sBAAmB,EAqB3C,SAfS,WAAQ,IAAM,CACrB,MAAMC,KAAS,0BAAuB,CACpC,oBAAqBF,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
|
+
"names": ["useFunctionMemberPrice_exports", "__export", "useFunctionMemberPrice", "__toCommonJS", "import_getFunctionMemberPrice", "import_react", "import_provider", "import_lib", "variant", "memberPriceDiscount", "locale", "result"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var B=(e,t)=>{for(var s in t)m(e,s,{get:t[s],enumerable:!0})},k=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of T(t))!h.call(e,o)&&o!==s&&m(e,o,{get:()=>t[o],enumerable:!(n=N(t,o))||n.enumerable});return e};var v=e=>k(m({},"__esModule",{value:!0}),e);var H={};B(H,{default:()=>E});module.exports=v(H);var r=require("react"),u=require("../const"),f=require("./useAlpcFetch"),C=require("../provider"),y=require("@anker-in/lib");function z({page:e,pageSize:t,consumeType:s}){const{isLoadingProfile:n,profile:o,alpcBrand:R}=(0,C.useCreditsContext)(),{brand:b,locale:p,appName:L}=(0,y.useHeadlessContext)(),A=R||b,M=!!o,[i,l]=(0,r.useState)([]),[_,w]=(0,r.useState)(0),[g,P]=(0,r.useState)(0),{isMutating:a,trigger:c}=(0,f.useAlpcMutation)({url:"/v1/credit/log/coupon",initData:{brand:A,country:u.ALPC_COUNTRY_MAP.get(p)||p,app_name:L}});(0,r.useEffect)(()=>{n||!o||a||e!==g&&e&&c({consume_type:s||u.AlpcConsumeType.Coupon,page:e,page_size:t,user_id:o?.user_id},{onSuccess(d){P(e),w(d?.data?.total),l(i.concat(d?.data?.redeem_logs||[]))}})},[c,i,s,e,t,g,o,n,a]);const x=(0,r.useCallback)(async()=>{n||!M||!o||a||await c({consume_type:s||u.AlpcConsumeType.Coupon,page:e,page_size:t,user_id:o?.user_id},{onSuccess(d){l(d?.data?.redeem_logs||[])}})},[s,a,n,e,t,o,c]);return{myRewards:i,isLoading:a,total:_,getMyRewards:x,canNext:_>i.length&&!a}}var E=z;
|
|
2
2
|
//# sourceMappingURL=useMyRewards.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useMyRewards.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { ALPC_COUNTRY_MAP, AlpcConsumeType } from '../const'\nimport { useAlpcMutation } from './useAlpcFetch'\nimport type { RedeemLogResponse } from '../response'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useMyRewards({\n page,\n pageSize,\n consumeType,\n}: {\n page: number\n pageSize: number\n consumeType?: AlpcConsumeType\n}) {\n const { isLoadingProfile, profile } = useCreditsContext()\n const { brand, locale, appName } = useHeadlessContext()\n const isLogin = !!profile\n\n const [myRewards, setMyRewards] = useState<RedeemLogResponse[]>([])\n const [total, setTotal] = useState(0)\n\n const [currentPage, setCurrentPage] = useState(0)\n\n const { isMutating: isLoading, trigger } = useAlpcMutation<\n { data: { redeem_logs: RedeemLogResponse[]; total: number } },\n {\n page: number\n page_size: number\n consume_type: AlpcConsumeType\n user_id: string\n }\n >({\n url: `/v1/credit/log/coupon`,\n initData: {\n brand: brand,\n country: ALPC_COUNTRY_MAP.get(locale) || locale,\n app_name: appName,\n },\n })\n\n useEffect(() => {\n if (isLoadingProfile || !profile || isLoading) {\n return\n }\n\n if (page !== currentPage && page) {\n trigger(\n {\n consume_type: consumeType || AlpcConsumeType.Coupon,\n page,\n page_size: pageSize,\n user_id: profile?.user_id,\n },\n {\n onSuccess(responseData) {\n setCurrentPage(page)\n setTotal(responseData?.data?.total)\n setMyRewards(myRewards.concat(responseData?.data?.redeem_logs || []))\n },\n }\n )\n }\n }, [trigger, myRewards, consumeType, page, pageSize, currentPage, profile, isLoadingProfile, isLoading])\n\n const getMyRewards = useCallback(async () => {\n if (isLoadingProfile || !isLogin || !profile || isLoading) {\n return\n }\n await trigger(\n {\n consume_type: consumeType || AlpcConsumeType.Coupon,\n page,\n page_size: pageSize,\n user_id: profile?.user_id,\n },\n {\n // \u4EC5\u652F\u63011\u9875\u7684\n onSuccess(responseData) {\n setMyRewards(responseData?.data?.redeem_logs || [])\n },\n }\n )\n }, [consumeType, isLoading, isLoadingProfile, page, pageSize, profile, trigger])\n\n return {\n myRewards,\n isLoading,\n total,\n getMyRewards,\n canNext: total > myRewards.length && !isLoading,\n }\n}\n\nexport default useMyRewards\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiD,iBAEjDC,EAAkD,oBAClDC,EAAgC,0BAEhCC,EAAkC,uBAClCC,EAAmC,yBAEnC,SAASC,EAAa,CACpB,KAAAC,EACA,SAAAC,EACA,YAAAC,CACF,EAIG,CACD,KAAM,CAAE,iBAAAC,EAAkB,QAAAC,
|
|
6
|
-
"names": ["useMyRewards_exports", "__export", "useMyRewards_default", "__toCommonJS", "import_react", "import_const", "import_useAlpcFetch", "import_provider", "import_lib", "useMyRewards", "page", "pageSize", "consumeType", "isLoadingProfile", "profile", "
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { ALPC_COUNTRY_MAP, AlpcConsumeType } from '../const'\nimport { useAlpcMutation } from './useAlpcFetch'\nimport type { RedeemLogResponse } from '../response'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useMyRewards({\n page,\n pageSize,\n consumeType,\n}: {\n page: number\n pageSize: number\n consumeType?: AlpcConsumeType\n}) {\n const { isLoadingProfile, profile, alpcBrand } = useCreditsContext()\n const { brand: headlessBrand, locale, appName } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n const isLogin = !!profile\n\n const [myRewards, setMyRewards] = useState<RedeemLogResponse[]>([])\n const [total, setTotal] = useState(0)\n\n const [currentPage, setCurrentPage] = useState(0)\n\n const { isMutating: isLoading, trigger } = useAlpcMutation<\n { data: { redeem_logs: RedeemLogResponse[]; total: number } },\n {\n page: number\n page_size: number\n consume_type: AlpcConsumeType\n user_id: string\n }\n >({\n url: `/v1/credit/log/coupon`,\n initData: {\n brand: brand,\n country: ALPC_COUNTRY_MAP.get(locale) || locale,\n app_name: appName,\n },\n })\n\n useEffect(() => {\n if (isLoadingProfile || !profile || isLoading) {\n return\n }\n\n if (page !== currentPage && page) {\n trigger(\n {\n consume_type: consumeType || AlpcConsumeType.Coupon,\n page,\n page_size: pageSize,\n user_id: profile?.user_id,\n },\n {\n onSuccess(responseData) {\n setCurrentPage(page)\n setTotal(responseData?.data?.total)\n setMyRewards(myRewards.concat(responseData?.data?.redeem_logs || []))\n },\n }\n )\n }\n }, [trigger, myRewards, consumeType, page, pageSize, currentPage, profile, isLoadingProfile, isLoading])\n\n const getMyRewards = useCallback(async () => {\n if (isLoadingProfile || !isLogin || !profile || isLoading) {\n return\n }\n await trigger(\n {\n consume_type: consumeType || AlpcConsumeType.Coupon,\n page,\n page_size: pageSize,\n user_id: profile?.user_id,\n },\n {\n // \u4EC5\u652F\u63011\u9875\u7684\n onSuccess(responseData) {\n setMyRewards(responseData?.data?.redeem_logs || [])\n },\n }\n )\n }, [consumeType, isLoading, isLoadingProfile, page, pageSize, profile, trigger])\n\n return {\n myRewards,\n isLoading,\n total,\n getMyRewards,\n canNext: total > myRewards.length && !isLoading,\n }\n}\n\nexport default useMyRewards\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiD,iBAEjDC,EAAkD,oBAClDC,EAAgC,0BAEhCC,EAAkC,uBAClCC,EAAmC,yBAEnC,SAASC,EAAa,CACpB,KAAAC,EACA,SAAAC,EACA,YAAAC,CACF,EAIG,CACD,KAAM,CAAE,iBAAAC,EAAkB,QAAAC,EAAS,UAAAC,CAAU,KAAI,qBAAkB,EAC7D,CAAE,MAAOC,EAAe,OAAAC,EAAQ,QAAAC,CAAQ,KAAI,sBAAmB,EAC/DC,EAAQJ,GAAaC,EACrBI,EAAU,CAAC,CAACN,EAEZ,CAACO,EAAWC,CAAY,KAAI,YAA8B,CAAC,CAAC,EAC5D,CAACC,EAAOC,CAAQ,KAAI,YAAS,CAAC,EAE9B,CAACC,EAAaC,CAAc,KAAI,YAAS,CAAC,EAE1C,CAAE,WAAYC,EAAW,QAAAC,CAAQ,KAAI,mBAQzC,CACA,IAAK,wBACL,SAAU,CACR,MAAOT,EACP,QAAS,mBAAiB,IAAIF,CAAM,GAAKA,EACzC,SAAUC,CACZ,CACF,CAAC,KAED,aAAU,IAAM,CACVL,GAAoB,CAACC,GAAWa,GAIhCjB,IAASe,GAAef,GAC1BkB,EACE,CACE,aAAchB,GAAe,kBAAgB,OAC7C,KAAAF,EACA,UAAWC,EACX,QAASG,GAAS,OACpB,EACA,CACE,UAAUe,EAAc,CACtBH,EAAehB,CAAI,EACnBc,EAASK,GAAc,MAAM,KAAK,EAClCP,EAAaD,EAAU,OAAOQ,GAAc,MAAM,aAAe,CAAC,CAAC,CAAC,CACtE,CACF,CACF,CAEJ,EAAG,CAACD,EAASP,EAAWT,EAAaF,EAAMC,EAAUc,EAAaX,EAASD,EAAkBc,CAAS,CAAC,EAEvG,MAAMG,KAAe,eAAY,SAAY,CACvCjB,GAAoB,CAACO,GAAW,CAACN,GAAWa,GAGhD,MAAMC,EACJ,CACE,aAAchB,GAAe,kBAAgB,OAC7C,KAAAF,EACA,UAAWC,EACX,QAASG,GAAS,OACpB,EACA,CAEE,UAAUe,EAAc,CACtBP,EAAaO,GAAc,MAAM,aAAe,CAAC,CAAC,CACpD,CACF,CACF,CACF,EAAG,CAACjB,EAAae,EAAWd,EAAkBH,EAAMC,EAAUG,EAASc,CAAO,CAAC,EAE/E,MAAO,CACL,UAAAP,EACA,UAAAM,EACA,MAAAJ,EACA,aAAAO,EACA,QAASP,EAAQF,EAAU,QAAU,CAACM,CACxC,CACF,CAEA,IAAOzB,EAAQO",
|
|
6
|
+
"names": ["useMyRewards_exports", "__export", "useMyRewards_default", "__toCommonJS", "import_react", "import_const", "import_useAlpcFetch", "import_provider", "import_lib", "useMyRewards", "page", "pageSize", "consumeType", "isLoadingProfile", "profile", "alpcBrand", "headlessBrand", "locale", "appName", "brand", "isLogin", "myRewards", "setMyRewards", "total", "setTotal", "currentPage", "setCurrentPage", "isLoading", "trigger", "responseData", "getMyRewards"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var r=Object.defineProperty;var
|
|
1
|
+
"use strict";var r=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var C=(o,e)=>{for(var n in e)r(o,n,{get:e[n],enumerable:!0})},l=(o,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of m(e))!c.call(o,t)&&t!==n&&r(o,t,{get:()=>e[t],enumerable:!(s=i(e,t))||s.enumerable});return o};var R=o=>l(r({},"__esModule",{value:!0}),o);var b={};C(b,{useRedeemCoupon:()=>g});module.exports=R(b);var p=require("../const"),a=require("./useAlpcFetch"),u=require("@anker-in/lib"),d=require("../provider");const g=(o={})=>{const{alpcBrand:e}=(0,d.useCreditsContext)(),{locale:n,appName:s,brand:t}=(0,u.useHeadlessContext)();return(0,a.useAlpcMutation)({url:"/v1/credit/redeem/coupon",initData:{brand:e||t,country:p.ALPC_COUNTRY_MAP.get(n)||n,app_name:s}},o)};
|
|
2
2
|
//# sourceMappingURL=useRedeemCoupon.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useRedeemCoupon.ts"],
|
|
4
|
-
"sourcesContent": ["import { ALPC_COUNTRY_MAP } from '../const'\nimport { useAlpcMutation, type UseMutationConfig } from './useAlpcFetch'\nimport { useHeadlessContext } from '@anker-in/lib'\n\ntype RedeemCouponResponse = {\n data: {\n success: boolean\n coupon_code: string\n }\n msg: string // \u62A5\u9519\u4FE1\u606F\n code: number // \u62A5\u9519\u7801\n}\n\nexport const useRedeemCoupon = (mutationOptions: UseMutationConfig<RedeemCouponResponse> = {}) => {\n const { locale, appName, brand } = useHeadlessContext()\n\n return useAlpcMutation<\n RedeemCouponResponse,\n {\n user_id?: string\n rule_id: number\n }\n >(\n {\n url: `/v1/credit/redeem/coupon`,\n initData: {\n brand,\n country: ALPC_COUNTRY_MAP.get(locale) || locale,\n app_name: appName,\n },\n },\n mutationOptions\n )\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiC,oBACjCC,EAAwD,0BACxDC,EAAmC,
|
|
6
|
-
"names": ["useRedeemCoupon_exports", "__export", "useRedeemCoupon", "__toCommonJS", "import_const", "import_useAlpcFetch", "import_lib", "mutationOptions", "locale", "appName", "
|
|
4
|
+
"sourcesContent": ["import { ALPC_COUNTRY_MAP } from '../const'\nimport { useAlpcMutation, type UseMutationConfig } from './useAlpcFetch'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { useCreditsContext } from '../provider'\n\ntype RedeemCouponResponse = {\n data: {\n success: boolean\n coupon_code: string\n }\n msg: string // \u62A5\u9519\u4FE1\u606F\n code: number // \u62A5\u9519\u7801\n}\n\nexport const useRedeemCoupon = (mutationOptions: UseMutationConfig<RedeemCouponResponse> = {}) => {\n const { alpcBrand } = useCreditsContext()\n const { locale, appName, brand: headlessBrand } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n\n return useAlpcMutation<\n RedeemCouponResponse,\n {\n user_id?: string\n rule_id: number\n }\n >(\n {\n url: `/v1/credit/redeem/coupon`,\n initData: {\n brand,\n country: ALPC_COUNTRY_MAP.get(locale) || locale,\n app_name: appName,\n },\n },\n mutationOptions\n )\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiC,oBACjCC,EAAwD,0BACxDC,EAAmC,yBACnCC,EAAkC,uBAW3B,MAAML,EAAkB,CAACM,EAA2D,CAAC,IAAM,CAChG,KAAM,CAAE,UAAAC,CAAU,KAAI,qBAAkB,EAClC,CAAE,OAAAC,EAAQ,QAAAC,EAAS,MAAOC,CAAc,KAAI,sBAAmB,EAGrE,SAAO,mBAOL,CACE,IAAK,2BACL,SAAU,CACR,MAZQH,GAAaG,EAarB,QAAS,mBAAiB,IAAIF,CAAM,GAAKA,EACzC,SAAUC,CACZ,CACF,EACAH,CACF,CACF",
|
|
6
|
+
"names": ["useRedeemCoupon_exports", "__export", "useRedeemCoupon", "__toCommonJS", "import_const", "import_useAlpcFetch", "import_lib", "import_provider", "mutationOptions", "alpcBrand", "locale", "appName", "headlessBrand"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var s=Object.defineProperty;var
|
|
1
|
+
"use strict";var s=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var C=(o,e)=>{for(var n in e)s(o,n,{get:e[n],enumerable:!0})},R=(o,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of c(e))!l.call(o,t)&&t!==n&&s(o,t,{get:()=>e[t],enumerable:!(r=p(e,t))||r.enumerable});return o};var b=o=>R(s({},"__esModule",{value:!0}),o);var g={};C(g,{useRedeemProduct:()=>f});module.exports=b(g);var a=require("../const"),d=require("./useAlpcFetch"),u=require("@anker-in/lib"),i=require("../provider");const f=(o={})=>{const{alpcBrand:e}=(0,i.useCreditsContext)(),{storeDomain:n,locale:r,appName:t,brand:m}=(0,u.useHeadlessContext)();return(0,d.useAlpcMutation)({url:"/v1/credit/exchange/goods",initData:{quantity:1,brand:e||m,country:(a.ALPC_COUNTRY_MAP.get(r||"")||r)?.toUpperCase(),domain:n,app_name:t}},o)};
|
|
2
2
|
//# sourceMappingURL=useRedeemProduct.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useRedeemProduct.ts"],
|
|
4
|
-
"sourcesContent": ["import { ALPC_COUNTRY_MAP } from '../const'\nimport { useAlpcMutation, type UseMutationConfig } from './useAlpcFetch'\nimport { useHeadlessContext } from '@anker-in/lib'\n\ntype RedeemProductResponse = {\n code: number\n data: {\n success: boolean\n }\n}\n\nexport const useRedeemProduct = (mutationOptions: UseMutationConfig<RedeemProductResponse> = {}) => {\n const { storeDomain, locale, appName, brand } = useHeadlessContext()\n\n return useAlpcMutation<\n RedeemProductResponse,\n {\n rule_id: number\n address: string\n }\n >(\n {\n url: `/v1/credit/exchange/goods`,\n initData: {\n quantity: 1,\n brand,\n country: (ALPC_COUNTRY_MAP.get(locale || '') || locale)?.toUpperCase(),\n domain: storeDomain,\n app_name: appName,\n },\n },\n mutationOptions\n )\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiC,oBACjCC,EAAwD,0BACxDC,EAAmC,
|
|
6
|
-
"names": ["useRedeemProduct_exports", "__export", "useRedeemProduct", "__toCommonJS", "import_const", "import_useAlpcFetch", "import_lib", "mutationOptions", "storeDomain", "locale", "appName", "
|
|
4
|
+
"sourcesContent": ["import { ALPC_COUNTRY_MAP } from '../const'\nimport { useAlpcMutation, type UseMutationConfig } from './useAlpcFetch'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { useCreditsContext } from '../provider'\n\ntype RedeemProductResponse = {\n code: number\n data: {\n success: boolean\n }\n}\n\nexport const useRedeemProduct = (mutationOptions: UseMutationConfig<RedeemProductResponse> = {}) => {\n const { alpcBrand } = useCreditsContext()\n const { storeDomain, locale, appName, brand: headlessBrand } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n\n return useAlpcMutation<\n RedeemProductResponse,\n {\n rule_id: number\n address: string\n }\n >(\n {\n url: `/v1/credit/exchange/goods`,\n initData: {\n quantity: 1,\n brand,\n country: (ALPC_COUNTRY_MAP.get(locale || '') || locale)?.toUpperCase(),\n domain: storeDomain,\n app_name: appName,\n },\n },\n mutationOptions\n )\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiC,oBACjCC,EAAwD,0BACxDC,EAAmC,yBACnCC,EAAkC,uBAS3B,MAAML,EAAmB,CAACM,EAA4D,CAAC,IAAM,CAClG,KAAM,CAAE,UAAAC,CAAU,KAAI,qBAAkB,EAClC,CAAE,YAAAC,EAAa,OAAAC,EAAQ,QAAAC,EAAS,MAAOC,CAAc,KAAI,sBAAmB,EAGlF,SAAO,mBAOL,CACE,IAAK,4BACL,SAAU,CACR,SAAU,EACV,MAbQJ,GAAaI,EAcrB,SAAU,mBAAiB,IAAIF,GAAU,EAAE,GAAKA,IAAS,YAAY,EACrE,OAAQD,EACR,SAAUE,CACZ,CACF,EACAJ,CACF,CACF",
|
|
6
|
+
"names": ["useRedeemProduct_exports", "__export", "useRedeemProduct", "__toCommonJS", "import_const", "import_useAlpcFetch", "import_lib", "import_provider", "mutationOptions", "alpcBrand", "storeDomain", "locale", "appName", "headlessBrand"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var D=(e,t)=>{for(var r in t)d(e,r,{get:t[r],enumerable:!0})},N=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of P(t))!B.call(e,s)&&s!==r&&d(e,s,{get:()=>t[s],enumerable:!(n=M(t,s))||n.enumerable});return e};var O=e=>N(d({},"__esModule",{value:!0}),e);var k={};D(k,{default:()=>h});module.exports=O(k);var i=require("react"),f=require("./useAlpcFetch"),g=require("../const"),C=require("../provider"),L=require("@anker-in/lib");function U(){let e="";const{profile:t,isLoadingProfile:r,alpcBrand:n}=(0,C.useCreditsContext)(),{locale:s,brand:R}=(0,L.useHeadlessContext)(),b=n||R;s==="pl"?e="eu":e=s;const[x,y]=(0,i.useState)([]),{isMutating:S,trigger:m}=(0,f.useAlpcMutation)({url:"/v1/credit/consume_credit_rules",initData:{brand:b,page:1,page_size:20,country:(g.ALPC_COUNTRY_MAP.get(e)||e)?.toUpperCase()}}),c=(0,i.useCallback)(()=>{m({user_id:t?.user_id},{onSuccess(A){let p=A.data.consume_credit_rules||[],u=p.filter(o=>o.consume_type==1)||[],l=p.filter(o=>o.consume_type==2)||[];u=u.sort((o,a)=>o.consume_credits-a.consume_credits),l=l.sort((o,a)=>o.consume_credits-a.consume_credits);const _=u.concat(l);y(_),localStorage?.setItem(`consume_credit_rules-${e}`,JSON.stringify({expire:Date.now()+10*60*1e3,consume_credit_rules:_}))}})},[t,m,e]);return(0,i.useEffect)(()=>{r||c()},[c,r]),{listLoading:S,redeemableList:x,getRedeemableList:c}}var h=U;
|
|
2
2
|
//# sourceMappingURL=useRedeemableList.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useRedeemableList.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { useAlpcMutation } from './useAlpcFetch'\nimport { ALPC_COUNTRY_MAP } from '../const'\nimport { useCreditsContext } from '../provider'\nimport type { ConsumeCreditRuleResponse } from '../response'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useRedeemableList() {\n let locale = '' as string\n const { profile, isLoadingProfile } = useCreditsContext()\n const { locale: contextLocale, brand } = useHeadlessContext()\n\n if (contextLocale === 'pl') {\n locale = 'eu'\n } else {\n locale = contextLocale\n }\n\n const [redeemableList, setRedeemableList] = useState<ConsumeCreditRuleResponse[]>([])\n const { isMutating: listLoading, trigger } = useAlpcMutation<\n {\n data: { consume_credit_rules: ConsumeCreditRuleResponse[] }\n },\n { user_id?: string }\n >({\n url: `/v1/credit/consume_credit_rules`,\n initData: {\n brand,\n page: 1,\n page_size: 20,\n country: (ALPC_COUNTRY_MAP.get(locale) || locale)?.toUpperCase(),\n
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiD,iBAEjDC,EAAgC,0BAChCC,EAAiC,oBACjCC,EAAkC,uBAElCC,EAAmC,yBAEnC,SAASC,GAAoB,CAC3B,IAAIC,EAAS,GACb,KAAM,CAAE,QAAAC,EAAS,iBAAAC,
|
|
6
|
-
"names": ["useRedeemableList_exports", "__export", "useRedeemableList_default", "__toCommonJS", "import_react", "import_useAlpcFetch", "import_const", "import_provider", "import_lib", "useRedeemableList", "locale", "profile", "isLoadingProfile", "contextLocale", "brand", "redeemableList", "setRedeemableList", "listLoading", "trigger", "getRedeemableList", "responseData", "list", "cList", "i", "pList", "prev", "next", "resultList"]
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { useAlpcMutation } from './useAlpcFetch'\nimport { ALPC_COUNTRY_MAP } from '../const'\nimport { useCreditsContext } from '../provider'\nimport type { ConsumeCreditRuleResponse } from '../response'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useRedeemableList() {\n let locale = '' as string\n const { profile, isLoadingProfile, alpcBrand } = useCreditsContext()\n const { locale: contextLocale, brand: headlessBrand } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n\n if (contextLocale === 'pl') {\n locale = 'eu'\n } else {\n locale = contextLocale\n }\n\n const [redeemableList, setRedeemableList] = useState<ConsumeCreditRuleResponse[]>([])\n const { isMutating: listLoading, trigger } = useAlpcMutation<\n {\n data: { consume_credit_rules: ConsumeCreditRuleResponse[] }\n },\n { user_id?: string }\n >({\n url: `/v1/credit/consume_credit_rules`,\n initData: {\n brand,\n page: 1,\n page_size: 20,\n country: (ALPC_COUNTRY_MAP.get(locale) || locale)?.toUpperCase(),\n },\n })\n\n const getRedeemableList = useCallback(() => {\n trigger(\n {\n user_id: profile?.user_id,\n },\n {\n onSuccess(responseData) {\n let list = responseData.data.consume_credit_rules || []\n let cList = list.filter(i => i.consume_type == 1) || []\n let pList = list.filter(i => i.consume_type == 2) || []\n cList = cList.sort((prev, next) => prev.consume_credits - next.consume_credits)\n pList = pList.sort((prev, next) => prev.consume_credits - next.consume_credits)\n const resultList = cList.concat(pList)\n setRedeemableList(resultList)\n\n localStorage?.setItem(\n `consume_credit_rules-${locale}`,\n JSON.stringify({\n expire: Date.now() + 10 * 60 * 1000,\n consume_credit_rules: resultList,\n })\n )\n },\n }\n )\n }, [profile, trigger, locale])\n\n useEffect(() => {\n if (!isLoadingProfile) {\n getRedeemableList()\n }\n }, [getRedeemableList, isLoadingProfile])\n\n return {\n listLoading,\n redeemableList,\n getRedeemableList,\n }\n}\n\nexport default useRedeemableList\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiD,iBAEjDC,EAAgC,0BAChCC,EAAiC,oBACjCC,EAAkC,uBAElCC,EAAmC,yBAEnC,SAASC,GAAoB,CAC3B,IAAIC,EAAS,GACb,KAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,UAAAC,CAAU,KAAI,qBAAkB,EAC7D,CAAE,OAAQC,EAAe,MAAOC,CAAc,KAAI,sBAAmB,EACrEC,EAAQH,GAAaE,EAEvBD,IAAkB,KACpBJ,EAAS,KAETA,EAASI,EAGX,KAAM,CAACG,EAAgBC,CAAiB,KAAI,YAAsC,CAAC,CAAC,EAC9E,CAAE,WAAYC,EAAa,QAAAC,CAAQ,KAAI,mBAK3C,CACA,IAAK,kCACL,SAAU,CACR,MAAAJ,EACA,KAAM,EACN,UAAW,GACX,SAAU,mBAAiB,IAAIN,CAAM,GAAKA,IAAS,YAAY,CACjE,CACF,CAAC,EAEKW,KAAoB,eAAY,IAAM,CAC1CD,EACE,CACE,QAAST,GAAS,OACpB,EACA,CACE,UAAUW,EAAc,CACtB,IAAIC,EAAOD,EAAa,KAAK,sBAAwB,CAAC,EAClDE,EAAQD,EAAK,OAAOE,GAAKA,EAAE,cAAgB,CAAC,GAAK,CAAC,EAClDC,EAAQH,EAAK,OAAOE,GAAKA,EAAE,cAAgB,CAAC,GAAK,CAAC,EACtDD,EAAQA,EAAM,KAAK,CAACG,EAAMC,IAASD,EAAK,gBAAkBC,EAAK,eAAe,EAC9EF,EAAQA,EAAM,KAAK,CAACC,EAAMC,IAASD,EAAK,gBAAkBC,EAAK,eAAe,EAC9E,MAAMC,EAAaL,EAAM,OAAOE,CAAK,EACrCR,EAAkBW,CAAU,EAE5B,cAAc,QACZ,wBAAwBnB,CAAM,GAC9B,KAAK,UAAU,CACb,OAAQ,KAAK,IAAI,EAAI,GAAK,GAAK,IAC/B,qBAAsBmB,CACxB,CAAC,CACH,CACF,CACF,CACF,CACF,EAAG,CAAClB,EAASS,EAASV,CAAM,CAAC,EAE7B,sBAAU,IAAM,CACTE,GACHS,EAAkB,CAEtB,EAAG,CAACA,EAAmBT,CAAgB,CAAC,EAEjC,CACL,YAAAO,EACA,eAAAF,EACA,kBAAAI,CACF,CACF,CAEA,IAAOnB,EAAQO",
|
|
6
|
+
"names": ["useRedeemableList_exports", "__export", "useRedeemableList_default", "__toCommonJS", "import_react", "import_useAlpcFetch", "import_const", "import_provider", "import_lib", "useRedeemableList", "locale", "profile", "isLoadingProfile", "alpcBrand", "contextLocale", "headlessBrand", "brand", "redeemableList", "setRedeemableList", "listLoading", "trigger", "getRedeemableList", "responseData", "list", "cList", "i", "pList", "prev", "next", "resultList"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var h=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var A=(a,x)=>{for(var g in x)h(a,g,{get:x[g],enumerable:!0})},H=(a,x,g,r)=>{if(x&&typeof x=="object"||typeof x=="function")for(let e of w(x))!P.call(a,e)&&e!==g&&h(a,e,{get:()=>x[e],enumerable:!(r=d(x,e))||r.enumerable});return a};var L=a=>H(h({},"__esModule",{value:!0}),a);var N={};A(N,{FunctionDiscountType:()=>m,RoundSelected:()=>_});module.exports=L(N);var m=(r=>(r[r.Percentage=1]="Percentage",r[r.FixedAmount=2]="FixedAmount",r[r.FixedPrice=3]="FixedPrice",r))(m||{}),_=(r=>(r.RoundHighest="round_highest",r.RoundLowest="round_lowest",r.RoundNearest="round_nearest",r))(_||{});
|
|
2
|
+
//# sourceMappingURL=memberPriceConst.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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\n// \u5C0F\u6570\u4F4D\u53D6\u820D\u65B9\u5F0F\nexport enum RoundSelected {\n RoundHighest = 'round_highest',\n RoundLowest = 'round_lowest',\n RoundNearest = 'round_nearest',\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,EAAA,kBAAAC,IAAA,eAAAC,EAAAJ,GACO,IAAKE,OACVA,IAAA,WAAa,GAAb,aACAA,IAAA,6BACAA,IAAA,2BAHUA,OAAA,IAOAC,OACVA,EAAA,aAAe,gBACfA,EAAA,YAAc,eACdA,EAAA,aAAe,gBAHLA,OAAA",
|
|
6
|
+
"names": ["memberPriceConst_exports", "__export", "FunctionDiscountType", "RoundSelected", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { FunctionDiscountType, RoundSelected } from './memberPriceConst';
|
|
2
|
+
export type PriceEndingConf = {
|
|
3
|
+
apply_price_ending: boolean;
|
|
4
|
+
one_decimal_place: string;
|
|
5
|
+
two_decimal_place: string;
|
|
6
|
+
round_selected: RoundSelected;
|
|
7
|
+
};
|
|
8
|
+
export type DiscountConfig = {
|
|
9
|
+
discount_type: FunctionDiscountType;
|
|
10
|
+
discount_value: number;
|
|
11
|
+
price_ending_conf?: PriceEndingConf;
|
|
12
|
+
};
|
|
13
|
+
export type FunctionMemberPriceConfig = {
|
|
14
|
+
rule_id: string;
|
|
15
|
+
result_detail: {
|
|
16
|
+
member_discounts?: {
|
|
17
|
+
user_identity: number;
|
|
18
|
+
main_products: {
|
|
19
|
+
all_store_variant: boolean;
|
|
20
|
+
variants: {
|
|
21
|
+
variant_id: string;
|
|
22
|
+
sku: string;
|
|
23
|
+
handle: string;
|
|
24
|
+
}[];
|
|
25
|
+
};
|
|
26
|
+
discount_conf: DiscountConfig;
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
29
|
+
discount_combinations: {
|
|
30
|
+
other_product_discounts: boolean;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
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
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var t=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var a=(n,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of u(e))!s.call(n,i)&&i!==o&&t(n,i,{get:()=>e[i],enumerable:!(r=c(e,i))||r.enumerable});return n};var l=n=>a(t({},"__esModule",{value:!0}),n);var d={};module.exports=l(d);
|
|
2
|
+
//# sourceMappingURL=memberPriceTypes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/components/credits/context/memberPriceTypes.ts"],
|
|
4
|
+
"sourcesContent": ["import { FunctionDiscountType, RoundSelected } from './memberPriceConst'\n\n// \u4EF7\u683C\u7ED3\u5C3E\u914D\u7F6E\nexport type PriceEndingConf = {\n apply_price_ending: boolean\n one_decimal_place: string\n two_decimal_place: string\n round_selected: RoundSelected\n}\n\n// \u6298\u6263\u914D\u7F6E\nexport type DiscountConfig = {\n discount_type: FunctionDiscountType\n discount_value: number\n price_ending_conf?: PriceEndingConf\n}\n\n// \u4F1A\u5458\u4EF7\u914D\u7F6E\u7C7B\u578B\nexport type FunctionMemberPriceConfig = {\n rule_id: string\n result_detail: {\n member_discounts?: {\n user_identity: number // \u7528\u6237\u8EAB\u4EFD\uFF1A1-\u666E\u901A\u4F1A\u5458\uFF0C2-\u9AD8\u7EA7\u4F1A\u5458\u7B49\n main_products: {\n all_store_variant: boolean\n variants: {\n variant_id: string\n sku: string\n handle: string\n }[]\n }\n discount_conf: DiscountConfig\n }[]\n }\n discount_combinations: {\n other_product_discounts: boolean\n }\n}\n\n// \u4F1A\u5458\u4EF7\u8BA1\u7B97\u7ED3\u679C\nexport type FunctionMemberPriceResult = {\n hasMemberPrice: boolean\n useCoupon: boolean\n originalPrice: number\n originalPriceWithCurrency: string\n salePrice: number\n salePriceWithCurrency: string\n salePriceWithoutCoupon: number\n salePriceWithoutCouponWithCurrency: string\n savePrice: number\n savePriceWithCurrency: string\n savePriceWithoutCoupon: number\n savePriceWithoutCouponWithCurrency: string\n}\n"],
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["memberPriceTypes_exports", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -2,6 +2,7 @@ import { PropsWithChildren } from 'react';
|
|
|
2
2
|
import type { DTC_TASK_TYPE } from './const';
|
|
3
3
|
import type { CreditInfoResponse } from './response';
|
|
4
4
|
import { CreditsPageCommon } from '../type';
|
|
5
|
+
import { FunctionMemberPriceConfig } from './memberPriceTypes';
|
|
5
6
|
type Context = {
|
|
6
7
|
profile: any;
|
|
7
8
|
isLoadingProfile: boolean;
|
|
@@ -17,8 +18,10 @@ type Context = {
|
|
|
17
18
|
pageGroup: string;
|
|
18
19
|
};
|
|
19
20
|
pageCommon: CreditsPageCommon;
|
|
21
|
+
memberPriceDiscount?: FunctionMemberPriceConfig[];
|
|
22
|
+
alpcBrand?: string;
|
|
20
23
|
};
|
|
21
24
|
export declare const CreditsContext: import("react").Context<Context>;
|
|
22
|
-
export declare function CreditsProvider({ children, profile, removeProfile, isLoadingProfile, openSignInPopup, openSignUpPopup, taskIdToTypeMapping, creditInfo, customer, customerLoading, fetchCreditInfo, gtm, pageCommon, }: PropsWithChildren<Context>): import("react/jsx-runtime").JSX.Element;
|
|
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;
|
|
23
26
|
export declare function useCreditsContext(): Context;
|
|
24
27
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var h=(e,o)=>{for(var n in o)p(e,n,{get:o[n],enumerable:!0})},b=(e,o,n,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of I(o))!T.call(e,r)&&r!==n&&p(e,r,{get:()=>o[r],enumerable:!(t=v(o,r))||t.enumerable});return e};var y=e=>b(p({},"__esModule",{value:!0}),e);var D={};h(D,{CreditsContext:()=>d,CreditsProvider:()=>S,useCreditsContext:()=>_});module.exports=y(D);var s=require("react/jsx-runtime"),i=require("react");const d=(0,i.createContext)({profile:null,isLoadingProfile:!1,taskIdToTypeMapping:{},removeProfile:()=>{},openSignInPopup:()=>{},openSignUpPopup:()=>{},creditInfo:void 0,customerLoading:!1,fetchCreditInfo:e=>{},gtm:{pageGroup:""},pageCommon:{},memberPriceDiscount:void 0,alpcBrand:void 0});function S({children:e,profile:o,removeProfile:n,isLoadingProfile:t,openSignInPopup:r,openSignUpPopup:m,taskIdToTypeMapping:C,creditInfo:f,customer:u,customerLoading:a,fetchCreditInfo:g,gtm:c,pageCommon:P,memberPriceDiscount:l,alpcBrand:x}){return(0,s.jsx)(d.Provider,{value:{profile:o,isLoadingProfile:t,removeProfile:n,openSignInPopup:r,openSignUpPopup:m,taskIdToTypeMapping:C,creditInfo:f,fetchCreditInfo:g,customer:u,customerLoading:a,gtm:c,pageCommon:P,memberPriceDiscount:l,alpcBrand:x},children:e})}function _(){const e=(0,i.useContext)(d);if(!e)throw new Error("useCreditsContext must be used within a CreditsProvider");return e}
|
|
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'\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}\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})\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}: 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 }}\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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,oBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAL,
|
|
6
|
-
"names": ["provider_exports", "__export", "CreditsContext", "CreditsProvider", "useCreditsContext", "__toCommonJS", "import_jsx_runtime", "import_react", "user_id", "children", "profile", "removeProfile", "isLoadingProfile", "openSignInPopup", "openSignUpPopup", "taskIdToTypeMapping", "creditInfo", "customer", "customerLoading", "fetchCreditInfo", "gtm", "pageCommon", "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}\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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,EAAA,oBAAAC,EAAA,sBAAAC,IAAA,eAAAC,EAAAL,GA6DI,IAAAM,EAAA,6BA7DJC,EAA6D,iBAyBtD,MAAML,KAAiB,iBAAuB,CACnD,QAAS,KACT,iBAAkB,GAClB,oBAAqB,CAAC,EACtB,cAAe,IAAM,CAAC,EACtB,gBAAiB,IAAM,CAAC,EACxB,gBAAiB,IAAM,CAAC,EACxB,WAAY,OACZ,gBAAiB,GACjB,gBAAkBM,GAAoB,CAAC,EACvC,IAAK,CACH,UAAW,EACb,EACA,WAAY,CAAC,EACb,oBAAqB,OACrB,UAAW,MACb,CAAC,EAEM,SAASL,EAAgB,CAC9B,SAAAM,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,CACF,EAA+B,CAC7B,SACE,OAACrB,EAAe,SAAf,CACC,MAAO,CACL,QAAAQ,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,CACF,EAEC,SAAAd,EACH,CAEJ,CAEO,SAASL,GAAoB,CAClC,MAAMoB,KAAU,cAAWtB,CAAc,EACzC,GAAI,CAACsB,EACH,MAAM,IAAI,MAAM,yDAAyD,EAE3E,OAAOA,CACT",
|
|
6
|
+
"names": ["provider_exports", "__export", "CreditsContext", "CreditsProvider", "useCreditsContext", "__toCommonJS", "import_jsx_runtime", "import_react", "user_id", "children", "profile", "removeProfile", "isLoadingProfile", "openSignInPopup", "openSignUpPopup", "taskIdToTypeMapping", "creditInfo", "customer", "customerLoading", "fetchCreditInfo", "gtm", "pageCommon", "memberPriceDiscount", "alpcBrand", "context"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function atobID(id: string): string | undefined;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var l=(t,e)=>{for(var r in e)s(t,r,{get:e[r],enumerable:!0})},u=(t,e,r,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of f(e))!i.call(t,n)&&n!==r&&s(t,n,{get:()=>e[n],enumerable:!(p=o(e,n))||p.enumerable});return t};var c=t=>u(s({},"__esModule",{value:!0}),t);var a={};l(a,{atobID:()=>g});module.exports=c(a);function g(t){return t&&typeof t=="string"&&t.includes("/")?t.split("/").pop()?.split("?")?.shift():t}
|
|
2
|
+
//# sourceMappingURL=atobID.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/components/credits/context/utils/atobID.ts"],
|
|
4
|
+
"sourcesContent": ["// \u4ECE Shopify GraphQL ID \u4E2D\u63D0\u53D6\u6570\u5B57 ID\nexport function atobID(id: string) {\n if (id && typeof id === 'string' && id.includes('/')) {\n return id.split('/').pop()?.split('?')?.shift()\n } else {\n return id\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,YAAAE,IAAA,eAAAC,EAAAH,GACO,SAASE,EAAOE,EAAY,CACjC,OAAIA,GAAM,OAAOA,GAAO,UAAYA,EAAG,SAAS,GAAG,EAC1CA,EAAG,MAAM,GAAG,EAAE,IAAI,GAAG,MAAM,GAAG,GAAG,MAAM,EAEvCA,CAEX",
|
|
6
|
+
"names": ["atobID_exports", "__export", "atobID", "__toCommonJS", "id"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var p=Object.create;var u=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var k=(e,n)=>{for(var c in n)u(e,c,{get:n[c],enumerable:!0})},s=(e,n,c,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of m(n))!f.call(e,o)&&o!==c&&u(e,o,{get:()=>n[o],enumerable:!(a=_(n,o))||a.enumerable});return e};var w=(e,n,c)=>(c=e!=null?p(b(e)):{},s(n||!e||!e.__esModule?u(c,"default",{value:e,enumerable:!0}):c,e)),D=e=>s(u({},"__esModule",{value:!0}),e);var R={};k(R,{functionDiscountCalculate:()=>g});module.exports=D(R);var i=require("../memberPriceConst"),r=w(require("decimal.js"));const g=({config:e,price:n})=>{const{apply_price_ending:c,one_decimal_place:a,two_decimal_place:o,round_selected:d}=e.price_ending_conf||{};let t=new r.default(n);switch(e.discount_type){case i.FunctionDiscountType.Percentage:t=t.mul(100-e.discount_value).div(100);break;case i.FunctionDiscountType.FixedAmount:t=t.sub(e.discount_value);break;case i.FunctionDiscountType.FixedPrice:t=new r.default(e.discount_value);break;default:break}if(c){switch(d){case i.RoundSelected.RoundHighest:t=t.ceil();break;case i.RoundSelected.RoundLowest:t=t.floor();break;case i.RoundSelected.RoundNearest:t=t.round();break;default:t=new r.default(t.toFixed(2,r.default.ROUND_DOWN));break}const l=t.toString().split(".");t=new r.default(l[0]+"."+a+o)}return t.toNumber()};
|
|
2
|
+
//# sourceMappingURL=functionDiscountCalculate.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/components/credits/context/utils/functionDiscountCalculate.ts"],
|
|
4
|
+
"sourcesContent": ["import { FunctionDiscountType, RoundSelected } from '../memberPriceConst'\nimport { DiscountConfig } from '../memberPriceTypes'\nimport Decimal from 'decimal.js'\n\n// Function \u8BA1\u7B97\u6298\u540E\u4EF7\nexport const functionDiscountCalculate = ({\n config,\n price,\n}: {\n config: DiscountConfig\n price: number\n}) => {\n const { apply_price_ending, one_decimal_place, two_decimal_place, round_selected } =\n config.price_ending_conf || {}\n\n let salePrice = new Decimal(price)\n\n switch (config.discount_type) {\n // \u767E\u5206\u6BD4\u6298\u6263\n case FunctionDiscountType.Percentage:\n salePrice = salePrice.mul(100 - config.discount_value).div(100)\n break\n // \u56FA\u5B9A\u91D1\u989D\u6298\u6263\n case FunctionDiscountType.FixedAmount:\n salePrice = salePrice.sub(config.discount_value)\n break\n // \u56FA\u5B9A\u4EF7\u683C\u6298\u6263\n case FunctionDiscountType.FixedPrice:\n salePrice = new Decimal(config.discount_value)\n break\n default:\n break\n }\n\n if (apply_price_ending) {\n // \u5C0F\u6570\u4F4D\u53D6\u820D\n switch (round_selected) {\n case RoundSelected.RoundHighest:\n salePrice = salePrice.ceil()\n break\n case RoundSelected.RoundLowest:\n salePrice = salePrice.floor()\n break\n case RoundSelected.RoundNearest:\n salePrice = salePrice.round()\n break\n default:\n salePrice = new Decimal(salePrice.toFixed(2, Decimal.ROUND_DOWN))\n break\n }\n\n const priceEnding = salePrice.toString().split('.')\n salePrice = new Decimal(priceEnding[0] + '.' + one_decimal_place + two_decimal_place)\n }\n\n return salePrice.toNumber()\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoD,+BAEpDC,EAAoB,yBAGb,MAAMH,EAA4B,CAAC,CACxC,OAAAI,EACA,MAAAC,CACF,IAGM,CACJ,KAAM,CAAE,mBAAAC,EAAoB,kBAAAC,EAAmB,kBAAAC,EAAmB,eAAAC,CAAe,EAC/EL,EAAO,mBAAqB,CAAC,EAE/B,IAAIM,EAAY,IAAI,EAAAC,QAAQN,CAAK,EAEjC,OAAQD,EAAO,cAAe,CAE5B,KAAK,uBAAqB,WACxBM,EAAYA,EAAU,IAAI,IAAMN,EAAO,cAAc,EAAE,IAAI,GAAG,EAC9D,MAEF,KAAK,uBAAqB,YACxBM,EAAYA,EAAU,IAAIN,EAAO,cAAc,EAC/C,MAEF,KAAK,uBAAqB,WACxBM,EAAY,IAAI,EAAAC,QAAQP,EAAO,cAAc,EAC7C,MACF,QACE,KACJ,CAEA,GAAIE,EAAoB,CAEtB,OAAQG,EAAgB,CACtB,KAAK,gBAAc,aACjBC,EAAYA,EAAU,KAAK,EAC3B,MACF,KAAK,gBAAc,YACjBA,EAAYA,EAAU,MAAM,EAC5B,MACF,KAAK,gBAAc,aACjBA,EAAYA,EAAU,MAAM,EAC5B,MACF,QACEA,EAAY,IAAI,EAAAC,QAAQD,EAAU,QAAQ,EAAG,EAAAC,QAAQ,UAAU,CAAC,EAChE,KACJ,CAEA,MAAMC,EAAcF,EAAU,SAAS,EAAE,MAAM,GAAG,EAClDA,EAAY,IAAI,EAAAC,QAAQC,EAAY,CAAC,EAAI,IAAML,EAAoBC,CAAiB,CACtF,CAEA,OAAOE,EAAU,SAAS,CAC5B",
|
|
6
|
+
"names": ["functionDiscountCalculate_exports", "__export", "functionDiscountCalculate", "__toCommonJS", "import_memberPriceConst", "import_decimal", "config", "price", "apply_price_ending", "one_decimal_place", "two_decimal_place", "round_selected", "salePrice", "Decimal", "priceEnding"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FunctionMemberPriceConfig, FunctionMemberPriceResult } from '../memberPriceTypes';
|
|
2
|
+
import { ProductVariant } from '@anker-in/lib';
|
|
3
|
+
export declare const getFunctionMemberPrice: ({ memberPriceDiscount, currencyCode, variant, locale, }: {
|
|
4
|
+
memberPriceDiscount?: FunctionMemberPriceConfig[];
|
|
5
|
+
currencyCode?: string;
|
|
6
|
+
variant?: ProductVariant;
|
|
7
|
+
locale: string;
|
|
8
|
+
}) => false | FunctionMemberPriceResult;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var M=Object.create;var a=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var N=(i,r)=>{for(var e in r)a(i,e,{get:r[e],enumerable:!0})},b=(i,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of A(r))!U.call(i,t)&&t!==e&&a(i,t,{get:()=>r[t],enumerable:!(o=S(r,t))||o.enumerable});return i};var D=(i,r,e)=>(e=i!=null?M(_(i)):{},b(r||!i||!i.__esModule?a(e,"default",{value:i,enumerable:!0}):e,i)),x=i=>b(a({},"__esModule",{value:!0}),i);var V={};N(V,{getFunctionMemberPrice:()=>R});module.exports=x(V);var n=require("../utils"),d=require("./functionDiscountCalculate"),c=D(require("decimal.js")),v=require("./getFunctionMemberPriceDiscountConfig"),w=D(require("./variantGetCoupon"));const R=({memberPriceDiscount:i,currencyCode:r,variant:e,locale:o})=>{const t=(0,w.default)({variant:e}),{memberPriceDiscountConfig:m,activeMemberPriceConfig:F}=(0,v.getFunctionMemberPriceDiscountConfig)({config:i,variant:e}),p=!!F?.discount_combinations.other_product_discounts;if(!m)return!1;const s={amount:e?.price.amount||0,priceWithCurrency:(0,n.formatPrice)({amount:e?.price.amount||0,currencyCode:r||"USD",locale:o})},u=m?(0,d.functionDiscountCalculate)({config:m,price:e?.price.amount||0}):e?.price.amount||0,C={amount:u,priceWithCurrency:(0,n.formatPrice)({amount:u,currencyCode:r||"USD",locale:o})};let P=u;if(t?.variant_price4wscode&&e&&p)if(p){const f=new c.default(e.price.amount).minus(t.variant_price4wscode);P=new c.default(u).minus(f).toNumber()}else{const f=new c.default(e.price.amount).minus(t.variant_price4wscode);if(u>f.toNumber())return!1}const h={amount:P,priceWithCurrency:(0,n.formatPrice)({amount:P,currencyCode:r||"USD",locale:o})},W=new c.default(s.amount).minus(h.amount).toNumber(),g={amount:W,priceWithCurrency:(0,n.formatPrice)({amount:W,currencyCode:r||"USD",locale:o,maximumFractionDigits:2})},l=new c.default(s.amount).minus(C.amount).toNumber(),y={amount:l,priceWithCurrency:(0,n.formatPrice)({amount:l,currencyCode:r||"USD",locale:o,maximumFractionDigits:2})};return{hasMemberPrice:!!m,useCoupon:p,originalPrice:s.amount,originalPriceWithCurrency:s.priceWithCurrency,salePrice:h.amount,salePriceWithCurrency:h.priceWithCurrency,salePriceWithoutCoupon:C.amount,salePriceWithoutCouponWithCurrency:C.priceWithCurrency,savePrice:g.amount,savePriceWithCurrency:g.priceWithCurrency,savePriceWithoutCoupon:y.amount,savePriceWithoutCouponWithCurrency:y.priceWithCurrency}};
|
|
2
|
+
//# sourceMappingURL=getFunctionMemberPrice.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/components/credits/context/utils/getFunctionMemberPrice.ts"],
|
|
4
|
+
"sourcesContent": ["import { formatPrice } from '../utils'\nimport { FunctionMemberPriceConfig, FunctionMemberPriceResult } from '../memberPriceTypes'\nimport { ProductVariant } from '@anker-in/lib'\nimport { functionDiscountCalculate } from './functionDiscountCalculate'\nimport Decimal from 'decimal.js'\nimport { getFunctionMemberPriceDiscountConfig } from './getFunctionMemberPriceDiscountConfig'\nimport variantGetCoupon from './variantGetCoupon'\n\n// \u8BA1\u7B97\u5355\u4EF6\u5546\u54C1\u7684\u4F1A\u5458\u4EF7\nexport const getFunctionMemberPrice = ({\n memberPriceDiscount,\n currencyCode,\n variant,\n locale,\n}: {\n memberPriceDiscount?: FunctionMemberPriceConfig[]\n currencyCode?: string\n variant?: ProductVariant\n locale: string\n}) => {\n const couponData = variantGetCoupon({ variant })\n\n // variant\u5BF9\u5E94\u7684\u4F1A\u5458\u4EF7\u6298\u6263\u914D\u7F6E\n const { memberPriceDiscountConfig, activeMemberPriceConfig } = getFunctionMemberPriceDiscountConfig({\n config: memberPriceDiscount,\n variant,\n })\n\n const useCoupon = !!activeMemberPriceConfig?.discount_combinations.other_product_discounts\n\n if (!memberPriceDiscountConfig) {\n return false as false\n }\n\n const originalPrice = {\n amount: variant?.price.amount || 0,\n priceWithCurrency: formatPrice({\n amount: variant?.price.amount || 0,\n currencyCode: currencyCode || 'USD',\n locale,\n }),\n }\n\n const salePriceWithoutCouponAmount = memberPriceDiscountConfig\n ? functionDiscountCalculate({\n config: memberPriceDiscountConfig,\n price: variant?.price.amount || 0,\n })\n : variant?.price.amount || 0\n const salePriceWithoutCoupon = {\n amount: salePriceWithoutCouponAmount,\n priceWithCurrency: formatPrice({\n amount: salePriceWithoutCouponAmount,\n currencyCode: currencyCode || 'USD',\n locale,\n }),\n }\n\n // function \u4F1A\u5458\u4EF7\u662F\u5728\u539F\u4EF7\u7684\u57FA\u7840\u4E0A\u8FDB\u884C\u8BA1\u7B97\uFF0C\u6682\u4E0D\u652F\u6301\u6298\u540E\u4EF7\n let salePriceAmount = salePriceWithoutCouponAmount\n\n // \u51CF\u53BBcode\u7684\u4F18\u60E0\n if (couponData?.variant_price4wscode && variant && useCoupon) {\n if (useCoupon) {\n // code\u7684\u4F18\u60E0\u91D1\u989D\n const codeSaveAmountDecimal = new Decimal(variant.price.amount).minus(couponData.variant_price4wscode)\n salePriceAmount = new Decimal(salePriceWithoutCouponAmount).minus(codeSaveAmountDecimal).toNumber()\n } else {\n // \u4E0D\u80FD\u4E0E code \u540C\u65F6\u4F7F\u7528\uFF0C\u9700\u8981\u5224\u65AD\u4F1A\u5458\u4EF7\u662F\u5426\u5C0F\u4E8E code \u7684\u4F18\u60E0\u91D1\u989D\uFF0C\u5982\u679C\u5C0F\u4E8E\u5219\u5F53\u505A\u6CA1\u6709\u4F1A\u5458\u4EF7\n const codeSaveAmountDecimal = new Decimal(variant.price.amount).minus(couponData.variant_price4wscode)\n if (salePriceWithoutCouponAmount > codeSaveAmountDecimal.toNumber()) {\n return false as false\n }\n }\n }\n\n const salePrice = {\n amount: salePriceAmount,\n priceWithCurrency: formatPrice({\n amount: salePriceAmount,\n currencyCode: currencyCode || 'USD',\n locale,\n }),\n }\n\n const savePriceAmount = new Decimal(originalPrice.amount).minus(salePrice.amount).toNumber()\n const savePrice = {\n amount: savePriceAmount,\n priceWithCurrency: formatPrice({\n amount: savePriceAmount,\n currencyCode: currencyCode || 'USD',\n locale,\n maximumFractionDigits: 2,\n }),\n }\n\n const savePriceWithoutCouponAmount = new Decimal(originalPrice.amount)\n .minus(salePriceWithoutCoupon.amount)\n .toNumber()\n const savePriceWithoutCoupon = {\n amount: savePriceWithoutCouponAmount,\n priceWithCurrency: formatPrice({\n amount: savePriceWithoutCouponAmount,\n currencyCode: currencyCode || 'USD',\n locale,\n maximumFractionDigits: 2,\n }),\n }\n\n const result: FunctionMemberPriceResult = {\n // \u662F\u5426\u5B58\u5728\u4F1A\u5458\u4EF7\n hasMemberPrice: !!memberPriceDiscountConfig,\n useCoupon,\n // \u539F\u4EF7\n originalPrice: originalPrice.amount,\n originalPriceWithCurrency: originalPrice.priceWithCurrency as string,\n // \u4F7F\u7528\u5238\u540E\u7684\u6298\u540E\u4EF7\n salePrice: salePrice.amount,\n salePriceWithCurrency: salePrice.priceWithCurrency as string,\n\n // \u4E0D\u4F7F\u7528\u5238\u7684\u6298\u540E\u4EF7\n salePriceWithoutCoupon: salePriceWithoutCoupon.amount,\n salePriceWithoutCouponWithCurrency: salePriceWithoutCoupon.priceWithCurrency as string,\n\n // \u5305\u542B\u4F7F\u7528\u5238\u7684\u8282\u7701\u91D1\u989D\n savePrice: savePrice.amount,\n savePriceWithCurrency: savePrice.priceWithCurrency as string,\n\n // \u4E0D\u4F7F\u7528\u5238\u7684\u8282\u7701\u91D1\u989D\n savePriceWithoutCoupon: savePriceWithoutCoupon.amount,\n savePriceWithoutCouponWithCurrency: savePriceWithoutCoupon.priceWithCurrency as string,\n }\n\n return result\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,oBAG5BC,EAA0C,uCAC1CC,EAAoB,yBACpBC,EAAqD,kDACrDC,EAA6B,iCAGtB,MAAMN,EAAyB,CAAC,CACrC,oBAAAO,EACA,aAAAC,EACA,QAAAC,EACA,OAAAC,CACF,IAKM,CACJ,MAAMC,KAAa,EAAAC,SAAiB,CAAE,QAAAH,CAAQ,CAAC,EAGzC,CAAE,0BAAAI,EAA2B,wBAAAC,CAAwB,KAAI,wCAAqC,CAClG,OAAQP,EACR,QAAAE,CACF,CAAC,EAEKM,EAAY,CAAC,CAACD,GAAyB,sBAAsB,wBAEnE,GAAI,CAACD,EACH,MAAO,GAGT,MAAMG,EAAgB,CACpB,OAAQP,GAAS,MAAM,QAAU,EACjC,qBAAmB,eAAY,CAC7B,OAAQA,GAAS,MAAM,QAAU,EACjC,aAAcD,GAAgB,MAC9B,OAAAE,CACF,CAAC,CACH,EAEMO,EAA+BJ,KACjC,6BAA0B,CACxB,OAAQA,EACR,MAAOJ,GAAS,MAAM,QAAU,CAClC,CAAC,EACDA,GAAS,MAAM,QAAU,EACvBS,EAAyB,CAC7B,OAAQD,EACR,qBAAmB,eAAY,CAC7B,OAAQA,EACR,aAAcT,GAAgB,MAC9B,OAAAE,CACF,CAAC,CACH,EAGA,IAAIS,EAAkBF,EAGtB,GAAIN,GAAY,sBAAwBF,GAAWM,EACjD,GAAIA,EAAW,CAEb,MAAMK,EAAwB,IAAI,EAAAC,QAAQZ,EAAQ,MAAM,MAAM,EAAE,MAAME,EAAW,oBAAoB,EACrGQ,EAAkB,IAAI,EAAAE,QAAQJ,CAA4B,EAAE,MAAMG,CAAqB,EAAE,SAAS,CACpG,KAAO,CAEL,MAAMA,EAAwB,IAAI,EAAAC,QAAQZ,EAAQ,MAAM,MAAM,EAAE,MAAME,EAAW,oBAAoB,EACrG,GAAIM,EAA+BG,EAAsB,SAAS,EAChE,MAAO,EAEX,CAGF,MAAME,EAAY,CAChB,OAAQH,EACR,qBAAmB,eAAY,CAC7B,OAAQA,EACR,aAAcX,GAAgB,MAC9B,OAAAE,CACF,CAAC,CACH,EAEMa,EAAkB,IAAI,EAAAF,QAAQL,EAAc,MAAM,EAAE,MAAMM,EAAU,MAAM,EAAE,SAAS,EACrFE,EAAY,CAChB,OAAQD,EACR,qBAAmB,eAAY,CAC7B,OAAQA,EACR,aAAcf,GAAgB,MAC9B,OAAAE,EACA,sBAAuB,CACzB,CAAC,CACH,EAEMe,EAA+B,IAAI,EAAAJ,QAAQL,EAAc,MAAM,EAClE,MAAME,EAAuB,MAAM,EACnC,SAAS,EACNQ,EAAyB,CAC7B,OAAQD,EACR,qBAAmB,eAAY,CAC7B,OAAQA,EACR,aAAcjB,GAAgB,MAC9B,OAAAE,EACA,sBAAuB,CACzB,CAAC,CACH,EA0BA,MAxB0C,CAExC,eAAgB,CAAC,CAACG,EAClB,UAAAE,EAEA,cAAeC,EAAc,OAC7B,0BAA2BA,EAAc,kBAEzC,UAAWM,EAAU,OACrB,sBAAuBA,EAAU,kBAGjC,uBAAwBJ,EAAuB,OAC/C,mCAAoCA,EAAuB,kBAG3D,UAAWM,EAAU,OACrB,sBAAuBA,EAAU,kBAGjC,uBAAwBE,EAAuB,OAC/C,mCAAoCA,EAAuB,iBAC7D,CAGF",
|
|
6
|
+
"names": ["getFunctionMemberPrice_exports", "__export", "getFunctionMemberPrice", "__toCommonJS", "import_utils", "import_functionDiscountCalculate", "import_decimal", "import_getFunctionMemberPriceDiscountConfig", "import_variantGetCoupon", "memberPriceDiscount", "currencyCode", "variant", "locale", "couponData", "variantGetCoupon", "memberPriceDiscountConfig", "activeMemberPriceConfig", "useCoupon", "originalPrice", "salePriceWithoutCouponAmount", "salePriceWithoutCoupon", "salePriceAmount", "codeSaveAmountDecimal", "Decimal", "salePrice", "savePriceAmount", "savePrice", "savePriceWithoutCouponAmount", "savePriceWithoutCoupon"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DiscountConfig, FunctionMemberPriceConfig } from '../memberPriceTypes';
|
|
2
|
+
import { ProductVariant } from '@anker-in/lib';
|
|
3
|
+
export declare const getFunctionMemberPriceDiscountConfig: ({ config, variant, }: {
|
|
4
|
+
config?: FunctionMemberPriceConfig[];
|
|
5
|
+
variant?: ProductVariant;
|
|
6
|
+
}) => {
|
|
7
|
+
memberPriceDiscountConfig: DiscountConfig | undefined;
|
|
8
|
+
activeMemberPriceConfig: FunctionMemberPriceConfig | undefined;
|
|
9
|
+
};
|