@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.
Files changed (264) hide show
  1. package/dist/cjs/components/credits/context/hooks/useActivities.js +1 -1
  2. package/dist/cjs/components/credits/context/hooks/useActivities.js.map +3 -3
  3. package/dist/cjs/components/credits/context/hooks/useAlpcFetch.js +1 -1
  4. package/dist/cjs/components/credits/context/hooks/useAlpcFetch.js.map +3 -3
  5. package/dist/cjs/components/credits/context/hooks/useFunctionMemberPrice.d.ts +7 -0
  6. package/dist/cjs/components/credits/context/hooks/useFunctionMemberPrice.js +2 -0
  7. package/dist/cjs/components/credits/context/hooks/useFunctionMemberPrice.js.map +7 -0
  8. package/dist/cjs/components/credits/context/hooks/useMyRewards.js +1 -1
  9. package/dist/cjs/components/credits/context/hooks/useMyRewards.js.map +3 -3
  10. package/dist/cjs/components/credits/context/hooks/useRedeemCoupon.js +1 -1
  11. package/dist/cjs/components/credits/context/hooks/useRedeemCoupon.js.map +3 -3
  12. package/dist/cjs/components/credits/context/hooks/useRedeemProduct.js +1 -1
  13. package/dist/cjs/components/credits/context/hooks/useRedeemProduct.js.map +3 -3
  14. package/dist/cjs/components/credits/context/hooks/useRedeemableList.js +1 -1
  15. package/dist/cjs/components/credits/context/hooks/useRedeemableList.js.map +3 -3
  16. package/dist/cjs/components/credits/context/memberPriceConst.d.ts +10 -0
  17. package/dist/cjs/components/credits/context/memberPriceConst.js +2 -0
  18. package/dist/cjs/components/credits/context/memberPriceConst.js.map +7 -0
  19. package/dist/cjs/components/credits/context/memberPriceTypes.d.ts +46 -0
  20. package/dist/cjs/components/credits/context/memberPriceTypes.js +2 -0
  21. package/dist/cjs/components/credits/context/memberPriceTypes.js.map +7 -0
  22. package/dist/cjs/components/credits/context/provider.d.ts +4 -1
  23. package/dist/cjs/components/credits/context/provider.js +1 -1
  24. package/dist/cjs/components/credits/context/provider.js.map +3 -3
  25. package/dist/cjs/components/credits/context/utils/atobID.d.ts +1 -0
  26. package/dist/cjs/components/credits/context/utils/atobID.js +2 -0
  27. package/dist/cjs/components/credits/context/utils/atobID.js.map +7 -0
  28. package/dist/cjs/components/credits/context/utils/functionDiscountCalculate.d.ts +5 -0
  29. package/dist/cjs/components/credits/context/utils/functionDiscountCalculate.js +2 -0
  30. package/dist/cjs/components/credits/context/utils/functionDiscountCalculate.js.map +7 -0
  31. package/dist/cjs/components/credits/context/utils/getFunctionMemberPrice.d.ts +8 -0
  32. package/dist/cjs/components/credits/context/utils/getFunctionMemberPrice.js +2 -0
  33. package/dist/cjs/components/credits/context/utils/getFunctionMemberPrice.js.map +7 -0
  34. package/dist/cjs/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.d.ts +9 -0
  35. package/dist/cjs/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.js +2 -0
  36. package/dist/cjs/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.js.map +7 -0
  37. package/dist/cjs/components/credits/context/utils/variantGetCoupon.d.ts +6 -0
  38. package/dist/cjs/components/credits/context/utils/variantGetCoupon.js +2 -0
  39. package/dist/cjs/components/credits/context/utils/variantGetCoupon.js.map +7 -0
  40. package/dist/cjs/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.d.ts +4 -0
  41. package/dist/cjs/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.js +2 -0
  42. package/dist/cjs/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.js.map +7 -0
  43. package/dist/cjs/components/credits/creditsAnkersolixTask/index.d.ts +2 -0
  44. package/dist/cjs/components/credits/creditsAnkersolixTask/index.js +2 -0
  45. package/dist/cjs/components/credits/creditsAnkersolixTask/index.js.map +7 -0
  46. package/dist/cjs/components/credits/creditsAnkersolixTask/type.d.ts +1 -0
  47. package/dist/cjs/components/credits/creditsAnkersolixTask/type.js +2 -0
  48. package/dist/cjs/components/credits/creditsAnkersolixTask/type.js.map +7 -0
  49. package/dist/cjs/components/credits/creditsBanner/index.d.ts +2 -1
  50. package/dist/cjs/components/credits/creditsBanner/index.js +1 -1
  51. package/dist/cjs/components/credits/creditsBanner/index.js.map +3 -3
  52. package/dist/cjs/components/credits/creditsBenefits/benefitItem.d.ts +4 -1
  53. package/dist/cjs/components/credits/creditsBenefits/benefitItem.js +2 -2
  54. package/dist/cjs/components/credits/creditsBenefits/benefitItem.js.map +4 -4
  55. package/dist/cjs/components/credits/creditsBenefits/iconInfo.js +1 -1
  56. package/dist/cjs/components/credits/creditsBenefits/iconInfo.js.map +2 -2
  57. package/dist/cjs/components/credits/creditsBenefits/index.d.ts +6 -2
  58. package/dist/cjs/components/credits/creditsBenefits/index.js +3 -3
  59. package/dist/cjs/components/credits/creditsBenefits/index.js.map +3 -3
  60. package/dist/cjs/components/credits/creditsCash/CreditsCash.d.ts +2 -1
  61. package/dist/cjs/components/credits/creditsCash/CreditsCash.js +1 -1
  62. package/dist/cjs/components/credits/creditsCash/CreditsCash.js.map +3 -3
  63. package/dist/cjs/components/credits/creditsCash/RedeemableItem.js +1 -1
  64. package/dist/cjs/components/credits/creditsCash/RedeemableItem.js.map +2 -2
  65. package/dist/cjs/components/credits/creditsFaq/index.d.ts +2 -1
  66. package/dist/cjs/components/credits/creditsFaq/index.js +1 -1
  67. package/dist/cjs/components/credits/creditsFaq/index.js.map +3 -3
  68. package/dist/cjs/components/credits/creditsInfoCard/index.d.ts +2 -1
  69. package/dist/cjs/components/credits/creditsInfoCard/index.js +1 -1
  70. package/dist/cjs/components/credits/creditsInfoCard/index.js.map +3 -3
  71. package/dist/cjs/components/credits/creditsMemberPrice/CreditsMemberPrice.d.ts +5 -0
  72. package/dist/cjs/components/credits/creditsMemberPrice/CreditsMemberPrice.js +2 -0
  73. package/dist/cjs/components/credits/creditsMemberPrice/CreditsMemberPrice.js.map +7 -0
  74. package/dist/cjs/components/credits/creditsMemberPrice/MemberPriceItem.d.ts +7 -0
  75. package/dist/cjs/components/credits/creditsMemberPrice/MemberPriceItem.js +2 -0
  76. package/dist/cjs/components/credits/creditsMemberPrice/MemberPriceItem.js.map +7 -0
  77. package/dist/cjs/components/credits/creditsMemberPrice/index.d.ts +2 -0
  78. package/dist/cjs/components/credits/creditsMemberPrice/index.js +2 -0
  79. package/dist/cjs/components/credits/creditsMemberPrice/index.js.map +7 -0
  80. package/dist/cjs/components/credits/creditsMemberPrice/type.d.ts +64 -0
  81. package/dist/cjs/components/credits/creditsMemberPrice/type.js +2 -0
  82. package/dist/cjs/components/credits/creditsMemberPrice/type.js.map +7 -0
  83. package/dist/cjs/components/credits/creditsNavigation/CreditsNavigation.d.ts +4 -0
  84. package/dist/cjs/components/credits/creditsNavigation/CreditsNavigation.js +2 -0
  85. package/dist/cjs/components/credits/creditsNavigation/CreditsNavigation.js.map +7 -0
  86. package/dist/cjs/components/credits/creditsNavigation/index.d.ts +2 -0
  87. package/dist/cjs/components/credits/creditsNavigation/index.js +2 -0
  88. package/dist/cjs/components/credits/creditsNavigation/index.js.map +7 -0
  89. package/dist/cjs/components/credits/creditsNavigation/type.d.ts +7 -0
  90. package/dist/cjs/components/credits/creditsNavigation/type.js +2 -0
  91. package/dist/cjs/components/credits/creditsNavigation/type.js.map +7 -0
  92. package/dist/cjs/components/credits/creditsRedeemList/CreditsRedeemList.d.ts +2 -1
  93. package/dist/cjs/components/credits/creditsRedeemList/CreditsRedeemList.js +1 -1
  94. package/dist/cjs/components/credits/creditsRedeemList/CreditsRedeemList.js.map +3 -3
  95. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Error.js +1 -1
  96. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Error.js.map +2 -2
  97. package/dist/cjs/components/credits/creditsRedeemList/type.d.ts +1 -0
  98. package/dist/cjs/components/credits/creditsRedeemList/type.js +1 -1
  99. package/dist/cjs/components/credits/creditsRedeemList/type.js.map +1 -1
  100. package/dist/cjs/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.d.ts +3 -1
  101. package/dist/cjs/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js +1 -1
  102. package/dist/cjs/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js.map +3 -3
  103. package/dist/cjs/templates/credits.d.ts +15 -1
  104. package/dist/cjs/templates/credits.js +2 -2
  105. package/dist/cjs/templates/credits.js.map +4 -4
  106. package/dist/cjs/templates/index.d.ts +1 -1
  107. package/dist/cjs/templates/index.js +1 -1
  108. package/dist/cjs/templates/index.js.map +1 -1
  109. package/dist/esm/components/credits/context/hooks/useActivities.js +1 -1
  110. package/dist/esm/components/credits/context/hooks/useActivities.js.map +3 -3
  111. package/dist/esm/components/credits/context/hooks/useAlpcFetch.js +1 -1
  112. package/dist/esm/components/credits/context/hooks/useAlpcFetch.js.map +3 -3
  113. package/dist/esm/components/credits/context/hooks/useFunctionMemberPrice.d.ts +7 -0
  114. package/dist/esm/components/credits/context/hooks/useFunctionMemberPrice.js +2 -0
  115. package/dist/esm/components/credits/context/hooks/useFunctionMemberPrice.js.map +7 -0
  116. package/dist/esm/components/credits/context/hooks/useMyRewards.js +1 -1
  117. package/dist/esm/components/credits/context/hooks/useMyRewards.js.map +3 -3
  118. package/dist/esm/components/credits/context/hooks/useRedeemCoupon.js +1 -1
  119. package/dist/esm/components/credits/context/hooks/useRedeemCoupon.js.map +3 -3
  120. package/dist/esm/components/credits/context/hooks/useRedeemProduct.js +1 -1
  121. package/dist/esm/components/credits/context/hooks/useRedeemProduct.js.map +3 -3
  122. package/dist/esm/components/credits/context/hooks/useRedeemableList.js +1 -1
  123. package/dist/esm/components/credits/context/hooks/useRedeemableList.js.map +3 -3
  124. package/dist/esm/components/credits/context/memberPriceConst.d.ts +10 -0
  125. package/dist/esm/components/credits/context/memberPriceConst.js +2 -0
  126. package/dist/esm/components/credits/context/memberPriceConst.js.map +7 -0
  127. package/dist/esm/components/credits/context/memberPriceTypes.d.ts +46 -0
  128. package/dist/esm/components/credits/context/memberPriceTypes.js +1 -0
  129. package/dist/esm/components/credits/context/memberPriceTypes.js.map +7 -0
  130. package/dist/esm/components/credits/context/provider.d.ts +4 -1
  131. package/dist/esm/components/credits/context/provider.js +1 -1
  132. package/dist/esm/components/credits/context/provider.js.map +3 -3
  133. package/dist/esm/components/credits/context/utils/atobID.d.ts +1 -0
  134. package/dist/esm/components/credits/context/utils/atobID.js +2 -0
  135. package/dist/esm/components/credits/context/utils/atobID.js.map +7 -0
  136. package/dist/esm/components/credits/context/utils/functionDiscountCalculate.d.ts +5 -0
  137. package/dist/esm/components/credits/context/utils/functionDiscountCalculate.js +2 -0
  138. package/dist/esm/components/credits/context/utils/functionDiscountCalculate.js.map +7 -0
  139. package/dist/esm/components/credits/context/utils/getFunctionMemberPrice.d.ts +8 -0
  140. package/dist/esm/components/credits/context/utils/getFunctionMemberPrice.js +2 -0
  141. package/dist/esm/components/credits/context/utils/getFunctionMemberPrice.js.map +7 -0
  142. package/dist/esm/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.d.ts +9 -0
  143. package/dist/esm/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.js +2 -0
  144. package/dist/esm/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.js.map +7 -0
  145. package/dist/esm/components/credits/context/utils/variantGetCoupon.d.ts +6 -0
  146. package/dist/esm/components/credits/context/utils/variantGetCoupon.js +2 -0
  147. package/dist/esm/components/credits/context/utils/variantGetCoupon.js.map +7 -0
  148. package/dist/esm/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.d.ts +4 -0
  149. package/dist/esm/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.js +2 -0
  150. package/dist/esm/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.js.map +7 -0
  151. package/dist/esm/components/credits/creditsAnkersolixTask/index.d.ts +2 -0
  152. package/dist/esm/components/credits/creditsAnkersolixTask/index.js +2 -0
  153. package/dist/esm/components/credits/creditsAnkersolixTask/index.js.map +7 -0
  154. package/dist/esm/components/credits/creditsAnkersolixTask/type.d.ts +1 -0
  155. package/dist/esm/components/credits/creditsAnkersolixTask/type.js +2 -0
  156. package/dist/esm/components/credits/creditsAnkersolixTask/type.js.map +7 -0
  157. package/dist/esm/components/credits/creditsBanner/index.d.ts +2 -1
  158. package/dist/esm/components/credits/creditsBanner/index.js +1 -1
  159. package/dist/esm/components/credits/creditsBanner/index.js.map +3 -3
  160. package/dist/esm/components/credits/creditsBenefits/benefitItem.d.ts +4 -1
  161. package/dist/esm/components/credits/creditsBenefits/benefitItem.js +2 -2
  162. package/dist/esm/components/credits/creditsBenefits/benefitItem.js.map +4 -4
  163. package/dist/esm/components/credits/creditsBenefits/iconInfo.js +1 -1
  164. package/dist/esm/components/credits/creditsBenefits/iconInfo.js.map +2 -2
  165. package/dist/esm/components/credits/creditsBenefits/index.d.ts +6 -2
  166. package/dist/esm/components/credits/creditsBenefits/index.js +3 -3
  167. package/dist/esm/components/credits/creditsBenefits/index.js.map +3 -3
  168. package/dist/esm/components/credits/creditsCash/CreditsCash.d.ts +2 -1
  169. package/dist/esm/components/credits/creditsCash/CreditsCash.js +1 -1
  170. package/dist/esm/components/credits/creditsCash/CreditsCash.js.map +3 -3
  171. package/dist/esm/components/credits/creditsCash/RedeemableItem.js +1 -1
  172. package/dist/esm/components/credits/creditsCash/RedeemableItem.js.map +2 -2
  173. package/dist/esm/components/credits/creditsFaq/index.d.ts +2 -1
  174. package/dist/esm/components/credits/creditsFaq/index.js +1 -1
  175. package/dist/esm/components/credits/creditsFaq/index.js.map +3 -3
  176. package/dist/esm/components/credits/creditsInfoCard/index.d.ts +2 -1
  177. package/dist/esm/components/credits/creditsInfoCard/index.js +1 -1
  178. package/dist/esm/components/credits/creditsInfoCard/index.js.map +3 -3
  179. package/dist/esm/components/credits/creditsMemberPrice/CreditsMemberPrice.d.ts +5 -0
  180. package/dist/esm/components/credits/creditsMemberPrice/CreditsMemberPrice.js +2 -0
  181. package/dist/esm/components/credits/creditsMemberPrice/CreditsMemberPrice.js.map +7 -0
  182. package/dist/esm/components/credits/creditsMemberPrice/MemberPriceItem.d.ts +7 -0
  183. package/dist/esm/components/credits/creditsMemberPrice/MemberPriceItem.js +2 -0
  184. package/dist/esm/components/credits/creditsMemberPrice/MemberPriceItem.js.map +7 -0
  185. package/dist/esm/components/credits/creditsMemberPrice/index.d.ts +2 -0
  186. package/dist/esm/components/credits/creditsMemberPrice/index.js +2 -0
  187. package/dist/esm/components/credits/creditsMemberPrice/index.js.map +7 -0
  188. package/dist/esm/components/credits/creditsMemberPrice/type.d.ts +64 -0
  189. package/dist/esm/components/credits/creditsMemberPrice/type.js +1 -0
  190. package/dist/esm/components/credits/creditsMemberPrice/type.js.map +7 -0
  191. package/dist/esm/components/credits/creditsNavigation/CreditsNavigation.d.ts +4 -0
  192. package/dist/esm/components/credits/creditsNavigation/CreditsNavigation.js +2 -0
  193. package/dist/esm/components/credits/creditsNavigation/CreditsNavigation.js.map +7 -0
  194. package/dist/esm/components/credits/creditsNavigation/index.d.ts +2 -0
  195. package/dist/esm/components/credits/creditsNavigation/index.js +2 -0
  196. package/dist/esm/components/credits/creditsNavigation/index.js.map +7 -0
  197. package/dist/esm/components/credits/creditsNavigation/type.d.ts +7 -0
  198. package/dist/esm/components/credits/creditsNavigation/type.js +1 -0
  199. package/dist/esm/components/credits/creditsNavigation/type.js.map +7 -0
  200. package/dist/esm/components/credits/creditsRedeemList/CreditsRedeemList.d.ts +2 -1
  201. package/dist/esm/components/credits/creditsRedeemList/CreditsRedeemList.js +1 -1
  202. package/dist/esm/components/credits/creditsRedeemList/CreditsRedeemList.js.map +3 -3
  203. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Error.js +1 -1
  204. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Error.js.map +2 -2
  205. package/dist/esm/components/credits/creditsRedeemList/type.d.ts +1 -0
  206. package/dist/esm/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.d.ts +3 -1
  207. package/dist/esm/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js +1 -1
  208. package/dist/esm/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js.map +3 -3
  209. package/dist/esm/templates/credits.d.ts +15 -1
  210. package/dist/esm/templates/credits.js +2 -2
  211. package/dist/esm/templates/credits.js.map +4 -4
  212. package/dist/esm/templates/index.d.ts +1 -1
  213. package/dist/esm/templates/index.js +1 -1
  214. package/dist/esm/templates/index.js.map +1 -1
  215. package/dist/index.js +40660 -0
  216. package/dist/index.js.map +1 -0
  217. package/dist/index.mjs +40648 -0
  218. package/dist/index.mjs.map +1 -0
  219. package/package.json +21 -20
  220. package/src/components/credits/context/hooks/useActivities.ts +3 -2
  221. package/src/components/credits/context/hooks/useAlpcFetch.ts +8 -4
  222. package/src/components/credits/context/hooks/useFunctionMemberPrice.ts +33 -0
  223. package/src/components/credits/context/hooks/useMyRewards.ts +3 -2
  224. package/src/components/credits/context/hooks/useRedeemCoupon.ts +4 -1
  225. package/src/components/credits/context/hooks/useRedeemProduct.ts +4 -1
  226. package/src/components/credits/context/hooks/useRedeemableList.ts +3 -3
  227. package/src/components/credits/context/memberPriceConst.ts +13 -0
  228. package/src/components/credits/context/memberPriceTypes.ts +54 -0
  229. package/src/components/credits/context/provider.tsx +9 -0
  230. package/src/components/credits/context/utils/atobID.ts +8 -0
  231. package/src/components/credits/context/utils/functionDiscountCalculate.ts +57 -0
  232. package/src/components/credits/context/utils/getFunctionMemberPrice.ts +135 -0
  233. package/src/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.ts +51 -0
  234. package/src/components/credits/context/utils/variantGetCoupon.ts +34 -0
  235. package/src/components/credits/creditsAnkersolixTask/CreditsAnkersolixTask.tsx +270 -0
  236. package/src/components/credits/creditsAnkersolixTask/index.ts +2 -0
  237. package/src/components/credits/creditsAnkersolixTask/type.ts +7 -0
  238. package/src/components/credits/creditsBanner/index.tsx +2 -2
  239. package/src/components/credits/creditsBenefits/{benefitItem.tsx → BenefitItem.tsx} +28 -9
  240. package/src/components/credits/creditsBenefits/index.tsx +12 -3
  241. package/src/components/credits/creditsCash/CreditsCash.tsx +5 -3
  242. package/src/components/credits/creditsCash/RedeemableItem.tsx +19 -15
  243. package/src/components/credits/creditsFaq/index.tsx +2 -2
  244. package/src/components/credits/creditsInfoCard/index.tsx +2 -2
  245. package/src/components/credits/creditsMemberPrice/CreditsMemberPrice.tsx +389 -0
  246. package/src/components/credits/creditsMemberPrice/MemberPriceItem.tsx +158 -0
  247. package/src/components/credits/creditsMemberPrice/index.ts +2 -0
  248. package/src/components/credits/creditsMemberPrice/type.ts +75 -0
  249. package/src/components/credits/creditsNavigation/CreditsNavigation.tsx +123 -0
  250. package/src/components/credits/creditsNavigation/index.ts +2 -0
  251. package/src/components/credits/creditsNavigation/type.ts +10 -0
  252. package/src/components/credits/creditsRedeemList/CreditsRedeemList.tsx +17 -3
  253. package/src/components/credits/creditsRedeemList/RedeemProductModal/Error.tsx +1 -1
  254. package/src/components/credits/creditsRedeemList/type.ts +1 -0
  255. package/src/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.tsx +2 -2
  256. package/src/templates/{credits.tsx → Credits.tsx} +38 -7
  257. package/src/templates/index.ts +1 -1
  258. package/dist/cjs/components/credits/const.d.ts +0 -1
  259. package/dist/cjs/components/credits/const.js +0 -2
  260. package/dist/cjs/components/credits/const.js.map +0 -7
  261. package/dist/esm/components/credits/const.d.ts +0 -1
  262. package/dist/esm/components/credits/const.js +0 -2
  263. package/dist/esm/components/credits/const.js.map +0 -7
  264. /package/src/components/credits/creditsBenefits/{iconInfo.tsx → IconInfo.tsx} +0 -0
@@ -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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ACL,EACA,GAAGC,EACH,KAAM,KAAK,UAAU,CACnB,GAAGM,EACH,GAAG9B,EAAK,GACV,CAAC,CACH,EACA,SAAU,SACO,MAAMX,EAAOC,EAAQC,EAAOC,CAAK,GAG9CyB,EAAS,EAAI,EACN,IAGF,GAET,UAAW,CAETC,EAAc,CAChB,CACF,CAAC,EACHW,CACF,CAGF",
6
- "names": ["Cookies", "useCallback", "useRef", "useState", "useSWR", "useHeadlessContext", "getAlpcPath", "useCreditsContext", "reAuthPromise", "fetcher", "options", "response", "result", "reAuth", "locale", "retry", "brand", "reloginResponse", "reloginResponseData", "alpcEUCookie", "useMutation", "url", "mutationConfig", "innerMutating", "data", "setData", "isMutating", "setIsMutating", "urlRef", "fetcherRef", "configRef", "trigger", "fetchData", "opts", "config", "onSuccess", "onError", "fetchResult", "err", "useAlpcFetch", "swrOptions", "setRetry", "removeProfile", "enable", "otherSwrOptions", "queryKey", "fetchBody", "headers", "fetchOptions", "fetchEnable", "requestBody", "requestUrl", "useAlpcMutation", "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": "AAAA,OAAOA,MAAa,YACpB,OAAS,eAAAC,EAAa,UAAAC,EAAQ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A,GAAGC,EACH,KAAM,KAAK,UAAU,CACnB,GAAGM,EACH,GAAGhC,EAAK,GACV,CAAC,CACH,EACA,SAAU,SACO,MAAMX,EAAOC,EAAQC,EAAOC,CAAK,GAG9CyB,EAAS,EAAI,EACN,IAGF,GAET,UAAW,CAETC,EAAc,CAChB,CACF,CAAC,EACHa,CACF,CAGF",
6
+ "names": ["Cookies", "useCallback", "useRef", "useState", "useSWR", "useHeadlessContext", "getAlpcPath", "useCreditsContext", "reAuthPromise", "fetcher", "options", "response", "result", "reAuth", "locale", "retry", "brand", "reloginResponse", "reloginResponseData", "alpcEUCookie", "useMutation", "url", "mutationConfig", "innerMutating", "data", "setData", "isMutating", "setIsMutating", "urlRef", "fetcherRef", "configRef", "trigger", "fetchData", "opts", "config", "onSuccess", "onError", "fetchResult", "err", "useAlpcFetch", "swrOptions", "setRetry", "removeProfile", "alpcBrand", "enable", "otherSwrOptions", "headlessBrand", "queryKey", "fetchBody", "headers", "fetchOptions", "fetchEnable", "requestBody", "requestUrl", "useAlpcMutation", "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
+ import{getFunctionMemberPrice as c}from"../utils/getFunctionMemberPrice";import{useMemo as i}from"react";import{useCreditsContext as m}from"../provider";import{useHeadlessContext as n}from"@anker-in/lib";const d=({variant:e})=>{const{memberPriceDiscount:r}=m(),{locale:t=""}=n();return i(()=>{const o=c({memberPriceDiscount:r,currencyCode:e?.price.currencyCode,variant:e,locale:t});return o||{hasMemberPrice:!1}},[t,r,e])};export{d as useFunctionMemberPrice};
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": "AAEA,OAAS,0BAAAA,MAA8B,kCACvC,OAAS,WAAAC,MAAe,QACxB,OAAS,qBAAAC,MAAyB,cAClC,OAAS,sBAAAC,MAA0B,gBAG5B,MAAMC,EAAyB,CAAC,CAAE,QAAAC,CAAQ,IAAoC,CACnF,KAAM,CAAE,oBAAAC,CAAoB,EAAIJ,EAAkB,EAC5C,CAAE,OAAAK,EAAS,EAAG,EAAIJ,EAAmB,EAqB3C,OAfSF,EAAQ,IAAM,CACrB,MAAMO,EAASR,EAAuB,CACpC,oBAAqBM,EACrB,aAAcD,GAAS,MAAM,aAC7B,QAAAA,EACA,OAAAE,CACF,CAAC,EAED,OAAIC,GAIG,CAAE,eAAgB,EAAM,CACjC,EAAG,CAACD,EAAQD,EAAqBD,CAAO,CAAC,CAG3C",
6
+ "names": ["getFunctionMemberPrice", "useMemo", "useCreditsContext", "useHeadlessContext", "useFunctionMemberPrice", "variant", "memberPriceDiscount", "locale", "result"]
7
+ }
@@ -1,2 +1,2 @@
1
- import{useCallback as L,useEffect as A,useState as m}from"react";import{ALPC_COUNTRY_MAP as M,AlpcConsumeType as _}from"../const";import{useAlpcMutation as w}from"./useAlpcFetch";import{useCreditsContext as P}from"../provider";import{useHeadlessContext as x}from"@anker-in/lib";function N({page:e,pageSize:s,consumeType:r}){const{isLoadingProfile:n,profile:t}=P(),{brand:g,locale:c,appName:f}=x(),C=!!t,[u,d]=m([]),[p,y]=m(0),[l,R]=m(0),{isMutating:o,trigger:a}=w({url:"/v1/credit/log/coupon",initData:{brand:g,country:M.get(c)||c,app_name:f}});A(()=>{n||!t||o||e!==l&&e&&a({consume_type:r||_.Coupon,page:e,page_size:s,user_id:t?.user_id},{onSuccess(i){R(e),y(i?.data?.total),d(u.concat(i?.data?.redeem_logs||[]))}})},[a,u,r,e,s,l,t,n,o]);const b=L(async()=>{n||!C||!t||o||await a({consume_type:r||_.Coupon,page:e,page_size:s,user_id:t?.user_id},{onSuccess(i){d(i?.data?.redeem_logs||[])}})},[r,o,n,e,s,t,a]);return{myRewards:u,isLoading:o,total:p,getMyRewards:b,canNext:p>u.length&&!o}}var E=N;export{E as default};
1
+ import{useCallback as M,useEffect as w,useState as c}from"react";import{ALPC_COUNTRY_MAP as P,AlpcConsumeType as _}from"../const";import{useAlpcMutation as x}from"./useAlpcFetch";import{useCreditsContext as N}from"../provider";import{useHeadlessContext as T}from"@anker-in/lib";function h({page:e,pageSize:s,consumeType:r}){const{isLoadingProfile:n,profile:t,alpcBrand:g}=N(),{brand:f,locale:d,appName:C}=T(),y=g||f,R=!!t,[a,m]=c([]),[p,b]=c(0),[l,L]=c(0),{isMutating:o,trigger:u}=x({url:"/v1/credit/log/coupon",initData:{brand:y,country:P.get(d)||d,app_name:C}});w(()=>{n||!t||o||e!==l&&e&&u({consume_type:r||_.Coupon,page:e,page_size:s,user_id:t?.user_id},{onSuccess(i){L(e),b(i?.data?.total),m(a.concat(i?.data?.redeem_logs||[]))}})},[u,a,r,e,s,l,t,n,o]);const A=M(async()=>{n||!R||!t||o||await u({consume_type:r||_.Coupon,page:e,page_size:s,user_id:t?.user_id},{onSuccess(i){m(i?.data?.redeem_logs||[])}})},[r,o,n,e,s,t,u]);return{myRewards:a,isLoading:o,total:p,getMyRewards:A,canNext:p>a.length&&!o}}var H=h;export{H as default};
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": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QAEjD,OAAS,oBAAAC,EAAkB,mBAAAC,MAAuB,WAClD,OAAS,mBAAAC,MAAuB,iBAEhC,OAAS,qBAAAC,MAAyB,cAClC,OAAS,sBAAAC,MAA0B,gBAEnC,SAASC,EAAa,CACpB,KAAAC,EACA,SAAAC,EACA,YAAAC,CACF,EAIG,CACD,KAAM,CAAE,iBAAAC,EAAkB,QAAAC,CAAQ,EAAIP,EAAkB,EAClD,CAAE,MAAAQ,EAAO,OAAAC,EAAQ,QAAAC,CAAQ,EAAIT,EAAmB,EAChDU,EAAU,CAAC,CAACJ,EAEZ,CAACK,EAAWC,CAAY,EAAIjB,EAA8B,CAAC,CAAC,EAC5D,CAACkB,EAAOC,CAAQ,EAAInB,EAAS,CAAC,EAE9B,CAACoB,EAAaC,CAAc,EAAIrB,EAAS,CAAC,EAE1C,CAAE,WAAYsB,EAAW,QAAAC,CAAQ,EAAIpB,EAQzC,CACA,IAAK,wBACL,SAAU,CACR,MAAOS,EACP,QAASX,EAAiB,IAAIY,CAAM,GAAKA,EACzC,SAAUC,CACZ,CACF,CAAC,EAEDf,EAAU,IAAM,CACVW,GAAoB,CAACC,GAAWW,GAIhCf,IAASa,GAAeb,GAC1BgB,EACE,CACE,aAAcd,GAAeP,EAAgB,OAC7C,KAAAK,EACA,UAAWC,EACX,QAASG,GAAS,OACpB,EACA,CACE,UAAUa,EAAc,CACtBH,EAAed,CAAI,EACnBY,EAASK,GAAc,MAAM,KAAK,EAClCP,EAAaD,EAAU,OAAOQ,GAAc,MAAM,aAAe,CAAC,CAAC,CAAC,CACtE,CACF,CACF,CAEJ,EAAG,CAACD,EAASP,EAAWP,EAAaF,EAAMC,EAAUY,EAAaT,EAASD,EAAkBY,CAAS,CAAC,EAEvG,MAAMG,EAAe3B,EAAY,SAAY,CACvCY,GAAoB,CAACK,GAAW,CAACJ,GAAWW,GAGhD,MAAMC,EACJ,CACE,aAAcd,GAAeP,EAAgB,OAC7C,KAAAK,EACA,UAAWC,EACX,QAASG,GAAS,OACpB,EACA,CAEE,UAAUa,EAAc,CACtBP,EAAaO,GAAc,MAAM,aAAe,CAAC,CAAC,CACpD,CACF,CACF,CACF,EAAG,CAACf,EAAaa,EAAWZ,EAAkBH,EAAMC,EAAUG,EAASY,CAAO,CAAC,EAE/E,MAAO,CACL,UAAAP,EACA,UAAAM,EACA,MAAAJ,EACA,aAAAO,EACA,QAASP,EAAQF,EAAU,QAAU,CAACM,CACxC,CACF,CAEA,IAAOI,EAAQpB",
6
- "names": ["useCallback", "useEffect", "useState", "ALPC_COUNTRY_MAP", "AlpcConsumeType", "useAlpcMutation", "useCreditsContext", "useHeadlessContext", "useMyRewards", "page", "pageSize", "consumeType", "isLoadingProfile", "profile", "brand", "locale", "appName", "isLogin", "myRewards", "setMyRewards", "total", "setTotal", "currentPage", "setCurrentPage", "isLoading", "trigger", "responseData", "getMyRewards", "useMyRewards_default"]
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": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QAEjD,OAAS,oBAAAC,EAAkB,mBAAAC,MAAuB,WAClD,OAAS,mBAAAC,MAAuB,iBAEhC,OAAS,qBAAAC,MAAyB,cAClC,OAAS,sBAAAC,MAA0B,gBAEnC,SAASC,EAAa,CACpB,KAAAC,EACA,SAAAC,EACA,YAAAC,CACF,EAIG,CACD,KAAM,CAAE,iBAAAC,EAAkB,QAAAC,EAAS,UAAAC,CAAU,EAAIR,EAAkB,EAC7D,CAAE,MAAOS,EAAe,OAAAC,EAAQ,QAAAC,CAAQ,EAAIV,EAAmB,EAC/DW,EAAQJ,GAAaC,EACrBI,EAAU,CAAC,CAACN,EAEZ,CAACO,EAAWC,CAAY,EAAInB,EAA8B,CAAC,CAAC,EAC5D,CAACoB,EAAOC,CAAQ,EAAIrB,EAAS,CAAC,EAE9B,CAACsB,EAAaC,CAAc,EAAIvB,EAAS,CAAC,EAE1C,CAAE,WAAYwB,EAAW,QAAAC,CAAQ,EAAItB,EAQzC,CACA,IAAK,wBACL,SAAU,CACR,MAAOa,EACP,QAASf,EAAiB,IAAIa,CAAM,GAAKA,EACzC,SAAUC,CACZ,CACF,CAAC,EAEDhB,EAAU,IAAM,CACVW,GAAoB,CAACC,GAAWa,GAIhCjB,IAASe,GAAef,GAC1BkB,EACE,CACE,aAAchB,GAAeP,EAAgB,OAC7C,KAAAK,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,EAAe7B,EAAY,SAAY,CACvCY,GAAoB,CAACO,GAAW,CAACN,GAAWa,GAGhD,MAAMC,EACJ,CACE,aAAchB,GAAeP,EAAgB,OAC7C,KAAAK,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,IAAOI,EAAQtB",
6
+ "names": ["useCallback", "useEffect", "useState", "ALPC_COUNTRY_MAP", "AlpcConsumeType", "useAlpcMutation", "useCreditsContext", "useHeadlessContext", "useMyRewards", "page", "pageSize", "consumeType", "isLoadingProfile", "profile", "alpcBrand", "headlessBrand", "locale", "appName", "brand", "isLogin", "myRewards", "setMyRewards", "total", "setTotal", "currentPage", "setCurrentPage", "isLoading", "trigger", "responseData", "getMyRewards", "useMyRewards_default"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ALPC_COUNTRY_MAP as s}from"../const";import{useAlpcMutation as r}from"./useAlpcFetch";import{useHeadlessContext as p}from"@anker-in/lib";const a=(o={})=>{const{locale:e,appName:n,brand:t}=p();return r({url:"/v1/credit/redeem/coupon",initData:{brand:t,country:s.get(e)||e,app_name:n}},o)};export{a as useRedeemCoupon};
1
+ import{ALPC_COUNTRY_MAP as r}from"../const";import{useAlpcMutation as p}from"./useAlpcFetch";import{useHeadlessContext as a}from"@anker-in/lib";import{useCreditsContext as u}from"../provider";const l=(o={})=>{const{alpcBrand:n}=u(),{locale:e,appName:t,brand:s}=a();return p({url:"/v1/credit/redeem/coupon",initData:{brand:n||s,country:r.get(e)||e,app_name:t}},o)};export{l as useRedeemCoupon};
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": "AAAA,OAAS,oBAAAA,MAAwB,WACjC,OAAS,mBAAAC,MAA+C,iBACxD,OAAS,sBAAAC,MAA0B,gBAW5B,MAAMC,EAAkB,CAACC,EAA2D,CAAC,IAAM,CAChG,KAAM,CAAE,OAAAC,EAAQ,QAAAC,EAAS,MAAAC,CAAM,EAAIL,EAAmB,EAEtD,OAAOD,EAOL,CACE,IAAK,2BACL,SAAU,CACR,MAAAM,EACA,QAASP,EAAiB,IAAIK,CAAM,GAAKA,EACzC,SAAUC,CACZ,CACF,EACAF,CACF,CACF",
6
- "names": ["ALPC_COUNTRY_MAP", "useAlpcMutation", "useHeadlessContext", "useRedeemCoupon", "mutationOptions", "locale", "appName", "brand"]
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": "AAAA,OAAS,oBAAAA,MAAwB,WACjC,OAAS,mBAAAC,MAA+C,iBACxD,OAAS,sBAAAC,MAA0B,gBACnC,OAAS,qBAAAC,MAAyB,cAW3B,MAAMC,EAAkB,CAACC,EAA2D,CAAC,IAAM,CAChG,KAAM,CAAE,UAAAC,CAAU,EAAIH,EAAkB,EAClC,CAAE,OAAAI,EAAQ,QAAAC,EAAS,MAAOC,CAAc,EAAIP,EAAmB,EAGrE,OAAOD,EAOL,CACE,IAAK,2BACL,SAAU,CACR,MAZQK,GAAaG,EAarB,QAAST,EAAiB,IAAIO,CAAM,GAAKA,EACzC,SAAUC,CACZ,CACF,EACAH,CACF,CACF",
6
+ "names": ["ALPC_COUNTRY_MAP", "useAlpcMutation", "useHeadlessContext", "useCreditsContext", "useRedeemCoupon", "mutationOptions", "alpcBrand", "locale", "appName", "headlessBrand"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{ALPC_COUNTRY_MAP as s}from"../const";import{useAlpcMutation as a}from"./useAlpcFetch";import{useHeadlessContext as d}from"@anker-in/lib";const p=(o={})=>{const{storeDomain:t,locale:e,appName:n,brand:r}=d();return a({url:"/v1/credit/exchange/goods",initData:{quantity:1,brand:r,country:(s.get(e||"")||e)?.toUpperCase(),domain:t,app_name:n}},o)};export{p as useRedeemProduct};
1
+ import{ALPC_COUNTRY_MAP as a}from"../const";import{useAlpcMutation as d}from"./useAlpcFetch";import{useHeadlessContext as u}from"@anker-in/lib";import{useCreditsContext as i}from"../provider";const R=(o={})=>{const{alpcBrand:t}=i(),{storeDomain:n,locale:e,appName:r,brand:s}=u();return d({url:"/v1/credit/exchange/goods",initData:{quantity:1,brand:t||s,country:(a.get(e||"")||e)?.toUpperCase(),domain:n,app_name:r}},o)};export{R as useRedeemProduct};
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": "AAAA,OAAS,oBAAAA,MAAwB,WACjC,OAAS,mBAAAC,MAA+C,iBACxD,OAAS,sBAAAC,MAA0B,gBAS5B,MAAMC,EAAmB,CAACC,EAA4D,CAAC,IAAM,CAClG,KAAM,CAAE,YAAAC,EAAa,OAAAC,EAAQ,QAAAC,EAAS,MAAAC,CAAM,EAAIN,EAAmB,EAEnE,OAAOD,EAOL,CACE,IAAK,4BACL,SAAU,CACR,SAAU,EACV,MAAAO,EACA,SAAUR,EAAiB,IAAIM,GAAU,EAAE,GAAKA,IAAS,YAAY,EACrE,OAAQD,EACR,SAAUE,CACZ,CACF,EACAH,CACF,CACF",
6
- "names": ["ALPC_COUNTRY_MAP", "useAlpcMutation", "useHeadlessContext", "useRedeemProduct", "mutationOptions", "storeDomain", "locale", "appName", "brand"]
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": "AAAA,OAAS,oBAAAA,MAAwB,WACjC,OAAS,mBAAAC,MAA+C,iBACxD,OAAS,sBAAAC,MAA0B,gBACnC,OAAS,qBAAAC,MAAyB,cAS3B,MAAMC,EAAmB,CAACC,EAA4D,CAAC,IAAM,CAClG,KAAM,CAAE,UAAAC,CAAU,EAAIH,EAAkB,EAClC,CAAE,YAAAI,EAAa,OAAAC,EAAQ,QAAAC,EAAS,MAAOC,CAAc,EAAIR,EAAmB,EAGlF,OAAOD,EAOL,CACE,IAAK,4BACL,SAAU,CACR,SAAU,EACV,MAbQK,GAAaI,EAcrB,SAAUV,EAAiB,IAAIQ,GAAU,EAAE,GAAKA,IAAS,YAAY,EACrE,OAAQD,EACR,SAAUE,CACZ,CACF,EACAJ,CACF,CACF",
6
+ "names": ["ALPC_COUNTRY_MAP", "useAlpcMutation", "useHeadlessContext", "useCreditsContext", "useRedeemProduct", "mutationOptions", "alpcBrand", "storeDomain", "locale", "appName", "headlessBrand"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{useCallback as C,useEffect as L,useState as R}from"react";import{useAlpcMutation as b}from"./useAlpcFetch";import{ALPC_COUNTRY_MAP as x}from"../const";import{useCreditsContext as y}from"../provider";import{useHeadlessContext as S}from"@anker-in/lib";function A(){let t="";const{profile:n,isLoadingProfile:c}=y(),{locale:u,brand:d}=S();u==="pl"?t="eu":t=u;const[p,_]=R([]),{isMutating:f,trigger:l}=b({url:"/v1/credit/consume_credit_rules",initData:{brand:d,page:1,page_size:20,country:(x.get(t)||t)?.toUpperCase(),task_target:1}}),s=C(()=>{l({user_id:n?.user_id},{onSuccess(g){let a=g.data.consume_credit_rules||[],o=a.filter(e=>e.consume_type==1)||[],r=a.filter(e=>e.consume_type==2)||[];o=o.sort((e,i)=>e.consume_credits-i.consume_credits),r=r.sort((e,i)=>e.consume_credits-i.consume_credits);const m=o.concat(r);_(m),localStorage?.setItem(`consume_credit_rules-${t}`,JSON.stringify({expire:Date.now()+10*60*1e3,consume_credit_rules:m}))}})},[n,l,t]);return L(()=>{c||s()},[s,c]),{listLoading:f,redeemableList:p,getRedeemableList:s}}var O=A;export{O as default};
1
+ import{useCallback as R,useEffect as b,useState as x}from"react";import{useAlpcMutation as y}from"./useAlpcFetch";import{ALPC_COUNTRY_MAP as S}from"../const";import{useCreditsContext as A}from"../provider";import{useHeadlessContext as M}from"@anker-in/lib";function P(){let t="";const{profile:n,isLoadingProfile:c,alpcBrand:m}=A(),{locale:u,brand:p}=M(),_=m||p;u==="pl"?t="eu":t=u;const[f,g]=x([]),{isMutating:C,trigger:l}=y({url:"/v1/credit/consume_credit_rules",initData:{brand:_,page:1,page_size:20,country:(S.get(t)||t)?.toUpperCase()}}),s=R(()=>{l({user_id:n?.user_id},{onSuccess(L){let a=L.data.consume_credit_rules||[],r=a.filter(e=>e.consume_type==1)||[],o=a.filter(e=>e.consume_type==2)||[];r=r.sort((e,i)=>e.consume_credits-i.consume_credits),o=o.sort((e,i)=>e.consume_credits-i.consume_credits);const d=r.concat(o);g(d),localStorage?.setItem(`consume_credit_rules-${t}`,JSON.stringify({expire:Date.now()+10*60*1e3,consume_credit_rules:d}))}})},[n,l,t]);return b(()=>{c||s()},[s,c]),{listLoading:C,redeemableList:f,getRedeemableList:s}}var h=P;export{h as default};
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 task_target: 1, // 1: 'app', 2: 'website'\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": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QAEjD,OAAS,mBAAAC,MAAuB,iBAChC,OAAS,oBAAAC,MAAwB,WACjC,OAAS,qBAAAC,MAAyB,cAElC,OAAS,sBAAAC,MAA0B,gBAEnC,SAASC,GAAoB,CAC3B,IAAIC,EAAS,GACb,KAAM,CAAE,QAAAC,EAAS,iBAAAC,CAAiB,EAAIL,EAAkB,EAClD,CAAE,OAAQM,EAAe,MAAAC,CAAM,EAAIN,EAAmB,EAExDK,IAAkB,KACpBH,EAAS,KAETA,EAASG,EAGX,KAAM,CAACE,EAAgBC,CAAiB,EAAIZ,EAAsC,CAAC,CAAC,EAC9E,CAAE,WAAYa,EAAa,QAAAC,CAAQ,EAAIb,EAK3C,CACA,IAAK,kCACL,SAAU,CACR,MAAAS,EACA,KAAM,EACN,UAAW,GACX,SAAUR,EAAiB,IAAII,CAAM,GAAKA,IAAS,YAAY,EAC/D,YAAa,CACf,CACF,CAAC,EAEKS,EAAoBjB,EAAY,IAAM,CAC1CgB,EACE,CACE,QAASP,GAAS,OACpB,EACA,CACE,UAAUS,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,wBAAwBjB,CAAM,GAC9B,KAAK,UAAU,CACb,OAAQ,KAAK,IAAI,EAAI,GAAK,GAAK,IAC/B,qBAAsBiB,CACxB,CAAC,CACH,CACF,CACF,CACF,CACF,EAAG,CAAChB,EAASO,EAASR,CAAM,CAAC,EAE7B,OAAAP,EAAU,IAAM,CACTS,GACHO,EAAkB,CAEtB,EAAG,CAACA,EAAmBP,CAAgB,CAAC,EAEjC,CACL,YAAAK,EACA,eAAAF,EACA,kBAAAI,CACF,CACF,CAEA,IAAOS,EAAQnB",
6
- "names": ["useCallback", "useEffect", "useState", "useAlpcMutation", "ALPC_COUNTRY_MAP", "useCreditsContext", "useHeadlessContext", "useRedeemableList", "locale", "profile", "isLoadingProfile", "contextLocale", "brand", "redeemableList", "setRedeemableList", "listLoading", "trigger", "getRedeemableList", "responseData", "list", "cList", "i", "pList", "prev", "next", "resultList", "useRedeemableList_default"]
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": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QAEjD,OAAS,mBAAAC,MAAuB,iBAChC,OAAS,oBAAAC,MAAwB,WACjC,OAAS,qBAAAC,MAAyB,cAElC,OAAS,sBAAAC,MAA0B,gBAEnC,SAASC,GAAoB,CAC3B,IAAIC,EAAS,GACb,KAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,UAAAC,CAAU,EAAIN,EAAkB,EAC7D,CAAE,OAAQO,EAAe,MAAOC,CAAc,EAAIP,EAAmB,EACrEQ,EAAQH,GAAaE,EAEvBD,IAAkB,KACpBJ,EAAS,KAETA,EAASI,EAGX,KAAM,CAACG,EAAgBC,CAAiB,EAAId,EAAsC,CAAC,CAAC,EAC9E,CAAE,WAAYe,EAAa,QAAAC,CAAQ,EAAIf,EAK3C,CACA,IAAK,kCACL,SAAU,CACR,MAAAW,EACA,KAAM,EACN,UAAW,GACX,SAAUV,EAAiB,IAAII,CAAM,GAAKA,IAAS,YAAY,CACjE,CACF,CAAC,EAEKW,EAAoBnB,EAAY,IAAM,CAC1CkB,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,OAAAP,EAAU,IAAM,CACTS,GACHS,EAAkB,CAEtB,EAAG,CAACA,EAAmBT,CAAgB,CAAC,EAEjC,CACL,YAAAO,EACA,eAAAF,EACA,kBAAAI,CACF,CACF,CAEA,IAAOS,EAAQrB",
6
+ "names": ["useCallback", "useEffect", "useState", "useAlpcMutation", "ALPC_COUNTRY_MAP", "useCreditsContext", "useHeadlessContext", "useRedeemableList", "locale", "profile", "isLoadingProfile", "alpcBrand", "contextLocale", "headlessBrand", "brand", "redeemableList", "setRedeemableList", "listLoading", "trigger", "getRedeemableList", "responseData", "list", "cList", "i", "pList", "prev", "next", "resultList", "useRedeemableList_default"]
7
7
  }
@@ -0,0 +1,10 @@
1
+ export declare enum FunctionDiscountType {
2
+ Percentage = 1,
3
+ FixedAmount = 2,
4
+ FixedPrice = 3
5
+ }
6
+ export declare enum RoundSelected {
7
+ RoundHighest = "round_highest",
8
+ RoundLowest = "round_lowest",
9
+ RoundNearest = "round_nearest"
10
+ }
@@ -0,0 +1,2 @@
1
+ var x=(r=>(r[r.Percentage=1]="Percentage",r[r.FixedAmount=2]="FixedAmount",r[r.FixedPrice=3]="FixedPrice",r))(x||{}),a=(r=>(r.RoundHighest="round_highest",r.RoundLowest="round_lowest",r.RoundNearest="round_nearest",r))(a||{});export{x as FunctionDiscountType,a as RoundSelected};
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": "AACO,IAAKA,OACVA,IAAA,WAAa,GAAb,aACAA,IAAA,6BACAA,IAAA,2BAHUA,OAAA,IAOAC,OACVA,EAAA,aAAe,gBACfA,EAAA,YAAc,eACdA,EAAA,aAAe,gBAHLA,OAAA",
6
+ "names": ["FunctionDiscountType", "RoundSelected"]
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 @@
1
+ //# sourceMappingURL=memberPriceTypes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
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
- import{jsx as l}from"react/jsx-runtime";import{createContext as u,useContext as P}from"react";const o=u({profile:null,isLoadingProfile:!1,taskIdToTypeMapping:{},removeProfile:()=>{},openSignInPopup:()=>{},openSignUpPopup:()=>{},creditInfo:void 0,customerLoading:!1,fetchCreditInfo:e=>{},gtm:{pageGroup:""},pageCommon:{}});function T({children:e,profile:t,removeProfile:r,isLoadingProfile:n,openSignInPopup:i,openSignUpPopup:p,taskIdToTypeMapping:s,creditInfo:d,customer:C,customerLoading:f,fetchCreditInfo:m,gtm:a,pageCommon:g}){return l(o.Provider,{value:{profile:t,isLoadingProfile:n,removeProfile:r,openSignInPopup:i,openSignUpPopup:p,taskIdToTypeMapping:s,creditInfo:d,fetchCreditInfo:m,customer:C,customerLoading:f,gtm:a,pageCommon:g},children:e})}function h(){const e=P(o);if(!e)throw new Error("useCreditsContext must be used within a CreditsProvider");return e}export{o as CreditsContext,T as CreditsProvider,h as useCreditsContext};
1
+ import{jsx as x}from"react/jsx-runtime";import{createContext as P,useContext as l}from"react";const o=P({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:r,removeProfile:n,isLoadingProfile:t,openSignInPopup:i,openSignUpPopup:p,taskIdToTypeMapping:d,creditInfo:s,customer:m,customerLoading:C,fetchCreditInfo:f,gtm:u,pageCommon:a,memberPriceDiscount:g,alpcBrand:c}){return x(o.Provider,{value:{profile:r,isLoadingProfile:t,removeProfile:n,openSignInPopup:i,openSignUpPopup:p,taskIdToTypeMapping:d,creditInfo:s,fetchCreditInfo:f,customer:m,customerLoading:C,gtm:u,pageCommon:a,memberPriceDiscount:g,alpcBrand:c},children:e})}function _(){const e=l(o);if(!e)throw new Error("useCreditsContext must be used within a CreditsProvider");return e}export{o as CreditsContext,S as CreditsProvider,_ as useCreditsContext};
2
2
  //# sourceMappingURL=provider.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/context/provider.tsx"],
4
- "sourcesContent": ["import { createContext, PropsWithChildren, useContext } from 'react'\nimport type { DTC_TASK_TYPE } from './const'\nimport type { CreditInfoResponse } from './response'\nimport { CreditsPageCommon } from '../type'\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": "AAsDI,cAAAA,MAAA,oBAtDJ,OAAS,iBAAAC,EAAkC,cAAAC,MAAkB,QAsBtD,MAAMC,EAAiBF,EAAuB,CACnD,QAAS,KACT,iBAAkB,GAClB,oBAAqB,CAAC,EACtB,cAAe,IAAM,CAAC,EACtB,gBAAiB,IAAM,CAAC,EACxB,gBAAiB,IAAM,CAAC,EACxB,WAAY,OACZ,gBAAiB,GACjB,gBAAkBG,GAAoB,CAAC,EACvC,IAAK,CACH,UAAW,EACb,EACA,WAAY,CAAC,CACf,CAAC,EAEM,SAASC,EAAgB,CAC9B,SAAAC,EACA,QAAAC,EACA,cAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,oBAAAC,EACA,WAAAC,EACA,SAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,IAAAC,EACA,WAAAC,CACF,EAA+B,CAC7B,OACElB,EAACG,EAAe,SAAf,CACC,MAAO,CACL,QAAAI,EACA,iBAAAE,EACA,cAAAD,EACA,gBAAAE,EACA,gBAAAC,EACA,oBAAAC,EACA,WAAAC,EACA,gBAAAG,EACA,SAAAF,EACA,gBAAAC,EACA,IAAAE,EACA,WAAAC,CACF,EAEC,SAAAZ,EACH,CAEJ,CAEO,SAASa,GAAoB,CAClC,MAAMC,EAAUlB,EAAWC,CAAc,EACzC,GAAI,CAACiB,EACH,MAAM,IAAI,MAAM,yDAAyD,EAE3E,OAAOA,CACT",
6
- "names": ["jsx", "createContext", "useContext", "CreditsContext", "user_id", "CreditsProvider", "children", "profile", "removeProfile", "isLoadingProfile", "openSignInPopup", "openSignUpPopup", "taskIdToTypeMapping", "creditInfo", "customer", "customerLoading", "fetchCreditInfo", "gtm", "pageCommon", "useCreditsContext", "context"]
4
+ "sourcesContent": ["import { createContext, PropsWithChildren, useContext } from 'react'\nimport type { DTC_TASK_TYPE } from './const'\nimport type { CreditInfoResponse } from './response'\nimport { CreditsPageCommon } from '../type'\nimport { FunctionMemberPriceConfig } from './memberPriceTypes'\n\ntype Context = {\n profile: any\n isLoadingProfile: boolean\n removeProfile: () => void\n taskIdToTypeMapping: Record<string, DTC_TASK_TYPE>\n openSignInPopup: () => void\n openSignUpPopup: () => void\n creditInfo?: CreditInfoResponse\n customer?: any\n customerLoading: boolean\n fetchCreditInfo: (user_id: string) => void\n gtm: {\n pageGroup: string\n }\n pageCommon: CreditsPageCommon\n memberPriceDiscount?: FunctionMemberPriceConfig[]\n alpcBrand?: string\n}\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": "AA6DI,cAAAA,MAAA,oBA7DJ,OAAS,iBAAAC,EAAkC,cAAAC,MAAkB,QAyBtD,MAAMC,EAAiBF,EAAuB,CACnD,QAAS,KACT,iBAAkB,GAClB,oBAAqB,CAAC,EACtB,cAAe,IAAM,CAAC,EACtB,gBAAiB,IAAM,CAAC,EACxB,gBAAiB,IAAM,CAAC,EACxB,WAAY,OACZ,gBAAiB,GACjB,gBAAkBG,GAAoB,CAAC,EACvC,IAAK,CACH,UAAW,EACb,EACA,WAAY,CAAC,EACb,oBAAqB,OACrB,UAAW,MACb,CAAC,EAEM,SAASC,EAAgB,CAC9B,SAAAC,EACA,QAAAC,EACA,cAAAC,EACA,iBAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,oBAAAC,EACA,WAAAC,EACA,SAAAC,EACA,gBAAAC,EACA,gBAAAC,EACA,IAAAC,EACA,WAAAC,EACA,oBAAAC,EACA,UAAAC,CACF,EAA+B,CAC7B,OACEpB,EAACG,EAAe,SAAf,CACC,MAAO,CACL,QAAAI,EACA,iBAAAE,EACA,cAAAD,EACA,gBAAAE,EACA,gBAAAC,EACA,oBAAAC,EACA,WAAAC,EACA,gBAAAG,EACA,SAAAF,EACA,gBAAAC,EACA,IAAAE,EACA,WAAAC,EACA,oBAAAC,EACA,UAAAC,CACF,EAEC,SAAAd,EACH,CAEJ,CAEO,SAASe,GAAoB,CAClC,MAAMC,EAAUpB,EAAWC,CAAc,EACzC,GAAI,CAACmB,EACH,MAAM,IAAI,MAAM,yDAAyD,EAE3E,OAAOA,CACT",
6
+ "names": ["jsx", "createContext", "useContext", "CreditsContext", "user_id", "CreditsProvider", "children", "profile", "removeProfile", "isLoadingProfile", "openSignInPopup", "openSignUpPopup", "taskIdToTypeMapping", "creditInfo", "customer", "customerLoading", "fetchCreditInfo", "gtm", "pageCommon", "memberPriceDiscount", "alpcBrand", "useCreditsContext", "context"]
7
7
  }
@@ -0,0 +1 @@
1
+ export declare function atobID(id: string): string | undefined;
@@ -0,0 +1,2 @@
1
+ function e(t){return t&&typeof t=="string"&&t.includes("/")?t.split("/").pop()?.split("?")?.shift():t}export{e as atobID};
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": "AACO,SAASA,EAAOC,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", "id"]
7
+ }
@@ -0,0 +1,5 @@
1
+ import { DiscountConfig } from '../memberPriceTypes';
2
+ export declare const functionDiscountCalculate: ({ config, price, }: {
3
+ config: DiscountConfig;
4
+ price: number;
5
+ }) => number;
@@ -0,0 +1,2 @@
1
+ import{FunctionDiscountType as c,RoundSelected as i}from"../memberPriceConst";import n from"decimal.js";const b=({config:t,price:o})=>{const{apply_price_ending:r,one_decimal_place:a,two_decimal_place:u,round_selected:s}=t.price_ending_conf||{};let e=new n(o);switch(t.discount_type){case c.Percentage:e=e.mul(100-t.discount_value).div(100);break;case c.FixedAmount:e=e.sub(t.discount_value);break;case c.FixedPrice:e=new n(t.discount_value);break;default:break}if(r){switch(s){case i.RoundHighest:e=e.ceil();break;case i.RoundLowest:e=e.floor();break;case i.RoundNearest:e=e.round();break;default:e=new n(e.toFixed(2,n.ROUND_DOWN));break}const d=e.toString().split(".");e=new n(d[0]+"."+a+u)}return e.toNumber()};export{b as functionDiscountCalculate};
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": "AAAA,OAAS,wBAAAA,EAAsB,iBAAAC,MAAqB,sBAEpD,OAAOC,MAAa,aAGb,MAAMC,EAA4B,CAAC,CACxC,OAAAC,EACA,MAAAC,CACF,IAGM,CACJ,KAAM,CAAE,mBAAAC,EAAoB,kBAAAC,EAAmB,kBAAAC,EAAmB,eAAAC,CAAe,EAC/EL,EAAO,mBAAqB,CAAC,EAE/B,IAAIM,EAAY,IAAIR,EAAQG,CAAK,EAEjC,OAAQD,EAAO,cAAe,CAE5B,KAAKJ,EAAqB,WACxBU,EAAYA,EAAU,IAAI,IAAMN,EAAO,cAAc,EAAE,IAAI,GAAG,EAC9D,MAEF,KAAKJ,EAAqB,YACxBU,EAAYA,EAAU,IAAIN,EAAO,cAAc,EAC/C,MAEF,KAAKJ,EAAqB,WACxBU,EAAY,IAAIR,EAAQE,EAAO,cAAc,EAC7C,MACF,QACE,KACJ,CAEA,GAAIE,EAAoB,CAEtB,OAAQG,EAAgB,CACtB,KAAKR,EAAc,aACjBS,EAAYA,EAAU,KAAK,EAC3B,MACF,KAAKT,EAAc,YACjBS,EAAYA,EAAU,MAAM,EAC5B,MACF,KAAKT,EAAc,aACjBS,EAAYA,EAAU,MAAM,EAC5B,MACF,QACEA,EAAY,IAAIR,EAAQQ,EAAU,QAAQ,EAAGR,EAAQ,UAAU,CAAC,EAChE,KACJ,CAEA,MAAMS,EAAcD,EAAU,SAAS,EAAE,MAAM,GAAG,EAClDA,EAAY,IAAIR,EAAQS,EAAY,CAAC,EAAI,IAAMJ,EAAoBC,CAAiB,CACtF,CAEA,OAAOE,EAAU,SAAS,CAC5B",
6
+ "names": ["FunctionDiscountType", "RoundSelected", "Decimal", "functionDiscountCalculate", "config", "price", "apply_price_ending", "one_decimal_place", "two_decimal_place", "round_selected", "salePrice", "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
+ import{formatPrice as o}from"../utils";import{functionDiscountCalculate as b}from"./functionDiscountCalculate";import n from"decimal.js";import{getFunctionMemberPriceDiscountConfig as D}from"./getFunctionMemberPriceDiscountConfig";import d from"./variantGetCoupon";const V=({memberPriceDiscount:l,currencyCode:r,variant:e,locale:i})=>{const m=d({variant:e}),{memberPriceDiscountConfig:c,activeMemberPriceConfig:y}=D({config:l,variant:e}),s=!!y?.discount_combinations.other_product_discounts;if(!c)return!1;const u={amount:e?.price.amount||0,priceWithCurrency:o({amount:e?.price.amount||0,currencyCode:r||"USD",locale:i})},t=c?b({config:c,price:e?.price.amount||0}):e?.price.amount||0,a={amount:t,priceWithCurrency:o({amount:t,currencyCode:r||"USD",locale:i})};let p=t;if(m?.variant_price4wscode&&e&&s)if(s){const P=new n(e.price.amount).minus(m.variant_price4wscode);p=new n(t).minus(P).toNumber()}else{const P=new n(e.price.amount).minus(m.variant_price4wscode);if(t>P.toNumber())return!1}const C={amount:p,priceWithCurrency:o({amount:p,currencyCode:r||"USD",locale:i})},h=new n(u.amount).minus(C.amount).toNumber(),f={amount:h,priceWithCurrency:o({amount:h,currencyCode:r||"USD",locale:i,maximumFractionDigits:2})},W=new n(u.amount).minus(a.amount).toNumber(),g={amount:W,priceWithCurrency:o({amount:W,currencyCode:r||"USD",locale:i,maximumFractionDigits:2})};return{hasMemberPrice:!!c,useCoupon:s,originalPrice:u.amount,originalPriceWithCurrency:u.priceWithCurrency,salePrice:C.amount,salePriceWithCurrency:C.priceWithCurrency,salePriceWithoutCoupon:a.amount,salePriceWithoutCouponWithCurrency:a.priceWithCurrency,savePrice:f.amount,savePriceWithCurrency:f.priceWithCurrency,savePriceWithoutCoupon:g.amount,savePriceWithoutCouponWithCurrency:g.priceWithCurrency}};export{V as getFunctionMemberPrice};
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": "AAAA,OAAS,eAAAA,MAAmB,WAG5B,OAAS,6BAAAC,MAAiC,8BAC1C,OAAOC,MAAa,aACpB,OAAS,wCAAAC,MAA4C,yCACrD,OAAOC,MAAsB,qBAGtB,MAAMC,EAAyB,CAAC,CACrC,oBAAAC,EACA,aAAAC,EACA,QAAAC,EACA,OAAAC,CACF,IAKM,CACJ,MAAMC,EAAaN,EAAiB,CAAE,QAAAI,CAAQ,CAAC,EAGzC,CAAE,0BAAAG,EAA2B,wBAAAC,CAAwB,EAAIT,EAAqC,CAClG,OAAQG,EACR,QAAAE,CACF,CAAC,EAEKK,EAAY,CAAC,CAACD,GAAyB,sBAAsB,wBAEnE,GAAI,CAACD,EACH,MAAO,GAGT,MAAMG,EAAgB,CACpB,OAAQN,GAAS,MAAM,QAAU,EACjC,kBAAmBR,EAAY,CAC7B,OAAQQ,GAAS,MAAM,QAAU,EACjC,aAAcD,GAAgB,MAC9B,OAAAE,CACF,CAAC,CACH,EAEM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zC,UAAWK,EAAU,OACrB,sBAAuBA,EAAU,kBAGjC,uBAAwBH,EAAuB,OAC/C,mCAAoCA,EAAuB,kBAG3D,UAAWK,EAAU,OACrB,sBAAuBA,EAAU,kBAGjC,uBAAwBE,EAAuB,OAC/C,mCAAoCA,EAAuB,iBAC7D,CAGF",
6
+ "names": ["formatPrice", "functionDiscountCalculate", "Decimal", "getFunctionMemberPriceDiscountConfig", "variantGetCoupon", "getFunctionMemberPrice", "memberPriceDiscount", "currencyCode", "variant", "locale", "couponData", "memberPriceDiscountConfig", "activeMemberPriceConfig", "useCoupon", "originalPrice", "salePriceWithoutCouponAmount", "salePriceWithoutCoupon", "salePriceAmount", "codeSaveAmountDecimal", "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
+ };
@@ -0,0 +1,2 @@
1
+ import{atobID as f}from"./atobID";const b=({config:e,variant:t})=>{let i,r;if(!e||!t)return{memberPriceDiscountConfig:i,activeMemberPriceConfig:r};for(const o of e)if(i=o.result_detail.member_discounts?.find(n=>n.main_products.all_store_variant?n:n.main_products.variants.find(c=>String(c.variant_id)===f(t.id)))?.discount_conf,i){r=o;break}return i?{memberPriceDiscountConfig:i,activeMemberPriceConfig:r}:{memberPriceDiscountConfig:i,activeMemberPriceConfig:r}};export{b as getFunctionMemberPriceDiscountConfig};
2
+ //# sourceMappingURL=getFunctionMemberPriceDiscountConfig.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/components/credits/context/utils/getFunctionMemberPriceDiscountConfig.ts"],
4
+ "sourcesContent": ["import { DiscountConfig, FunctionMemberPriceConfig } from '../memberPriceTypes'\nimport { ProductVariant } from '@anker-in/lib'\nimport { atobID } from './atobID'\n\n// \u83B7\u53D6\u4F1A\u5458\u4EF7\u6298\u6263\u914D\u7F6E\nexport const getFunctionMemberPriceDiscountConfig = ({\n config,\n variant,\n}: {\n config?: FunctionMemberPriceConfig[]\n variant?: ProductVariant\n}) => {\n let memberPriceDiscountConfig: DiscountConfig | undefined\n let activeMemberPriceConfig: FunctionMemberPriceConfig | undefined\n\n if (!config || !variant) {\n return {\n memberPriceDiscountConfig,\n activeMemberPriceConfig,\n }\n }\n\n for (const configItem of config) {\n memberPriceDiscountConfig = configItem.result_detail.member_discounts?.find(discountItem => {\n if (discountItem.main_products.all_store_variant) {\n return discountItem\n }\n\n return discountItem.main_products.variants.find(\n variantConfig => String(variantConfig.variant_id) === atobID(variant.id as string)\n )\n })?.discount_conf\n\n if (memberPriceDiscountConfig) {\n activeMemberPriceConfig = configItem\n break\n }\n }\n\n if (!memberPriceDiscountConfig) {\n return {\n memberPriceDiscountConfig,\n activeMemberPriceConfig,\n }\n }\n\n return {\n memberPriceDiscountConfig,\n activeMemberPriceConfig,\n }\n}\n"],
5
+ "mappings": "AAEA,OAAS,UAAAA,MAAc,WAGhB,MAAMC,EAAuC,CAAC,CACnD,OAAAC,EACA,QAAAC,CACF,IAGM,CACJ,IAAIC,EACAC,EAEJ,GAAI,CAACH,GAAU,CAACC,EACd,MAAO,CACL,0BAAAC,EACA,wBAAAC,CACF,EAGF,UAAWC,KAAcJ,EAWvB,GAVAE,EAA4BE,EAAW,cAAc,kBAAkB,KAAKC,GACtEA,EAAa,cAAc,kBACtBA,EAGFA,EAAa,cAAc,SAAS,KACzCC,GAAiB,OAAOA,EAAc,UAAU,IAAMR,EAAOG,EAAQ,EAAY,CACnF,CACD,GAAG,cAEAC,EAA2B,CAC7BC,EAA0BC,EAC1B,KACF,CAGF,OAAKF,EAOE,CACL,0BAAAA,EACA,wBAAAC,CACF,EATS,CACL,0BAAAD,EACA,wBAAAC,CACF,CAOJ",
6
+ "names": ["atobID", "getFunctionMemberPriceDiscountConfig", "config", "variant", "memberPriceDiscountConfig", "activeMemberPriceConfig", "configItem", "discountItem", "variantConfig"]
7
+ }
@@ -0,0 +1,6 @@
1
+ import { ProductVariant } from '@anker-in/lib';
2
+ declare const variantGetCoupon: ({ variant, channel, }: {
3
+ variant?: ProductVariant;
4
+ channel?: string;
5
+ }) => any;
6
+ export default variantGetCoupon;
@@ -0,0 +1,2 @@
1
+ import{atobID as a}from"./atobID";const r=({variant:e,channel:i=""})=>{if(!e)return;const s="wsch";return(e?.metafields?.discountCodeApp||[])?.filter(t=>{const n=a(e.id);return(!t?.ends_at||new Date(t?.ends_at).getTime()>new Date().getTime())&&new Date(t?.starts_at).getTime()<=new Date().getTime()&&t.variant_shopify_id===+(n||"")&&(i?t?.title?.toLocaleLowerCase().includes(i):!t?.title?.toLocaleLowerCase().includes(s))})?.[0]};var f=r;export{f as default};
2
+ //# sourceMappingURL=variantGetCoupon.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/components/credits/context/utils/variantGetCoupon.ts"],
4
+ "sourcesContent": ["import { ProductVariant } from '@anker-in/lib'\nimport { atobID } from './atobID'\n\nconst variantGetCoupon = ({\n variant,\n channel = '',\n}: {\n variant?: ProductVariant\n channel?: string\n}) => {\n if (!variant) return undefined\n\n const hideChannel = 'wsch'\n const discountCodeApp = variant?.metafields?.discountCodeApp || []\n\n const results = discountCodeApp?.filter((coupon: any) => {\n const variantId = atobID(variant.id as string)\n const isActive =\n (!coupon?.ends_at || new Date(coupon?.ends_at).getTime() > new Date().getTime()) &&\n new Date(coupon?.starts_at).getTime() <= new Date().getTime() &&\n coupon.variant_shopify_id === +(variantId || '')\n\n return (\n isActive &&\n (channel\n ? coupon?.title?.toLocaleLowerCase().includes(channel)\n : !coupon?.title?.toLocaleLowerCase().includes(hideChannel))\n )\n })\n\n return results?.[0]\n}\n\nexport default variantGetCoupon\n"],
5
+ "mappings": "AACA,OAAS,UAAAA,MAAc,WAEvB,MAAMC,EAAmB,CAAC,CACxB,QAAAC,EACA,QAAAC,EAAU,EACZ,IAGM,CACJ,GAAI,CAACD,EAAS,OAEd,MAAME,EAAc,OAkBpB,OAjBwBF,GAAS,YAAY,iBAAmB,CAAC,IAEhC,OAAQG,GAAgB,CACvD,MAAMC,EAAYN,EAAOE,EAAQ,EAAY,EAM7C,OAJG,CAACG,GAAQ,SAAW,IAAI,KAAKA,GAAQ,OAAO,EAAE,QAAQ,EAAI,IAAI,KAAK,EAAE,QAAQ,IAC9E,IAAI,KAAKA,GAAQ,SAAS,EAAE,QAAQ,GAAK,IAAI,KAAK,EAAE,QAAQ,GAC5DA,EAAO,qBAAuB,EAAEC,GAAa,MAI5CH,EACGE,GAAQ,OAAO,kBAAkB,EAAE,SAASF,CAAO,EACnD,CAACE,GAAQ,OAAO,kBAAkB,EAAE,SAASD,CAAW,EAEhE,CAAC,IAEgB,CAAC,CACpB,EAEA,IAAOG,EAAQN",
6
+ "names": ["atobID", "variantGetCoupon", "variant", "channel", "hideChannel", "coupon", "variantId", "variantGetCoupon_default"]
7
+ }
@@ -0,0 +1,4 @@
1
+ import { type CreditsAnkersolixTaskProps } from './type';
2
+ export declare const CreditsAnkersolixTask: ({ copy, classNames, id }: CreditsAnkersolixTaskProps & {
3
+ id?: string;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ import{Fragment as A,jsx as e,jsxs as i}from"react/jsx-runtime";import{Button as y,Container as P,Heading as b,Picture as z,Text as _}from"@anker-in/headless-ui";import{ChevronDownIcon as E,ChevronUpIcon as H}from"@heroicons/react/24/outline";import{motion as j}from"framer-motion";import{useMemo as q,useState as d}from"react";import{TaskType as g}from"./type";import{useActions as V}from"../creditsWaysToGetCredits/useActions";import{useCreditsContext as G}from"../context/provider";import{classNames as h,useHeadlessContext as J,ROUNDED_BRANDS as K}from"@anker-in/lib";import{useRegistration as Q}from"../../registration";import{CreditsUploadReceiptModal as W}from"../modal/creditsUploadReceiptModal";import{CreditsSubscribeModal as X}from"../modal/subscribeModal";const re=({copy:s,classNames:Y,id:v})=>{const[l,k]=d(!1),{profile:M}=G(),{authCodeActivate:R}=Q(),{brand:L}=J(),p=K.includes(L),m=!!M,[T,C]=d(!1),[U,x]=d(!1),[F,O]=d(!1),[N,B]=d(!1),{actions:u}=V({copy:s,subscribe:{openSubscribePopup:()=>x(!0),isSuccess:F},uploadReceipt:{openUploadReceiptPopup:()=>C(!0),isSuccess:N}}),w=q(()=>{const t=s.list.map(n=>{if(!u[n.id])return;const{finished:o,notLogin:S,notFinished:f,completed:D}=u[n.id];let r="",c,I;return m?o?(r=D.buttonLabel,c=void 0):(r=f.buttonLabel,c=f.handleClick,I=f.link):(r=S.buttonLabel,c=S.handleClick),{...n,buttonLabel:r,handleClick:c,finished:o,link:I}}).filter(Boolean);return m?t.sort((n,o)=>n?.finished&&!o?.finished?1:!n?.finished&&o?.finished?-1:0):t},[u,s.list,m]),a=w.length>3;return i(P,{id:v,className:"[&>div]:l:!px-0 bg-[#F5F5F7]",children:[e(b,{as:"h2",size:"4",html:s.title,className:"md:px-[16px]"}),i("div",{className:h("mt-[24px] p-[32px] md-l:p-[32px] md:p-[16px] relative overflow-hidden",p?"rounded-[8px]":"",!p&&"l:rounded-none"),style:{background:"linear-gradient(180deg, rgba(255, 241, 214, 0) 39.51%, #F4CA81 119.53%)"},children:[e("div",{className:"absolute inset-0 pointer-events-none -z-10",style:{background:"radial-gradient(ellipse 130% 205% at 45% -20%, #FFF6EA 0%, #FFFFFF 73%, #FFF1D6 100%)"}}),i("div",{className:"flex items-center justify-between h-[560px] md:h-auto md:flex-col md:items-start l:h-auto l:mb-[16px] l:flex-col-reverse l:items-start",children:[i("div",{className:"flex flex-col gap-[8px]",children:[e(b,{as:"h3",size:4,html:s?.subtitle,className:"text-[32px] font-bold text-[#080a0f] tracking-[-1.28px] leading-[1.2] xl:text-[24px]"}),e("div",{className:"flex items-center gap-[8px]",children:e("p",{className:"text-[48px] font-bold tracking-[-1.92px] leading-none bg-gradient-to-r from-[#2c7ed0] via-[#00a9e1] via-43% to-[#00db84] bg-clip-text text-transparent xl-xxl:text-[40px] l-xl:text-[32px] l:text-[24px]",dangerouslySetInnerHTML:{__html:s.equalCredits}})})]}),s.mainImage?.url&&e(z,{className:"w-full max-w-[50%] md:max-w-full md:mt-[24px] l:max-w-full l:mt-[24px]",source:s.mainImage.url})]}),i("div",{className:"relative",children:[i(j.div,{className:h("grid grid-cols-3 gap-[16px] overflow-hidden md:grid-cols-1 md-l:grid-cols-2 min-md:!h-auto"),initial:{height:a?512:"auto"},animate:{height:l||!a?"auto":512},transition:{duration:.3},onAnimationComplete:()=>{if(!l&&a&&window.screen.width<768){const t=document.getElementById(v||"ankersolix-task");t&&t.scrollIntoView({behavior:"smooth",block:"end"})}},children:[w.map(t=>i("div",{className:h("flex min-h-[241px] xl-xxl:min-h-[192px] l:min-h-[160px] l-xl:min-h-[170px] flex-col justify-between bg-white p-[32px] md:p-[16px] l:p-[24px]",""),children:[i("div",{children:[e(b,{as:"h4",html:t.title,size:2,className:"text-[24px] font-bold text-[#080a0f] tracking-[-0.96px] leading-[1.2] text-pretty md:text-[18px] l:text-[20px]"}),i("div",{className:"mt-[8px] flex items-center gap-[4px]",children:[e(z,{className:"size-[24px] [&_path]:size-full",source:"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/20250902-153351.png?v=1756798450"}),e(_,{as:"p",html:t.credits,size:2,className:"text-[18px] font-bold text-[#080a0f] tracking-[-0.36px] leading-[1.4] md:text-[16px]"})]})]}),t.handleClick&&!(t.id===g.UploadReceipt&&N)&&!(t.id===g.Activate&&R.isActivateSuccess)&&!(t.id===g.Subscribe&&F)?e(y,{as:t.link?"a":"button",...t.link&&{href:t.link},...t.handleClick&&{onClick:t.handleClick},variant:"primary",size:"lg",className:"mt-[24px] w-fit bg-[#080a0f] text-white text-[16px] font-bold tracking-[-0.64px] leading-[1.2]",children:t.buttonLabel}):e(y,{variant:"primary",size:"lg",className:"mt-[24px] w-fit bg-[#080a0f] text-white text-[16px] font-bold tracking-[-0.64px] leading-[1.2]",disabled:!0,children:t.buttonLabel})]},t.id)),!l&&a&&e("div",{className:"absolute inset-0 pointer-events-none min-md:hidden",style:{background:"linear-gradient(180deg, rgba(244, 202, 129, 0) 66.37%, #f4ca81 100%)"}})]}),a&&e(A,{children:l?e("button",{className:"mx-auto mt-[12px] block w-fit min-md:hidden",onClick:()=>{k(!1)},children:e(H,{className:"size-[40px] rounded-full bg-[#FFFFFF33] p-[8px]"})}):e(A,{children:e("div",{className:"absolute bottom-0 flex w-full translate-y-1/2 justify-center min-md:hidden",children:e("button",{className:"w-fit",onClick:()=>k(!l),children:e(E,{className:"size-[40px] rounded-full bg-[#FFFFFF33] p-[8px]"})})})})})]})]}),s.receipt&&e(W,{isOpen:T,onClose:()=>{C(!1)},copy:s.receipt,onSuccess:()=>{B(!0)}}),s.subscribe&&e(X,{copy:s.subscribe,onSuccess:()=>{O(!0),setTimeout(()=>{x(!1)},3e3)},isOpen:U,onClose:()=>{x(!1)}})]})};export{re as CreditsAnkersolixTask};
2
+ //# sourceMappingURL=CreditsAnkersolixTask.js.map