@anker-in/campaign-ui 0.2.10-beta.22 → 0.2.10-beta.23

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 (314) hide show
  1. package/dist/cjs/components/chat/action.js +2 -0
  2. package/dist/cjs/components/chat/action.js.map +7 -0
  3. package/dist/cjs/components/chat/button.js +2 -0
  4. package/dist/cjs/components/chat/button.js.map +7 -0
  5. package/dist/cjs/components/chat/chatContext.js +2 -0
  6. package/dist/cjs/components/chat/chatContext.js.map +7 -0
  7. package/dist/cjs/components/chat/index.js +2 -0
  8. package/dist/cjs/components/chat/index.js.map +7 -0
  9. package/dist/cjs/components/chat/markdown.js +2 -0
  10. package/dist/cjs/components/chat/markdown.js.map +7 -0
  11. package/dist/cjs/components/chat/messages.js +2 -0
  12. package/dist/cjs/components/chat/messages.js.map +7 -0
  13. package/dist/cjs/components/chat/props.js +2 -0
  14. package/dist/cjs/components/chat/props.js.map +7 -0
  15. package/dist/cjs/components/chat/response.js +2 -0
  16. package/dist/cjs/components/chat/response.js.map +7 -0
  17. package/dist/cjs/components/chat/suggestions.js +2 -0
  18. package/dist/cjs/components/chat/suggestions.js.map +7 -0
  19. package/dist/cjs/components/chat/utils.js +2 -0
  20. package/dist/cjs/components/chat/utils.js.map +7 -0
  21. package/dist/cjs/components/credits/context/const.js +2 -0
  22. package/dist/cjs/components/credits/context/const.js.map +7 -0
  23. package/dist/cjs/components/credits/context/hooks/useActivities.js +2 -0
  24. package/dist/cjs/components/credits/context/hooks/useActivities.js.map +7 -0
  25. package/dist/cjs/components/credits/context/hooks/useAddressValidate.js +2 -0
  26. package/dist/cjs/components/credits/context/hooks/useAddressValidate.js.map +7 -0
  27. package/dist/cjs/components/credits/context/hooks/useAlpcFetch.js +2 -0
  28. package/dist/cjs/components/credits/context/hooks/useAlpcFetch.js.map +7 -0
  29. package/dist/cjs/components/credits/context/hooks/useClickOutside.js +2 -0
  30. package/dist/cjs/components/credits/context/hooks/useClickOutside.js.map +7 -0
  31. package/dist/cjs/components/credits/context/hooks/useCopy.js +2 -0
  32. package/dist/cjs/components/credits/context/hooks/useCopy.js.map +7 -0
  33. package/dist/cjs/components/credits/context/hooks/useCountries.js +2 -0
  34. package/dist/cjs/components/credits/context/hooks/useCountries.js.map +7 -0
  35. package/dist/cjs/components/credits/context/hooks/useFirstPurchaseFinished.js +2 -0
  36. package/dist/cjs/components/credits/context/hooks/useFirstPurchaseFinished.js.map +7 -0
  37. package/dist/cjs/components/credits/context/hooks/useMyRewards.js +2 -0
  38. package/dist/cjs/components/credits/context/hooks/useMyRewards.js.map +7 -0
  39. package/dist/cjs/components/credits/context/hooks/useReceiptUploaded.js +2 -0
  40. package/dist/cjs/components/credits/context/hooks/useReceiptUploaded.js.map +7 -0
  41. package/dist/cjs/components/credits/context/hooks/useRedeemAndBuy.js +2 -0
  42. package/dist/cjs/components/credits/context/hooks/useRedeemAndBuy.js.map +7 -0
  43. package/dist/cjs/components/credits/context/hooks/useRedeemCoupon.js +2 -0
  44. package/dist/cjs/components/credits/context/hooks/useRedeemCoupon.js.map +7 -0
  45. package/dist/cjs/components/credits/context/hooks/useRedeemProduct.js +2 -0
  46. package/dist/cjs/components/credits/context/hooks/useRedeemProduct.js.map +7 -0
  47. package/dist/cjs/components/credits/context/hooks/useRedeemableList.js +2 -0
  48. package/dist/cjs/components/credits/context/hooks/useRedeemableList.js.map +7 -0
  49. package/dist/cjs/components/credits/context/hooks/useSendEmailValidation.js +2 -0
  50. package/dist/cjs/components/credits/context/hooks/useSendEmailValidation.js.map +7 -0
  51. package/dist/cjs/components/credits/context/hooks/useSubscribed.js +2 -0
  52. package/dist/cjs/components/credits/context/hooks/useSubscribed.js.map +7 -0
  53. package/dist/cjs/components/credits/context/hooks/useSubscriptions.js +2 -0
  54. package/dist/cjs/components/credits/context/hooks/useSubscriptions.js.map +7 -0
  55. package/dist/cjs/components/credits/context/hooks/useUploadReceipt.js +2 -0
  56. package/dist/cjs/components/credits/context/hooks/useUploadReceipt.js.map +7 -0
  57. package/dist/cjs/components/credits/context/provider.js +2 -0
  58. package/dist/cjs/components/credits/context/provider.js.map +7 -0
  59. package/dist/cjs/components/credits/context/response.js +2 -0
  60. package/dist/cjs/components/credits/context/response.js.map +7 -0
  61. package/dist/cjs/components/credits/context/utils.js +2 -0
  62. package/dist/cjs/components/credits/context/utils.js.map +7 -0
  63. package/dist/cjs/components/credits/creditsBanner/index.js +2 -0
  64. package/dist/cjs/components/credits/creditsBanner/index.js.map +7 -0
  65. package/dist/cjs/components/credits/creditsBenefits/benefitItem.js +2 -0
  66. package/dist/cjs/components/credits/creditsBenefits/benefitItem.js.map +7 -0
  67. package/dist/cjs/components/credits/creditsBenefits/iconInfo.js +2 -0
  68. package/dist/cjs/components/credits/creditsBenefits/iconInfo.js.map +7 -0
  69. package/dist/cjs/components/credits/creditsBenefits/index.js +4 -0
  70. package/dist/cjs/components/credits/creditsBenefits/index.js.map +7 -0
  71. package/dist/cjs/components/credits/creditsCash/RedeemableItem.js +2 -0
  72. package/dist/cjs/components/credits/creditsCash/RedeemableItem.js.map +7 -0
  73. package/dist/cjs/components/credits/creditsCash/index.js +2 -0
  74. package/dist/cjs/components/credits/creditsCash/index.js.map +7 -0
  75. package/dist/cjs/components/credits/creditsCash/type.js +2 -0
  76. package/dist/cjs/components/credits/creditsCash/type.js.map +7 -0
  77. package/dist/cjs/components/credits/creditsFaq/faqItem/FaqItem.js +2 -0
  78. package/dist/cjs/components/credits/creditsFaq/faqItem/FaqItem.js.map +7 -0
  79. package/dist/cjs/components/credits/creditsFaq/index.js +2 -0
  80. package/dist/cjs/components/credits/creditsFaq/index.js.map +7 -0
  81. package/dist/cjs/components/credits/creditsInfoCard/index.js +2 -0
  82. package/dist/cjs/components/credits/creditsInfoCard/index.js.map +7 -0
  83. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/CountrySelect.js +2 -0
  84. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/CountrySelect.js.map +7 -0
  85. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/FormItem.js +2 -0
  86. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/FormItem.js.map +7 -0
  87. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/Input.js +2 -0
  88. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/Input.js.map +7 -0
  89. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/StateSelect.js +2 -0
  90. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/StateSelect.js.map +7 -0
  91. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/index.js +2 -0
  92. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/index.js.map +7 -0
  93. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/type.js +2 -0
  94. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/type.js.map +7 -0
  95. package/dist/cjs/components/credits/creditsRedeemList/RedeemCouponModal.js +2 -0
  96. package/dist/cjs/components/credits/creditsRedeemList/RedeemCouponModal.js.map +7 -0
  97. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Address.js +2 -0
  98. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Address.js.map +7 -0
  99. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Error.js +2 -0
  100. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Error.js.map +7 -0
  101. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Init.js +2 -0
  102. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Init.js.map +7 -0
  103. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js +2 -0
  104. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js.map +7 -0
  105. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Success.js +2 -0
  106. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Success.js.map +7 -0
  107. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/index.js +2 -0
  108. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/index.js.map +7 -0
  109. package/dist/cjs/components/credits/creditsRedeemList/RedeemableItem.js +2 -0
  110. package/dist/cjs/components/credits/creditsRedeemList/RedeemableItem.js.map +7 -0
  111. package/dist/cjs/components/credits/creditsRedeemList/index.js +2 -0
  112. package/dist/cjs/components/credits/creditsRedeemList/index.js.map +7 -0
  113. package/dist/cjs/components/credits/creditsRedeemList/type.js +2 -0
  114. package/dist/cjs/components/credits/creditsRedeemList/type.js.map +7 -0
  115. package/dist/cjs/components/credits/creditsWaysToGetCredits/index.js +2 -0
  116. package/dist/cjs/components/credits/creditsWaysToGetCredits/index.js.map +7 -0
  117. package/dist/cjs/components/credits/creditsWaysToGetCredits/type.js +2 -0
  118. package/dist/cjs/components/credits/creditsWaysToGetCredits/type.js.map +7 -0
  119. package/dist/cjs/components/credits/creditsWaysToGetCredits/useActions.js +2 -0
  120. package/dist/cjs/components/credits/creditsWaysToGetCredits/useActions.js.map +7 -0
  121. package/dist/cjs/components/credits/index.js +2 -0
  122. package/dist/cjs/components/credits/index.js.map +7 -0
  123. package/dist/cjs/components/credits/modal/MyRewardsModal.js +2 -0
  124. package/dist/cjs/components/credits/modal/MyRewardsModal.js.map +7 -0
  125. package/dist/cjs/components/credits/modal/activitiesModal.js +2 -0
  126. package/dist/cjs/components/credits/modal/activitiesModal.js.map +7 -0
  127. package/dist/cjs/components/credits/modal/creditsUploadReceiptModal.js +2 -0
  128. package/dist/cjs/components/credits/modal/creditsUploadReceiptModal.js.map +7 -0
  129. package/dist/cjs/components/credits/modal/loadingDots.js +2 -0
  130. package/dist/cjs/components/credits/modal/loadingDots.js.map +7 -0
  131. package/dist/cjs/components/credits/modal/modalContainer.js +2 -0
  132. package/dist/cjs/components/credits/modal/modalContainer.js.map +7 -0
  133. package/dist/cjs/components/credits/modal/rulesModal.js +2 -0
  134. package/dist/cjs/components/credits/modal/rulesModal.js.map +7 -0
  135. package/dist/cjs/components/credits/modal/tip.js +2 -0
  136. package/dist/cjs/components/credits/modal/tip.js.map +7 -0
  137. package/dist/cjs/components/credits/type.js +2 -0
  138. package/dist/cjs/components/credits/type.js.map +7 -0
  139. package/dist/cjs/components/index.js +2 -0
  140. package/dist/cjs/components/index.js.map +7 -0
  141. package/dist/cjs/debug-env.js +2 -0
  142. package/dist/cjs/debug-env.js.map +7 -0
  143. package/dist/cjs/helpers/fetchResponse.js +2 -0
  144. package/dist/cjs/helpers/fetchResponse.js.map +7 -0
  145. package/dist/cjs/helpers/fetcher.js +2 -0
  146. package/dist/cjs/helpers/fetcher.js.map +7 -0
  147. package/dist/cjs/helpers/index.js +2 -0
  148. package/dist/cjs/helpers/index.js.map +7 -0
  149. package/dist/cjs/helpers/track.js +2 -0
  150. package/dist/cjs/helpers/track.js.map +7 -0
  151. package/dist/cjs/helpers/utils.js +2 -0
  152. package/dist/cjs/helpers/utils.js.map +7 -0
  153. package/dist/cjs/index.js +2 -0
  154. package/dist/cjs/index.js.map +7 -0
  155. package/dist/cjs/stories/chat.stories.js +2 -0
  156. package/dist/cjs/stories/chat.stories.js.map +7 -0
  157. package/dist/esm/components/chat/action.js +2 -0
  158. package/dist/esm/components/chat/action.js.map +7 -0
  159. package/dist/esm/components/chat/button.js +2 -0
  160. package/dist/esm/components/chat/button.js.map +7 -0
  161. package/dist/esm/components/chat/chatContext.js +2 -0
  162. package/dist/esm/components/chat/chatContext.js.map +7 -0
  163. package/dist/esm/components/chat/index.js +2 -0
  164. package/dist/esm/components/chat/index.js.map +7 -0
  165. package/dist/esm/components/chat/markdown.js +2 -0
  166. package/dist/esm/components/chat/markdown.js.map +7 -0
  167. package/dist/esm/components/chat/messages.js +2 -0
  168. package/dist/esm/components/chat/messages.js.map +7 -0
  169. package/dist/esm/components/chat/props.js +1 -0
  170. package/dist/esm/components/chat/props.js.map +7 -0
  171. package/dist/esm/components/chat/response.js +2 -0
  172. package/dist/esm/components/chat/response.js.map +7 -0
  173. package/dist/esm/components/chat/suggestions.js +2 -0
  174. package/dist/esm/components/chat/suggestions.js.map +7 -0
  175. package/dist/esm/components/chat/utils.js +2 -0
  176. package/dist/esm/components/chat/utils.js.map +7 -0
  177. package/dist/esm/components/credits/context/const.js +2 -0
  178. package/dist/esm/components/credits/context/const.js.map +7 -0
  179. package/dist/esm/components/credits/context/hooks/useActivities.js +2 -0
  180. package/dist/esm/components/credits/context/hooks/useActivities.js.map +7 -0
  181. package/dist/esm/components/credits/context/hooks/useAddressValidate.js +2 -0
  182. package/dist/esm/components/credits/context/hooks/useAddressValidate.js.map +7 -0
  183. package/dist/esm/components/credits/context/hooks/useAlpcFetch.js +2 -0
  184. package/dist/esm/components/credits/context/hooks/useAlpcFetch.js.map +7 -0
  185. package/dist/esm/components/credits/context/hooks/useClickOutside.js +2 -0
  186. package/dist/esm/components/credits/context/hooks/useClickOutside.js.map +7 -0
  187. package/dist/esm/components/credits/context/hooks/useCopy.js +2 -0
  188. package/dist/esm/components/credits/context/hooks/useCopy.js.map +7 -0
  189. package/dist/esm/components/credits/context/hooks/useCountries.js +2 -0
  190. package/dist/esm/components/credits/context/hooks/useCountries.js.map +7 -0
  191. package/dist/esm/components/credits/context/hooks/useFirstPurchaseFinished.js +2 -0
  192. package/dist/esm/components/credits/context/hooks/useFirstPurchaseFinished.js.map +7 -0
  193. package/dist/esm/components/credits/context/hooks/useMyRewards.js +2 -0
  194. package/dist/esm/components/credits/context/hooks/useMyRewards.js.map +7 -0
  195. package/dist/esm/components/credits/context/hooks/useReceiptUploaded.js +2 -0
  196. package/dist/esm/components/credits/context/hooks/useReceiptUploaded.js.map +7 -0
  197. package/dist/esm/components/credits/context/hooks/useRedeemAndBuy.js +2 -0
  198. package/dist/esm/components/credits/context/hooks/useRedeemAndBuy.js.map +7 -0
  199. package/dist/esm/components/credits/context/hooks/useRedeemCoupon.js +2 -0
  200. package/dist/esm/components/credits/context/hooks/useRedeemCoupon.js.map +7 -0
  201. package/dist/esm/components/credits/context/hooks/useRedeemProduct.js +2 -0
  202. package/dist/esm/components/credits/context/hooks/useRedeemProduct.js.map +7 -0
  203. package/dist/esm/components/credits/context/hooks/useRedeemableList.js +2 -0
  204. package/dist/esm/components/credits/context/hooks/useRedeemableList.js.map +7 -0
  205. package/dist/esm/components/credits/context/hooks/useSendEmailValidation.js +2 -0
  206. package/dist/esm/components/credits/context/hooks/useSendEmailValidation.js.map +7 -0
  207. package/dist/esm/components/credits/context/hooks/useSubscribed.js +2 -0
  208. package/dist/esm/components/credits/context/hooks/useSubscribed.js.map +7 -0
  209. package/dist/esm/components/credits/context/hooks/useSubscriptions.js +2 -0
  210. package/dist/esm/components/credits/context/hooks/useSubscriptions.js.map +7 -0
  211. package/dist/esm/components/credits/context/hooks/useUploadReceipt.js +2 -0
  212. package/dist/esm/components/credits/context/hooks/useUploadReceipt.js.map +7 -0
  213. package/dist/esm/components/credits/context/provider.js +2 -0
  214. package/dist/esm/components/credits/context/provider.js.map +7 -0
  215. package/dist/esm/components/credits/context/response.js +1 -0
  216. package/dist/esm/components/credits/context/response.js.map +7 -0
  217. package/dist/esm/components/credits/context/utils.js +2 -0
  218. package/dist/esm/components/credits/context/utils.js.map +7 -0
  219. package/dist/esm/components/credits/creditsBanner/index.js +2 -0
  220. package/dist/esm/components/credits/creditsBanner/index.js.map +7 -0
  221. package/dist/esm/components/credits/creditsBenefits/benefitItem.js +2 -0
  222. package/dist/esm/components/credits/creditsBenefits/benefitItem.js.map +7 -0
  223. package/dist/esm/components/credits/creditsBenefits/iconInfo.js +2 -0
  224. package/dist/esm/components/credits/creditsBenefits/iconInfo.js.map +7 -0
  225. package/dist/esm/components/credits/creditsBenefits/index.js +4 -0
  226. package/dist/esm/components/credits/creditsBenefits/index.js.map +7 -0
  227. package/dist/esm/components/credits/creditsCash/RedeemableItem.js +2 -0
  228. package/dist/esm/components/credits/creditsCash/RedeemableItem.js.map +7 -0
  229. package/dist/esm/components/credits/creditsCash/index.js +2 -0
  230. package/dist/esm/components/credits/creditsCash/index.js.map +7 -0
  231. package/dist/esm/components/credits/creditsCash/type.js +1 -0
  232. package/dist/esm/components/credits/creditsCash/type.js.map +7 -0
  233. package/dist/esm/components/credits/creditsFaq/faqItem/FaqItem.js +2 -0
  234. package/dist/esm/components/credits/creditsFaq/faqItem/FaqItem.js.map +7 -0
  235. package/dist/esm/components/credits/creditsFaq/index.js +2 -0
  236. package/dist/esm/components/credits/creditsFaq/index.js.map +7 -0
  237. package/dist/esm/components/credits/creditsInfoCard/index.js +2 -0
  238. package/dist/esm/components/credits/creditsInfoCard/index.js.map +7 -0
  239. package/dist/esm/components/credits/creditsRedeemList/AddressForm/CountrySelect.js +2 -0
  240. package/dist/esm/components/credits/creditsRedeemList/AddressForm/CountrySelect.js.map +7 -0
  241. package/dist/esm/components/credits/creditsRedeemList/AddressForm/FormItem.js +2 -0
  242. package/dist/esm/components/credits/creditsRedeemList/AddressForm/FormItem.js.map +7 -0
  243. package/dist/esm/components/credits/creditsRedeemList/AddressForm/Input.js +2 -0
  244. package/dist/esm/components/credits/creditsRedeemList/AddressForm/Input.js.map +7 -0
  245. package/dist/esm/components/credits/creditsRedeemList/AddressForm/StateSelect.js +2 -0
  246. package/dist/esm/components/credits/creditsRedeemList/AddressForm/StateSelect.js.map +7 -0
  247. package/dist/esm/components/credits/creditsRedeemList/AddressForm/index.js +2 -0
  248. package/dist/esm/components/credits/creditsRedeemList/AddressForm/index.js.map +7 -0
  249. package/dist/esm/components/credits/creditsRedeemList/AddressForm/type.js +1 -0
  250. package/dist/esm/components/credits/creditsRedeemList/AddressForm/type.js.map +7 -0
  251. package/dist/esm/components/credits/creditsRedeemList/RedeemCouponModal.js +2 -0
  252. package/dist/esm/components/credits/creditsRedeemList/RedeemCouponModal.js.map +7 -0
  253. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Address.js +2 -0
  254. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Address.js.map +7 -0
  255. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Error.js +2 -0
  256. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Error.js.map +7 -0
  257. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Init.js +2 -0
  258. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Init.js.map +7 -0
  259. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js +2 -0
  260. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js.map +7 -0
  261. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Success.js +2 -0
  262. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Success.js.map +7 -0
  263. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/index.js +2 -0
  264. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/index.js.map +7 -0
  265. package/dist/esm/components/credits/creditsRedeemList/RedeemableItem.js +2 -0
  266. package/dist/esm/components/credits/creditsRedeemList/RedeemableItem.js.map +7 -0
  267. package/dist/esm/components/credits/creditsRedeemList/index.js +2 -0
  268. package/dist/esm/components/credits/creditsRedeemList/index.js.map +7 -0
  269. package/dist/esm/components/credits/creditsRedeemList/type.js +1 -0
  270. package/dist/esm/components/credits/creditsRedeemList/type.js.map +7 -0
  271. package/dist/esm/components/credits/creditsWaysToGetCredits/index.js +2 -0
  272. package/dist/esm/components/credits/creditsWaysToGetCredits/index.js.map +7 -0
  273. package/dist/esm/components/credits/creditsWaysToGetCredits/type.js +2 -0
  274. package/dist/esm/components/credits/creditsWaysToGetCredits/type.js.map +7 -0
  275. package/dist/esm/components/credits/creditsWaysToGetCredits/useActions.js +2 -0
  276. package/dist/esm/components/credits/creditsWaysToGetCredits/useActions.js.map +7 -0
  277. package/dist/esm/components/credits/index.js +2 -0
  278. package/dist/esm/components/credits/index.js.map +7 -0
  279. package/dist/esm/components/credits/modal/MyRewardsModal.js +2 -0
  280. package/dist/esm/components/credits/modal/MyRewardsModal.js.map +7 -0
  281. package/dist/esm/components/credits/modal/activitiesModal.js +2 -0
  282. package/dist/esm/components/credits/modal/activitiesModal.js.map +7 -0
  283. package/dist/esm/components/credits/modal/creditsUploadReceiptModal.js +2 -0
  284. package/dist/esm/components/credits/modal/creditsUploadReceiptModal.js.map +7 -0
  285. package/dist/esm/components/credits/modal/loadingDots.js +2 -0
  286. package/dist/esm/components/credits/modal/loadingDots.js.map +7 -0
  287. package/dist/esm/components/credits/modal/modalContainer.js +2 -0
  288. package/dist/esm/components/credits/modal/modalContainer.js.map +7 -0
  289. package/dist/esm/components/credits/modal/rulesModal.js +2 -0
  290. package/dist/esm/components/credits/modal/rulesModal.js.map +7 -0
  291. package/dist/esm/components/credits/modal/tip.js +2 -0
  292. package/dist/esm/components/credits/modal/tip.js.map +7 -0
  293. package/dist/esm/components/credits/type.js +1 -0
  294. package/dist/esm/components/credits/type.js.map +7 -0
  295. package/dist/esm/components/index.js +2 -0
  296. package/dist/esm/components/index.js.map +7 -0
  297. package/dist/esm/debug-env.js +2 -0
  298. package/dist/esm/debug-env.js.map +7 -0
  299. package/dist/esm/helpers/fetchResponse.js +2 -0
  300. package/dist/esm/helpers/fetchResponse.js.map +7 -0
  301. package/dist/esm/helpers/fetcher.js +2 -0
  302. package/dist/esm/helpers/fetcher.js.map +7 -0
  303. package/dist/esm/helpers/index.js +2 -0
  304. package/dist/esm/helpers/index.js.map +7 -0
  305. package/dist/esm/helpers/track.js +2 -0
  306. package/dist/esm/helpers/track.js.map +7 -0
  307. package/dist/esm/helpers/utils.js +2 -0
  308. package/dist/esm/helpers/utils.js.map +7 -0
  309. package/dist/esm/index.js +2 -0
  310. package/dist/esm/index.js.map +7 -0
  311. package/dist/esm/package.json +3 -0
  312. package/dist/esm/stories/chat.stories.js +2 -0
  313. package/dist/esm/stories/chat.stories.js.map +7 -0
  314. package/package.json +2 -2
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/components/credits/creditsRedeemList/AddressForm/StateSelect.tsx"],
4
+ "sourcesContent": ["import classNames from 'classnames'\nimport { Picture } from '@anker-in/headless-ui'\nimport { useEffect, useMemo, useState } from 'react'\nimport useClickOutside from '../../context/hooks/useClickOutside'\n\ninterface StateSelectProps {\n states: { code: string; id: string; name: string }[]\n className?: string\n countryId?: string\n defaultCode?: string\n stateName?: string\n stateCode?: string\n onChange: (code: string, name: string) => void\n}\n\nexport function StateSelect({ states, stateName = '', stateCode = '', className = '', onChange }: StateSelectProps) {\n const [show, setShow] = useState(false)\n const [display, setDisplay] = useState<any>('')\n\n const dropdown = useClickOutside<HTMLDivElement>(() => {\n setShow(false)\n })\n\n const value = useMemo(() => {\n const currentState = states.find(item => (stateCode ? item.code === stateCode : item.name === stateName))\n\n return currentState ? [currentState?.id, currentState?.name, currentState?.code].join(',') : ''\n }, [states, stateCode, stateName])\n\n useEffect(() => {\n const target = states.filter(item => [item.id, item.name, item.code].join(',') === value)\n if (target.length) setDisplay(target[0].name)\n }, [setDisplay, states, value])\n\n return (\n <div className=\"relative h-full\">\n {states.length ? (\n <>\n <select\n className={classNames('h-[52px] pr-[45px] min-l:hidden', className)}\n value={value}\n style={{\n WebkitTextFillColor: value ? 'black' : '#666',\n }}\n onChange={event => {\n const [, name, code] = event.target.value.split(',')\n onChange(code, name)\n }}\n >\n {states.map((item: { id: string; name: string; code: string }) => (\n <option key={item.id} value={[item.id, item.name, item.code].join(',')}>\n {item.name}\n </option>\n ))}\n </select>\n <div\n className={classNames('absolute left-0 top-0 hidden h-[52px] pr-[45px] min-l:!block', className)}\n onClick={() => {\n setShow(true)\n }}\n role=\"button\"\n tabIndex={0}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n }\n }}\n >\n {display}\n </div>\n\n <Picture\n source=\"https://cdn.shopify.com/s/files/1/0517/6767/3016/files/country-select.png?v=1692202500\"\n className=\"pointer-events-none absolute right-0 top-1/2 h-[45px] !w-[45px] -translate-y-1/2 object-cover\"\n alt=\"arrow\"\n />\n\n <div\n ref={dropdown}\n className={classNames(\n 'absolute left-0 top-[58px] z-30 max-h-[334px] w-full cursor-pointer overflow-auto rounded-[4px] bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.12)]',\n { '!hidden': !show }\n )}\n >\n <ul className=\"py-[6px]\">\n {states.map((item: { id: string; name: string; code: string }) => (\n <li\n key={item.id}\n value={[item.id, item.name, item.code].join(',')}\n className={classNames(\n 'relative px-[14px] py-[17px] text-[16px] font-semibold leading-[1] transition hover:bg-[#F7F8F9]',\n {\n '!bg-[#e8e8e8]': [item.id, item.name, item.code].join(',') === value,\n }\n )}\n >\n <button\n className=\"absolute left-0 top-0 z-1 size-full opacity-0\"\n value={[item.id, item.name, item.code].join(',')}\n onClick={() => {\n setDisplay(item.name)\n setShow(false)\n onChange(item.code, item.name)\n }}\n />\n {item.name}\n </li>\n ))}\n </ul>\n </div>\n </>\n ) : (\n <input\n className={className}\n value={stateName}\n style={{\n WebkitTextFillColor: 'black',\n }}\n onChange={event => {\n onChange('', event.target.value)\n }}\n ></input>\n )}\n </div>\n )\n}\n"],
5
+ "mappings": "AAqCQ,mBAAAA,EAaM,OAAAC,EAoCE,QAAAC,MAjDR,oBArCR,OAAOC,MAAgB,aACvB,OAAS,WAAAC,MAAe,wBACxB,OAAS,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAC7C,OAAOC,MAAqB,sCAYrB,SAASC,EAAY,CAAE,OAAAC,EAAQ,UAAAC,EAAY,GAAI,UAAAC,EAAY,GAAI,UAAAC,EAAY,GAAI,SAAAC,CAAS,EAAqB,CAClH,KAAM,CAACC,EAAMC,CAAO,EAAIT,EAAS,EAAK,EAChC,CAACU,EAASC,CAAU,EAAIX,EAAc,EAAE,EAExCY,EAAWX,EAAgC,IAAM,CACrDQ,EAAQ,EAAK,CACf,CAAC,EAEKI,EAAQd,EAAQ,IAAM,CAC1B,MAAMe,EAAeX,EAAO,KAAKY,GAASV,EAAYU,EAAK,OAASV,EAAYU,EAAK,OAASX,CAAU,EA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O,IAAKY,GACXpB,EAAC,MAEC,MAAO,CAACoB,EAAK,GAAIA,EAAK,KAAMA,EAAK,IAAI,EAAE,KAAK,GAAG,EAC/C,UAAWnB,EACT,mGACA,CACE,gBAAiB,CAACmB,EAAK,GAAIA,EAAK,KAAMA,EAAK,IAAI,EAAE,KAAK,GAAG,IAAMF,CACjE,CACF,EAEA,UAAAnB,EAAC,UACC,UAAU,gDACV,MAAO,CAACqB,EAAK,GAAIA,EAAK,KAAMA,EAAK,IAAI,EAAE,KAAK,GAAG,EAC/C,QAAS,IAAM,CACbJ,EAAWI,EAAK,IAAI,EACpBN,EAAQ,EAAK,EACbF,EAASQ,EAAK,KAAMA,EAAK,IAAI,CAC/B,EACF,EACCA,EAAK,OAlBDA,EAAK,EAmBZ,CACD,EACH,EACF,GACF,EAEArB,EAAC,SACC,UAAWY,EACX,MAAOF,EACP,MAAO,CACL,oBAAqB,OACvB,EACA,SAAUa,GAAS,CACjBV,EAAS,GAAIU,EAAM,OAAO,KAAK,CACjC,EACD,EAEL,CAEJ",
6
+ "names": ["Fragment", "jsx", "jsxs", "classNames", "Picture", "useEffect", "useMemo", "useState", "useClickOutside", "StateSelect", "states", "stateName", "stateCode", "className", "onChange", "show", "setShow", "display", "setDisplay", "dropdown", "value", "currentState", "item", "target", "event", "name", "code"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{jsx as o,jsxs as B}from"react/jsx-runtime";import g from"classnames";import{useCallback as F,useEffect as _,useMemo as x,useState as S}from"react";import{CountrySelect as w}from"./CountrySelect";import{FormItem as I}from"./FormItem";import{Input as q}from"./Input";import{StateSelect as P}from"./StateSelect";import{ALPC_COUNTRY_MAP as K}from"../../context/const";import{useCreditsContext as U}from"../../context/provider";import{useHeadlessContext as z}from"@anker-in/lib";const J=({countries:c,countriesLoading:N,form:n,validate:C,errors:h,onChange:l})=>{const{profile:u,customer:r}=U(),{locale:m}=z(),[e,i]=S(),p=x(()=>c.find(a=>a.code===e?.country)?.provinces||[],[e,c]),b=x(()=>n?.flat().find(a=>a.type==="state")?.key,[n]),A=F(()=>{if(r?.defaultAddress)return{name:(r?.defaultAddress.firstName||"")+" "+(r?.defaultAddress.lastName||""),first_name:r?.defaultAddress.firstName,last_name:r?.defaultAddress.lastName,address1:r?.defaultAddress.address1,address2:r?.defaultAddress.address2,city:r?.defaultAddress.city,phone:r?.defaultAddress.phone,country:r?.defaultAddress.countryCodeV2,province:r?.defaultAddress.province,province_code:r?.defaultAddress.provinceCode,email:r?.email||u?.email,zip:r?.defaultAddress.zip};{let s=K.get(m)||m;return s==="UK"&&(s="GB"),s==="EU"&&(s="NL"),{email:u?.email,country:s}}},[r,u?.email,m]);return console.log("customer",r),_(()=>{if(r){const s=A();i(s),l(s)}},[r,A]),e?o("div",{className:"grid gap-[20px]",children:n&&n.map((s,a)=>o("div",{className:"item-center -mx-[6px] flex",children:s.map((t,k)=>{const f=h.find(d=>d.key===t.key)?.message,y=g("h-full w-full appearance-none rounded-[2px] border bg-white px-[14px] py-[17px] leading-[1] outline-none placeholder:text-[#999] autofill:shadow-white focus:border-brand disabled:pointer-events-none disabled:text-[#999] disabled:bg-[#F7F8F9] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",f?"!border-[#F84D4F]":"border-[#d8d8d8]");return t.type==="state"&&!p.length?null:o("div",{className:g("mx-[6px] flex-1"),children:B(I,{error:f,required:t.required,label:t.label,children:[t.type==="country"&&o(w,{className:y,countries:c,loading:N,value:e.country,onChange:d=>{e.country!==d&&(e.province="",e.province_code=""),e.country=d,i({...e}),l(e)}}),t.type==="state"&&o(P,{className:y,states:p,stateCode:e.province_code,stateName:e.province,onChange:(d,v)=>{e.province_code=d,e.province=v,i({...e}),l(e)}}),t.type!=="state"&&t.type!=="country"&&o(q,{placeholder:t.label,className:y,error:f,value:e[t.key],required:t.required,disabled:t.type==="email",onChange:d=>{const v=d.target.value;e[t.key]=v,i({...e}),l(e)},onBlur:()=>{C({ignoreKeys:p.length&&b?[b]:[]})}})]})},k)})},a))}):null};export{J as AddressForm};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/components/credits/creditsRedeemList/AddressForm/index.tsx"],
4
+ "sourcesContent": ["import classNames from 'classnames'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport { CountrySelect } from './CountrySelect'\nimport { FormItem } from './FormItem'\nimport { Input } from './Input'\nimport { StateSelect } from './StateSelect'\nimport { ALPC_COUNTRY_MAP } from '../../context/const'\nimport { useCreditsContext } from '../../context/provider'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { AddressFormProps } from './type'\n\nexport const AddressForm = ({ countries, countriesLoading, form, validate, errors, onChange }: AddressFormProps) => {\n const { profile, customer } = useCreditsContext()\n const { locale } = useHeadlessContext()\n\n const [address, setAddress] = useState<Record<string, any>>()\n\n const states = useMemo(() => {\n const currentCountry = countries.find(item => item.code === address?.country)\n\n return currentCountry?.provinces || []\n }, [address, countries])\n\n const stateInputKey = useMemo(() => {\n const stateInput = form?.flat().find(item => item.type === 'state')\n return stateInput?.key\n }, [form])\n\n const getDefaultAddress = useCallback(() => {\n if (customer?.defaultAddress) {\n return {\n name: (customer?.defaultAddress.firstName || '') + ' ' + (customer?.defaultAddress.lastName || ''),\n first_name: customer?.defaultAddress.firstName,\n last_name: customer?.defaultAddress.lastName,\n address1: customer?.defaultAddress.address1,\n address2: customer?.defaultAddress.address2,\n city: customer?.defaultAddress.city,\n phone: customer?.defaultAddress.phone,\n country: customer?.defaultAddress.countryCodeV2,\n province: customer?.defaultAddress.province,\n province_code: customer?.defaultAddress.provinceCode,\n email: customer?.email || profile?.email,\n zip: customer?.defaultAddress.zip,\n }\n } else {\n let defaultCountry = ALPC_COUNTRY_MAP.get(locale) || locale\n if (defaultCountry === 'UK') {\n defaultCountry = 'GB'\n }\n if (defaultCountry === 'EU') {\n defaultCountry = 'NL'\n }\n return {\n email: profile?.email,\n country: defaultCountry,\n }\n }\n }, [customer, profile?.email, locale])\n\n console.log('customer', customer)\n useEffect(() => {\n if (customer) {\n const defaultAddress = getDefaultAddress()\n setAddress(defaultAddress)\n onChange(defaultAddress)\n }\n }, [customer, getDefaultAddress])\n\n if (!address) {\n return null\n }\n\n return (\n <div className=\"grid gap-[20px]\">\n {form &&\n form.map((row, rowIndex: number) => (\n <div key={rowIndex} className=\"item-center -mx-[6px] flex\">\n {row.map((input, inputIndex: number) => {\n const error = errors.find(item => item.key === input.key)?.message\n const inputClassName = classNames(\n 'h-full w-full appearance-none rounded-[2px] border bg-white px-[14px] py-[17px] leading-[1] outline-none placeholder:text-[#999] autofill:shadow-white focus:border-brand disabled:pointer-events-none disabled:text-[#999] disabled:bg-[#F7F8F9] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none',\n error ? '!border-[#F84D4F]' : 'border-[#d8d8d8]'\n )\n\n if (input.type === 'state') {\n if (!states.length) {\n return null\n }\n }\n\n return (\n <div key={inputIndex} className={classNames('mx-[6px] flex-1')}>\n <FormItem error={error} required={input.required} label={input.label}>\n {input.type === 'country' && (\n <CountrySelect\n className={inputClassName}\n countries={countries}\n loading={countriesLoading}\n value={address.country}\n onChange={selectedCountryCode => {\n if (address.country !== selectedCountryCode) {\n address.province = ''\n address.province_code = ''\n }\n address.country = selectedCountryCode\n setAddress({ ...address })\n onChange(address)\n }}\n ></CountrySelect>\n )}\n {input.type === 'state' && (\n <StateSelect\n className={inputClassName}\n states={states}\n stateCode={address.province_code}\n stateName={address.province}\n onChange={(provinceCode, provinceName) => {\n address.province_code = provinceCode\n address.province = provinceName\n setAddress({ ...address })\n onChange(address)\n }}\n ></StateSelect>\n )}\n\n {input.type !== 'state' && input.type !== 'country' && (\n <Input\n placeholder={input.label}\n className={inputClassName}\n error={error}\n value={address[input.key]}\n required={input.required}\n disabled={input.type === 'email'}\n onChange={event => {\n const value = event.target.value\n address[input.key] = value\n setAddress({ ...address })\n onChange(address)\n }}\n onBlur={() => {\n validate({\n ignoreKeys: states.length && stateInputKey ? [stateInputKey] : [],\n })\n }}\n />\n )}\n </FormItem>\n </div>\n )\n })}\n </div>\n ))}\n </div>\n )\n}\n"],
5
+ "mappings": "AA6FkB,OAEI,OAAAA,EAFJ,QAAAC,MAAA,oBA7FlB,OAAOC,MAAgB,aACvB,OAAS,eAAAC,EAAa,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAE1D,OAAS,iBAAAC,MAAqB,kBAC9B,OAAS,YAAAC,MAAgB,aACzB,OAAS,SAAAC,MAAa,UACtB,OAAS,eAAAC,MAAmB,gBAC5B,OAAS,oBAAAC,MAAwB,sBACjC,OAAS,qBAAAC,MAAyB,yBAClC,OAAS,sBAAAC,MAA0B,gBAG5B,MAAMC,EAAc,CAAC,CAAE,UAAAC,EAAW,iBAAAC,EAAkB,KAAAC,EAAM,SAAAC,EAAU,OAAAC,EAAQ,SAAAC,CAAS,IAAwB,CAClH,KAAM,CAAE,QAAAC,EAAS,SAAAC,CAAS,EAAIV,EAAkB,EAC1C,CAAE,OAAAW,CAAO,EAAIV,EAAmB,EAEhC,CAACW,EAASC,CAAU,EAAInB,EAA8B,EAEtDoB,EAASrB,EAAQ,IACEU,EAAU,KAAKY,GAAQA,EAAK,OAASH,GAAS,OAAO,GAErD,WAAa,CAAC,EACpC,CAACA,EAAST,CAAS,CAAC,EAEjBa,EAAgBvB,EAAQ,IACTY,GAAM,KAAK,EAAE,KAAKU,GAAQA,EAAK,OAAS,OAAO,GAC/C,IAClB,CAACV,CAAI,CAAC,EAEHY,EAAoB1B,EAAY,IAAM,CAC1C,GAAImB,GAAU,eACZ,MAAO,CACL,MAAOA,GAAU,eAAe,WAAa,IAAM,KAAOA,GAAU,eAAe,UAAY,IAC/F,WAAYA,GAAU,eAAe,UACrC,UAAWA,GAAU,eAAe,SACpC,SAAUA,GAAU,eAAe,SACnC,SAAUA,GAAU,eAAe,SACnC,KAAMA,GAAU,eAAe,KAC/B,MAA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b,EAAW,CAAE,GAAGD,CAAQ,CAAC,EACzBJ,EAASI,CAAO,CAClB,EACD,EAEFU,EAAM,OAAS,SACdlC,EAACU,EAAA,CACC,UAAW2B,EACX,OAAQX,EACR,UAAWF,EAAQ,cACnB,UAAWA,EAAQ,SACnB,SAAU,CAACe,EAAcC,IAAiB,CACxChB,EAAQ,cAAgBe,EACxBf,EAAQ,SAAWgB,EACnBf,EAAW,CAAE,GAAGD,CAAQ,CAAC,EACzBJ,EAASI,CAAO,CAClB,EACD,EAGFU,EAAM,OAAS,SAAWA,EAAM,OAAS,WACxClC,EAACS,EAAA,CACC,YAAayB,EAAM,MACnB,UAAWG,EACX,MAAOD,EACP,MAAOZ,EAAQU,EAAM,GAAG,EACxB,SAAUA,EAAM,SAChB,SAAUA,EAAM,OAAS,QACzB,SAAUO,GAAS,CACjB,MAAMC,EAAQD,EAAM,OAAO,MAC3BjB,EAAQU,EAAM,GAAG,EAAIQ,EACrBjB,EAAW,CAAE,GAAGD,CAAQ,CAAC,EACzBJ,EAASI,CAAO,CAClB,EACA,OAAQ,IAAM,CACZN,EAAS,CACP,WAAYQ,EAAO,QAAUE,EAAgB,CAACA,CAAa,EAAI,CAAC,CAClE,CAAC,CACH,EACF,GAEJ,GAvDQO,CAwDV,CAEJ,CAAC,GAzEOF,CA0EV,CACD,EACL,EAnFO,IAqFX",
6
+ "names": ["jsx", "jsxs", "classNames", "useCallback", "useEffect", "useMemo", "useState", "CountrySelect", "FormItem", "Input", "StateSelect", "ALPC_COUNTRY_MAP", "useCreditsContext", "useHeadlessContext", "AddressForm", "countries", "countriesLoading", "form", "validate", "errors", "onChange", "profile", "customer", "locale", "address", "setAddress", "states", "item", "stateInputKey", "getDefaultAddress", "defaultCountry", "defaultAddress", "row", "rowIndex", "input", "inputIndex", "error", "inputClassName", "selectedCountryCode", "provinceCode", "provinceName", "event", "value"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import{Fragment as E,jsx as t,jsxs as l}from"react/jsx-runtime";import{Button as M,Picture as k,Text as d}from"@anker-in/headless-ui";import p from"classnames";import{useCallback as I,useEffect as L,useState as u}from"react";import S from"../context/hooks/useCopy";import{useCreditsContext as _}from"../context/provider";import{useRedeemCoupon as y}from"../context/hooks/useRedeemCoupon";import{AlpcErrorCode as c}from"../context/const";import{CreditsModalContainer as B}from"../modal/modalContainer";import{numberFormat as z}from"../context/utils";import{useHeadlessContext as P}from"@anker-in/lib";function O({item:i,copy:e,onError:f,...r}){const{locale:w}=P(),[a,F]=u(),[g,s]=u(),[C,n]=u(!1),{copy:R,copied:b}=S(),{profile:x,fetchCreditInfo:v}=_(),{isMutating:N,trigger:h}=y({onSuccess(o){if(!o){s(e.redeemModal.commonError);return}if(o?.data?.success)F(o.data.coupon_code),v(x?.user_id);else{let m;o.code===c.CodeLpcShopifyCouponRuleRedeemLimit?(m=e.redeemModal.redeemLimitError,n(!0)):o.code===c.CodeLpcRuleInventoryNotEnough?(m=e.redeemModal.inventoryNotEnough,n(!0)):o.code===c.CodeLpcNotEnoughCredits?(m=e.redeemModal.creditsNotEnough,n(!0),v(x?.user_id)):o.code===c.CodeCrossSiteError&&(m=e.redeemModal.crossSiteError,n(!0)),s(m||e.redeemModal.commonError||""),f&&f(o.code)}},onError(o){s(o.message||e.redeemModal.commonError)}}),T=I(async()=>{s(""),h({user_id:x?.user_id,rule_id:Number(i.alpc?.id)})},[i,x,h]);return L(()=>{r.isOpen||(n(!1),s(""))},[r.isOpen]),l(B,{...r,className:"w-[540px] md:h-auto",scrollClassName:"mb-[40px] min-l:px-0 md:mb-[24px] px-0",titleClassName:"h-[56px] bg-[#F5F5F7]",children:[l("div",{className:p("max-h-[500px] overflow-y-auto bg-[#F5F5F7] px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]"),children:[l("div",{className:"relative mx-auto h-[164px] w-[324px]",children:[e?.imageMapping?.coupon?.url&&t(k,{source:e?.imageMapping?.coupon?.url,className:"h-full [&_img]:h-full"}),t("div",{className:"absolute bottom-[8px] left-[16px] font-extrabold text-white",children:i.config.value?l("div",{className:"flex items-end gap-[4px]",children:[t(d,{className:"text-[64px] font-bold leading-none",html:i.config.value.toString()}),t(d,{className:"text-[24px] font-bold leading-[2]",html:e?.off})]}):t(d,{size:3,html:i.alpc?.title})})]}),a?l("div",{className:"mt-[30px] flex items-center justify-center md:mt-[18px]",children:[t("div",{className:"mr-[10px] text-[24px] font-bold leading-[1.4] md:leading-[1.2]",children:a}),t("div",{className:p("cursor-pointer text-[16px] font-bold leading-[1.2] underline md:text-[14px]",b?"pointer-events-none":"pointer-events-auto"),onClick:()=>{R(a)},role:"button",tabIndex:0,onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&o.preventDefault()},children:b?e?.copied:e?.copy})]}):l(d,{as:"p",className:p("mt-[30px] text-center text-[24px] font-bold leading-[1.2] md:mt-[18px] md:text-[20px] md:leading-[1.2]"),children:[z(i.alpc?.consumeCredits)," ",e?.pointUnit]}),!a&&i.config?.rules?.length>0&&l("div",{className:"mt-[18px] w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]",children:[l("div",{className:"mb-[4px]",children:[e?.ruleLabel,":"]}),t("ul",{className:"ml-4 grid grid-flow-row gap-[4px]",children:i.config?.rules?.map((o,m)=>t("li",{className:"list-disc",children:t(d,{html:o})},m))})]})]}),l("div",{className:"bg-white px-[48px] pt-[24px] text-center md:px-[16px]",children:[a&&!N?l(E,{children:[l("div",{className:"flex flex-col",children:[t(d,{className:"mb-[4px] text-[24px] font-bold leading-[1.2] md:text-[20px]",html:e.redeemModal.coupon.successTitle}),t(d,{className:"text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:text-[14px]",html:e.redeemModal.coupon.successDesc})]}),t(M,{variant:"primary",size:"lg",className:"mt-[16px] w-full",onClick:()=>{window.location.href=e.redeemModal.coupon.successButtonUrl||`/${w}`,r.onClose&&r.onClose()},disabled:C,children:e.redeemModal.coupon.successButton})]}):l(E,{children:[t(d,{className:"block text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]",html:e.redeemModal.confirmTitle}),t(M,{loading:N,variant:"primary",size:"lg",className:"mt-[16px] w-full",onClick:T,disabled:C,children:e.redeemModal.confirmButton})]}),g&&t("div",{className:"mx-auto max-w-full py-[12px] text-center",children:t(d,{className:"text-[14px] font-semibold text-[#1F2021]",html:g})})]})]})}var W=O;export{W as default};
2
+ //# sourceMappingURL=RedeemCouponModal.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/components/credits/creditsRedeemList/RedeemCouponModal.tsx"],
4
+ "sourcesContent": ["import { Button, Picture, Text } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { useCallback, useEffect, useState } from 'react'\nimport type { ModalContainerProps } from '../modal/modalContainer'\nimport useCopy from '../context/hooks/useCopy'\nimport { useCreditsContext } from '../context/provider'\nimport { useRedeemCoupon } from '../context/hooks/useRedeemCoupon'\nimport { AlpcErrorCode } from '../context/const'\nimport { CreditsModalContainer } from '../modal/modalContainer'\nimport { numberFormat } from '../context/utils'\nimport type { RedeemableItem as RedeemableItemType } from '../type'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { CreditsRedeemListCopy } from './type'\n\nfunction RedeemCouponModal({\n item,\n copy,\n onError,\n ...props\n}: ModalContainerProps & {\n item: RedeemableItemType\n copy: CreditsRedeemListCopy\n onError: (code: number) => void\n}) {\n const { locale } = useHeadlessContext()\n const [couponCode, setCouponCode] = useState<string>()\n const [errorInfo, setErrorInfo] = useState<string>()\n\n const [disabled, setDisabled] = useState(false)\n const { copy: copyText, copied: copiedStatus } = useCopy()\n\n const { profile, fetchCreditInfo } = useCreditsContext()\n\n const { isMutating: loading, trigger } = useRedeemCoupon({\n onSuccess(responseData) {\n if (!responseData) {\n setErrorInfo(copy.redeemModal.commonError)\n return\n }\n\n if (responseData?.data?.success) {\n setCouponCode(responseData.data.coupon_code)\n fetchCreditInfo(profile?.user_id)\n } else {\n let errorMsg\n if (responseData.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n errorMsg = copy.redeemModal.redeemLimitError\n setDisabled(true)\n } else if (responseData.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n errorMsg = copy.redeemModal.inventoryNotEnough\n setDisabled(true)\n } else if (responseData.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n errorMsg = copy.redeemModal.creditsNotEnough\n setDisabled(true)\n fetchCreditInfo(profile?.user_id)\n } else if (responseData.code === AlpcErrorCode.CodeCrossSiteError) {\n errorMsg = copy.redeemModal.crossSiteError\n setDisabled(true)\n }\n\n setErrorInfo(errorMsg || copy.redeemModal.commonError || '')\n onError && onError(responseData.code)\n }\n },\n onError(error) {\n setErrorInfo(error.message || copy.redeemModal.commonError)\n },\n })\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n trigger({\n user_id: profile?.user_id,\n rule_id: Number(item.alpc?.id),\n })\n }, [item, profile, trigger])\n\n useEffect(() => {\n if (!props.isOpen) {\n setDisabled(false)\n setErrorInfo('')\n }\n }, [props.isOpen])\n\n return (\n <CreditsModalContainer\n {...props}\n className=\"w-[540px] md:h-auto\"\n scrollClassName=\"mb-[40px] min-l:px-0 md:mb-[24px] px-0\"\n titleClassName=\"h-[56px] bg-[#F5F5F7]\"\n >\n <div\n className={classNames(\n 'max-h-[500px] overflow-y-auto bg-[#F5F5F7] px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]'\n )}\n >\n <div className=\"relative mx-auto h-[164px] w-[324px]\">\n {copy?.imageMapping?.coupon?.url && (\n <Picture source={copy?.imageMapping?.coupon?.url} className=\"h-full [&_img]:h-full\" />\n )}\n <div className=\"absolute bottom-[8px] left-[16px] font-extrabold text-white\">\n {item.config.value ? (\n <div className=\"flex items-end gap-[4px]\">\n <Text className=\"text-[64px] font-bold leading-none\" html={item.config.value.toString()} />\n <Text className=\"text-[24px] font-bold leading-[2]\" html={copy?.off} />\n </div>\n ) : (\n <Text size={3} html={item.alpc?.title} />\n )}\n </div>\n </div>\n {couponCode ? (\n <div className=\"mt-[30px] flex items-center justify-center md:mt-[18px]\">\n <div className=\"mr-[10px] text-[24px] font-bold leading-[1.4] md:leading-[1.2]\">{couponCode}</div>\n <div\n className={classNames(\n 'cursor-pointer text-[16px] font-bold leading-[1.2] underline md:text-[14px]',\n copiedStatus ? 'pointer-events-none' : 'pointer-events-auto'\n )}\n onClick={() => {\n copyText(couponCode)\n }}\n role=\"button\"\n tabIndex={0}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n }\n }}\n >\n {copiedStatus ? copy?.copied : copy?.copy}\n </div>\n </div>\n ) : (\n <Text\n as=\"p\"\n className={classNames(\n 'mt-[30px] text-center text-[24px] font-bold leading-[1.2] md:mt-[18px] md:text-[20px] md:leading-[1.2]'\n )}\n >\n {numberFormat(item.alpc?.consumeCredits)} {copy?.pointUnit}\n </Text>\n )}\n {!couponCode && item.config?.rules?.length > 0 && (\n <div className=\"mt-[18px] w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]\">\n <div className=\"mb-[4px]\">{copy?.ruleLabel}:</div>\n <ul className=\"ml-4 grid grid-flow-row gap-[4px]\">\n {item.config?.rules?.map((text, index) => (\n <li className=\"list-disc\" key={index}>\n <Text html={text} />\n </li>\n ))}\n </ul>\n </div>\n )}\n </div>\n <div className=\"bg-white px-[48px] pt-[24px] text-center md:px-[16px]\">\n {couponCode && !loading ? (\n <>\n <div className=\"flex flex-col\">\n <Text\n className=\"mb-[4px] text-[24px] font-bold leading-[1.2] md:text-[20px]\"\n html={copy.redeemModal.coupon.successTitle}\n ></Text>\n <Text\n className=\"text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:text-[14px]\"\n html={copy.redeemModal.coupon.successDesc}\n ></Text>\n </div>\n <Button\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[16px] w-full\"\n onClick={() => {\n window.location.href = copy.redeemModal.coupon.successButtonUrl || `/${locale}`\n if (props.onClose) {\n props.onClose()\n }\n }}\n disabled={disabled}\n >\n {copy.redeemModal.coupon.successButton}\n </Button>\n </>\n ) : (\n <>\n <Text\n className=\"block text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]\"\n html={copy.redeemModal.confirmTitle}\n ></Text>\n <Button\n loading={loading}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[16px] w-full\"\n onClick={handleConfirm}\n disabled={disabled}\n >\n {copy.redeemModal.confirmButton}\n </Button>\n </>\n )}\n {errorInfo && (\n <div className=\"mx-auto max-w-full py-[12px] text-center\">\n <Text className=\"text-[14px] font-semibold text-[#1F2021]\" html={errorInfo} />\n </div>\n )}\n </div>\n </CreditsModalContainer>\n )\n}\n\nexport default RedeemCouponModal\n"],
5
+ "mappings": "AAkGY,OA4DF,YAAAA,EA5DE,OAAAC,EAIE,QAAAC,MAJF,oBAlGZ,OAAS,UAAAC,EAAQ,WAAAC,EAAS,QAAAC,MAAY,wBACtC,OAAOC,MAAgB,aACvB,OAAS,eAAAC,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QAEjD,OAAOC,MAAa,2BACpB,OAAS,qBAAAC,MAAyB,sBAClC,OAAS,mBAAAC,MAAuB,mCAChC,OAAS,iBAAAC,MAAqB,mBAC9B,OAAS,yBAAAC,MAA6B,0BACtC,OAAS,gBAAAC,MAAoB,mBAE7B,OAAS,sBAAAC,MAA0B,gBAGnC,SAASC,EAAkB,CACzB,KAAAC,EACA,KAAAC,EACA,QAAAC,EACA,GAAGC,CACL,EAIG,CACD,KAAM,CAAE,OAAAC,CAAO,EAAIN,EAAmB,EAChC,CAACO,EAAYC,CAAa,EAAIf,EAAiB,EAC/C,CAACgB,EAA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O,IAAI,CAACsB,EAAMC,IAC9BxC,EAAC,MAAG,UAAU,YACZ,SAAAA,EAACI,EAAA,CAAK,KAAMmC,EAAM,GADWC,CAE/B,CACD,EACH,GACF,GAEJ,EACAvC,EAAC,OAAI,UAAU,wDACZ,UAAAqB,GAAc,CAACU,EACd/B,EAAAF,EAAA,CACE,UAAAE,EAAC,OAAI,UAAU,gBACb,UAAAD,EAACI,EAAA,CACC,UAAU,8DACV,KAAMc,EAAK,YAAY,OAAO,aAC/B,EACDlB,EAACI,EAAA,CACC,UAAU,oEACV,KAAMc,EAAK,YAAY,OAAO,YAC/B,GACH,EACAlB,EAACE,EAAA,CACC,QAAQ,UACR,KAAK,KACL,UAAU,mBACV,QAAS,IAAM,CACb,OAAO,SAAS,KAAOgB,EAAK,YAAY,OAAO,kBAAoB,IAAIG,CAAM,GACzED,EAAM,SACRA,EAAM,QAAQ,CAElB,EACA,SAAUM,EAET,SAAAR,EAAK,YAAY,OAAO,cAC3B,GACF,EAEAjB,EAAAF,EAAA,CACE,UAAAC,EAACI,EAAA,CACC,UAAU,4EACV,KAAMc,EAAK,YAAY,aACxB,EACDlB,EAACE,EAAA,CACC,QAAS8B,EACT,QAAQ,UACR,KAAK,KACL,UAAU,mBACV,QAASK,EACT,SAAUX,EAET,SAAAR,EAAK,YAAY,cACpB,GACF,EAEDM,GACCxB,EAAC,OAAI,UAAU,2CACb,SAAAA,EAACI,EAAA,CAAK,UAAU,2CAA2C,KAAMoB,EAAW,EAC9E,GAEJ,GACF,CAEJ,CAEA,IAAOiB,EAAQzB",
6
+ "names": ["Fragment", "jsx", "jsxs", "Button", "Picture", "Text", "classNames", "useCallback", "useEffect", "useState", "useCopy", "useCreditsContext", "useRedeemCoupon", "AlpcErrorCode", "CreditsModalContainer", "numberFormat", "useHeadlessContext", "RedeemCouponModal", "item", "copy", "onError", "props", "locale", "couponCode", "setCouponCode", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "copyText", "copiedStatus", "profile", "fetchCreditInfo", "loading", "trigger", "responseData", "errorMsg", "error", "handleConfirm", "e", "text", "index", "RedeemCouponModal_default"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{Button as v,Text as r}from"@anker-in/headless-ui";import b from"classnames";import{AddressForm as g}from"../AddressForm";import{useHeadlessContext as h}from"@anker-in/lib";import{ProductInfo as C}from"./ProductInfo";import N from"../../context/hooks/useCountries";const k=({copy:o,shippingAddress:s,setAddress:i,validateAddress:m,validateErrors:a,shippingProduct:d,loading:n,address:p,disabled:l,handlePayment:x,item:c})=>{const{storeDomain:f}=h(),{countries:u=[],isLoading:y}=N({shopifyStoreDomain:f});return t("div",{className:"relative",children:[e("div",{className:b("max-h-[500px] overflow-y-auto px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]"),children:t("div",{children:[s&&e(r,{className:"mb-5 text-[16px] font-bold",html:s}),e(g,{onChange:i,validate:m,errors:a,form:o.redeemModal.product.addressForm,countries:u,countriesLoading:y})]})}),t("div",{className:"sticky bottom-0 flex flex-col items-center justify-center bg-white px-[48px] py-[24px] l:px-[16px]",children:[t("div",{className:"flex w-full items-center rounded-[16px] bg-[#F5F5F7] p-[16px]",children:[d&&e(r,{className:"mb-5 text-[16px] font-bold",html:d}),e(C,{item:c,copy:o})]}),e(v,{loading:n||!p,variant:"primary",className:"mx-auto mt-[16px] w-[444px] md:mt-[12px] md:w-full",onClick:x,disabled:l,children:o.redeemModal.product.paymentButton})]})]})};export{k as Address};
2
+ //# sourceMappingURL=Address.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/components/credits/creditsRedeemList/RedeemProductModal/Address.tsx"],
4
+ "sourcesContent": ["import { Button, Text } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { AddressForm } from '../AddressForm'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport type { RedeemableItem as RedeemableItemType } from '../../type'\nimport { CreditsRedeemListCopy } from '../type'\nimport { ProductInfo } from './ProductInfo'\nimport useCountries from '../../context/hooks/useCountries'\n\ntype AddressProps = {\n copy: CreditsRedeemListCopy\n shippingAddress: string\n setAddress: (address: Record<string, any>) => void\n validateAddress: (address: Record<string, any>) => boolean\n validateErrors: { key: string; message: string }[]\n item: RedeemableItemType\n loading: boolean\n address: Record<string, any> | undefined\n disabled: boolean\n handlePayment: () => void\n shippingProduct: string\n}\n\nexport const Address = ({\n copy,\n shippingAddress,\n setAddress,\n validateAddress,\n validateErrors,\n shippingProduct,\n loading,\n address,\n disabled,\n handlePayment,\n item,\n}: AddressProps) => {\n const { storeDomain } = useHeadlessContext()\n const { countries = [], isLoading: countriesLoading } = useCountries({ shopifyStoreDomain: storeDomain })\n\n return (\n <div className=\"relative\">\n <div className={classNames('max-h-[500px] overflow-y-auto px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]')}>\n <div>\n {shippingAddress && <Text className=\"mb-5 text-[16px] font-bold\" html={shippingAddress}></Text>}\n <AddressForm\n onChange={setAddress}\n validate={validateAddress}\n errors={validateErrors}\n form={copy.redeemModal.product.addressForm}\n countries={countries}\n countriesLoading={countriesLoading}\n ></AddressForm>\n </div>\n </div>\n <div className=\"sticky bottom-0 flex flex-col items-center justify-center bg-white px-[48px] py-[24px] l:px-[16px]\">\n <div className=\"flex w-full items-center rounded-[16px] bg-[#F5F5F7] p-[16px]\">\n {shippingProduct && <Text className=\"mb-5 text-[16px] font-bold\" html={shippingProduct}></Text>}\n <ProductInfo item={item} copy={copy} />\n </div>\n <Button\n loading={loading || !address}\n variant=\"primary\"\n className=\"mx-auto mt-[16px] w-[444px] md:mt-[12px] md:w-full\"\n onClick={handlePayment}\n disabled={disabled}\n >\n {copy.redeemModal.product.paymentButton}\n </Button>\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": "AA0CQ,OACsB,OAAAA,EADtB,QAAAC,MAAA,oBA1CR,OAAS,UAAAC,EAAQ,QAAAC,MAAY,wBAC7B,OAAOC,MAAgB,aACvB,OAAS,eAAAC,MAAmB,iBAC5B,OAAS,sBAAAC,MAA0B,gBAGnC,OAAS,eAAAC,MAAmB,gBAC5B,OAAOC,MAAkB,mCAgBlB,MAAMC,EAAU,CAAC,CACtB,KAAAC,EACA,gBAAAC,EACA,WAAAC,EACA,gBAAAC,EACA,eAAAC,EACA,gBAAAC,EACA,QAAAC,EACA,QAAAC,EACA,SAAAC,EACA,cAAAC,EACA,KAAAC,CACF,IAAoB,CAClB,KAAM,CAAE,YAAAC,CAAY,EAAIf,EAAmB,EACrC,CAAE,UAAAgB,EAAY,CAAC,EAAG,UAAWC,CAAiB,EAAIf,EAAa,CAAE,mBAAoBa,CAAY,CAAC,EAExG,OACEpB,EAAC,OAAI,UAAU,WACb,UAAAD,EAAC,OAAI,UAAWI,EAAW,iFAAiF,EAC1G,SAAAH,EAAC,OACE,UAAAU,GAAmBX,EAACG,EAAA,CAAK,UAAU,6BAA6B,KAAMQ,EAAiB,EACxFX,EAACK,EAAA,CACC,SAAUO,EACV,SAAUC,EACV,OAAQC,EACR,KAAMJ,EAAK,YAAY,QAAQ,YAC/B,UAAWY,EACX,iBAAkBC,EACnB,GACH,EACF,EACAtB,EAAC,OAAI,UAAU,qGACb,UAAAA,EAAC,OAAI,UAAU,gEACZ,UAAAc,GAAmBf,EAACG,EAAA,CAAK,UAAU,6BAA6B,KAAMY,EAAiB,EACxFf,EAACO,EAAA,CAAY,KAAMa,EAAM,KAAMV,EAAM,GACvC,EACAV,EAACE,EAAA,CACC,QAASc,GAAW,CAACC,EACrB,QAAQ,UACR,UAAU,qDACV,QAASE,EACT,SAAUD,EAET,SAAAR,EAAK,YAAY,QAAQ,cAC5B,GACF,GACF,CAEJ",
6
+ "names": ["jsx", "jsxs", "Button", "Text", "classNames", "AddressForm", "useHeadlessContext", "ProductInfo", "useCountries", "Address", "copy", "shippingAddress", "setAddress", "validateAddress", "validateErrors", "shippingProduct", "loading", "address", "disabled", "handlePayment", "item", "storeDomain", "countries", "countriesLoading"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{jsx as e,jsxs as a}from"react/jsx-runtime";import{Picture as t,Text as s}from"@anker-in/headless-ui";const x=({errorInfo:r})=>a("div",{className:"mx-auto max-w-[404px] text-[16px] text-black/40",children:[e(t,{className:"mx-auto mb-[12px] h-[140px] w-[220px]",source:r.imageUrl}),e(s,{as:"div",className:"mt-[16px] text-center",html:r.message})]});export{x as Error};
2
+ //# sourceMappingURL=Error.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/components/credits/creditsRedeemList/RedeemProductModal/Error.tsx"],
4
+ "sourcesContent": ["import { Picture, Text } from '@anker-in/headless-ui'\n\ntype ErrorProps = {\n errorInfo: { imageUrl: string; message: string }\n}\n\nexport const Error = ({ errorInfo }: ErrorProps) => {\n return (\n <div className=\"mx-auto max-w-[404px] text-[16px] text-black/40\">\n <Picture className=\"mx-auto mb-[12px] h-[140px] w-[220px]\" source={errorInfo.imageUrl} />\n <Text as=\"div\" className=\"mt-[16px] text-center\" html={errorInfo.message} />\n </div>\n )\n}\n"],
5
+ "mappings": "AAQI,OACE,OAAAA,EADF,QAAAC,MAAA,oBARJ,OAAS,WAAAC,EAAS,QAAAC,MAAY,wBAMvB,MAAMC,EAAQ,CAAC,CAAE,UAAAC,CAAU,IAE9BJ,EAAC,OAAI,UAAU,kDACb,UAAAD,EAACE,EAAA,CAAQ,UAAU,wCAAwC,OAAQG,EAAU,SAAU,EACvFL,EAACG,EAAA,CAAK,GAAG,MAAM,UAAU,wBAAwB,KAAME,EAAU,QAAS,GAC5E",
6
+ "names": ["jsx", "jsxs", "Picture", "Text", "Error", "errorInfo"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{Fragment as b,jsx as e,jsxs as s}from"react/jsx-runtime";import{Button as f,Picture as i,Text as a}from"@anker-in/headless-ui";import m from"classnames";import{Fragment as u,useMemo as g}from"react";import{numberFormat as v}from"../../context/utils";import{ConsumeType as r}from"../../context/const";const F=({copy:l,item:t,loading:x,disabled:n,setStatus:c})=>{const p=g(()=>t.config.rules?.length?t.config.rules:[...t.config.desc?.split("<br>")||[],...l.redeemModal.product.rules||[]],[t.config.rules,t.config.desc,l.redeemModal.product.rules]);return console.log("item",t),s("div",{className:"flex flex-col",children:[e("div",{className:m("max-h-[500px] overflow-y-auto bg-[#F5F5F7] px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]"),children:s(b,{children:[s("div",{className:"relative mx-auto h-[164px] w-fit",children:[e(i,{source:t.config?.type===r.Product?t.product.images[0]?.url:l?.imageMapping[t.config.type]?.url||t.config.image?.url,className:"h-full w-auto [&_img]:h-full [&_img]:w-auto [&_img]:object-contain"}),e("div",{className:"absolute bottom-[8px] left-[16px] font-extrabold text-white",children:t.config.value&&s("div",{className:"flex items-end gap-[4px]",children:[e(a,{className:"text-[64px] font-bold leading-none",html:t.config.value.toString()}),e(a,{className:"text-[24px] font-bold leading-[2]",html:t.config.type===r.Coupon?l?.off:l?.giftCardLabel})]})})]}),s("div",{className:"mt-[30px] md:mt-[18px]",children:[t.config.type==="product"&&e("div",{className:m("mb-[4px] text-center text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]"),children:t.config.title}),s(a,{as:"p",className:m(" text-center text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]"),children:[v(t.alpc?.consumeCredits)," ",l?.pointUnit]})]}),s("div",{className:"mt-[16px] w-full text-[14px] font-semibold text-[#777] md:mt-[12px]",children:[e("div",{className:"text-[16px] font-bold leading-[1.4]",children:l.redeemModal.product.stepTitle}),e("div",{className:"mt-[4px] flex items-center justify-center",children:l.redeemModal.product.steps?.map((d,o)=>s(u,{children:[s("div",{className:"flex w-[76px] flex-col items-center text-center md:h-[94px] min-l:w-[130px]",children:[e(i,{source:d.imageUrl,className:"mb-[4px] h-[58px] w-[58px]"}),e("div",{className:"min-h-[34px] text-[14px] font-bold text-[#777] md:min-h-[28px] md:text-[12px]",children:d.title})]}),o!==l.redeemModal.product.steps.length-1&&e(i,{source:"https://cdn.shopify.com/s/files/1/0517/6767/3016/files/step-arrow.png?v=1690458150",className:"mb-[20px] h-[10px] w-[20px] md:mb-[30px] md:h-[5px] md:w-[12px]"})]},o))}),e("div",{className:"overflow-auto",children:p?.length&&e("ul",{className:"ml-[18px] mt-[16px] grid grid-flow-row gap-[4px] text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px]",children:p.map((d,o)=>e("li",{className:"list-disc",children:e(a,{as:"div",html:d,className:"font-bold"})},o))})})]})]})}),s("div",{className:"flex-1 bg-white px-[48px] py-[24px] text-center md:px-[16px]",children:[e(a,{as:"p",className:"block text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]",html:l.redeemModal.confirmTitle}),e(f,{loading:x,disabled:n,variant:"primary",size:"lg",className:"mt-[16px] w-full md:mt-[12px]",onClick:()=>{c("address")},children:l.redeemModal.confirmButton})]})]})};export{F as Init};
2
+ //# sourceMappingURL=Init.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/components/credits/creditsRedeemList/RedeemProductModal/Init.tsx"],
4
+ "sourcesContent": ["import { Button, Picture, Text } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { Fragment, useMemo } from 'react'\nimport { numberFormat } from '../../context/utils'\nimport type { RedeemableItem as RedeemableItemType } from '../../type'\nimport { CreditsRedeemListCopy } from '../type'\nimport { ConsumeType } from '../../context/const'\n\ntype InitProps = {\n copy: CreditsRedeemListCopy\n item: RedeemableItemType\n loading: boolean\n disabled: boolean\n setStatus: (status: 'address' | 'init' | 'success' | 'error') => void\n}\n\nexport const Init = ({ copy, item, loading, disabled, setStatus }: InitProps) => {\n const rules = useMemo(() => {\n if (item.config.rules?.length) {\n return item.config.rules\n }\n const descriptions = item.config.desc?.split('<br>') || []\n return [...descriptions, ...(copy.redeemModal.product.rules || [])]\n }, [item.config.rules, item.config.desc, copy.redeemModal.product.rules])\n\n console.log('item', item)\n return (\n <div className=\"flex flex-col\">\n <div\n className={classNames(\n 'max-h-[500px] overflow-y-auto bg-[#F5F5F7] px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]'\n )}\n >\n <>\n <div className=\"relative mx-auto h-[164px] w-fit\">\n <Picture\n source={\n item.config?.type === ConsumeType.Product\n ? item.product.images[0]?.url\n : copy?.imageMapping[item.config.type]?.url || item.config.image?.url\n }\n className=\"h-full w-auto [&_img]:h-full [&_img]:w-auto [&_img]:object-contain\"\n ></Picture>\n {/* \u793C\u54C1\u5361\u5C55\u793A */}\n <div className=\"absolute bottom-[8px] left-[16px] font-extrabold text-white\">\n {item.config.value && (\n <div className=\"flex items-end gap-[4px]\">\n <Text className=\"text-[64px] font-bold leading-none\" html={item.config.value.toString()} />\n <Text\n className=\"text-[24px] font-bold leading-[2]\"\n html={item.config.type === ConsumeType.Coupon ? copy?.off : copy?.giftCardLabel}\n />\n </div>\n )}\n </div>\n </div>\n <div className=\"mt-[30px] md:mt-[18px]\">\n {item.config.type === 'product' && (\n <div\n className={classNames(\n 'mb-[4px] text-center text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]'\n )}\n >\n {item.config.title}\n </div>\n )}\n <Text\n as=\"p\"\n className={classNames(' text-center text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]')}\n >\n {numberFormat(item.alpc?.consumeCredits)} {copy?.pointUnit}\n </Text>\n </div>\n <div className=\"mt-[16px] w-full text-[14px] font-semibold text-[#777] md:mt-[12px]\">\n <div className=\"text-[16px] font-bold leading-[1.4]\">{copy.redeemModal.product.stepTitle}</div>\n <div className=\"mt-[4px] flex items-center justify-center\">\n {copy.redeemModal.product.steps?.map((item, index) => (\n <Fragment key={index}>\n <div className=\"flex w-[76px] flex-col items-center text-center md:h-[94px] min-l:w-[130px]\">\n <Picture source={item.imageUrl} className=\"mb-[4px] h-[58px] w-[58px]\"></Picture>\n <div className=\"min-h-[34px] text-[14px] font-bold text-[#777] md:min-h-[28px] md:text-[12px]\">\n {item.title}\n </div>\n </div>\n {index !== copy.redeemModal.product.steps.length - 1 && (\n <Picture\n source=\"https://cdn.shopify.com/s/files/1/0517/6767/3016/files/step-arrow.png?v=1690458150\"\n className=\"mb-[20px] h-[10px] w-[20px] md:mb-[30px] md:h-[5px] md:w-[12px]\"\n ></Picture>\n )}\n </Fragment>\n ))}\n </div>\n <div className=\"overflow-auto\">\n {rules?.length && (\n <ul className=\"ml-[18px] mt-[16px] grid grid-flow-row gap-[4px] text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px]\">\n {rules.map((text, index) => (\n <li className=\"list-disc\" key={index}>\n <Text as=\"div\" html={text} className=\"font-bold\" />\n </li>\n ))}\n </ul>\n )}\n </div>\n </div>\n </>\n </div>\n <div className=\"flex-1 bg-white px-[48px] py-[24px] text-center md:px-[16px]\">\n <Text\n as=\"p\"\n className=\"block text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]\"\n html={copy.redeemModal.confirmTitle}\n ></Text>\n <Button\n loading={loading}\n disabled={disabled}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[16px] w-full md:mt-[12px]\"\n onClick={() => {\n setStatus('address')\n }}\n >\n {copy.redeemModal.confirmButton}\n </Button>\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": "AAiCQ,mBAAAA,EAEI,OAAAC,EAWI,QAAAC,MAbR,oBAjCR,OAAS,UAAAC,EAAQ,WAAAC,EAAS,QAAAC,MAAY,wBACtC,OAAOC,MAAgB,aACvB,OAAS,YAAAN,EAAU,WAAAO,MAAe,QAClC,OAAS,gBAAAC,MAAoB,sBAG7B,OAAS,eAAAC,MAAmB,sBAUrB,MAAMC,EAAO,CAAC,CAAE,KAAAC,EAAM,KAAAC,EAAM,QAAAC,EAAS,SAAAC,EAAU,UAAAC,CAAU,IAAiB,CAC/E,MAAMC,EAAQT,EAAQ,IAChBK,EAAK,OAAO,OAAO,OACdA,EAAK,OAAO,MA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C,EAAMK,IAC1Cf,EAACF,EAAA,CACC,UAAAE,EAAC,OAAI,UAAU,8EACb,UAAAD,EAACG,EAAA,CAAQ,OAAQQ,EAAK,SAAU,UAAU,6BAA6B,EACvEX,EAAC,OAAI,UAAU,gFACZ,SAAAW,EAAK,MACR,GACF,EACCK,IAAUN,EAAK,YAAY,QAAQ,MAAM,OAAS,GACjDV,EAACG,EAAA,CACC,OAAO,qFACP,UAAU,kEACX,IAXUa,CAaf,CACD,EACH,EACAhB,EAAC,OAAI,UAAU,gBACZ,SAAAe,GAAO,QACNf,EAAC,MAAG,UAAU,mHACX,SAAAe,EAAM,IAAI,CAACE,EAAMD,IAChBhB,EAAC,MAAG,UAAU,YACZ,SAAAA,EAACI,EAAA,CAAK,GAAG,MAAM,KAAMa,EAAM,UAAU,YAAY,GADpBD,CAE/B,CACD,EACH,EAEJ,GACF,GACF,EACF,EACAf,EAAC,OAAI,UAAU,+DACb,UAAAD,EAACI,EAAA,CACC,GAAG,IACH,UAAU,4EACV,KAAMM,EAAK,YAAY,aACxB,EACDV,EAACE,EAAA,CACC,QAASU,EACT,SAAUC,EACV,QAAQ,UACR,KAAK,KACL,UAAU,gCACV,QAAS,IAAM,CACbC,EAAU,SAAS,CACrB,EAEC,SAAAJ,EAAK,YAAY,cACpB,GACF,GACF,CAEJ",
6
+ "names": ["Fragment", "jsx", "jsxs", "Button", "Picture", "Text", "classNames", "useMemo", "numberFormat", "ConsumeType", "Init", "copy", "item", "loading", "disabled", "setStatus", "rules", "index", "text"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{jsx as a,jsxs as e}from"react/jsx-runtime";import{Picture as m}from"@anker-in/headless-ui";import{formatPrice as l}from"../../context/utils";import{useHeadlessContext as i}from"@anker-in/lib";const x=({item:t,copy:d})=>{const{locale:s}=i();return e("div",{className:"flex w-full items-center justify-center md:items-start md:justify-start",children:[a(m,{className:"mr-[16px] size-[100px] shrink-0 md:mr-[12px] md:hidden md:size-[44px] [&_img]:h-full [&_img]:w-auto [&_img]:object-contain",source:t.variant.image?.url||t.product?.images[0]?.url,alt:t.product.title}),e("div",{className:"md:flex md:flex-col",children:[e("div",{className:"md:flex md:items-center",children:[a(m,{className:"mr-[16px] size-[100px] shrink-0 md:mr-[12px] md:size-[44px] min-md:hidden [&_img]:h-full [&_img]:w-auto [&_img]:object-contain",source:t.variant.image?.url||t.product?.images[0]?.url,alt:t.product.title}),a("div",{className:"flex-1 text-[16px] font-bold leading-[1.4] min-l:!hidden",title:t.product.title,children:t.product.title})]}),e("div",{className:"mt-[16px] md:mt-[12px]",children:[a("div",{className:"mb-[12px] line-clamp-1 text-[16px] font-bold l:!hidden",title:t.product.title,children:t.product.title}),e("div",{className:"flex font-semibold leading-[1.4] md:flex-col",children:[e("div",{className:"mr-[40px] text-[15px] font-bold text-[#777] md:mr-0 md:text-[12px]",children:[e("div",{className:"mb-[8px] flex items-center md:mb-[4px]",children:[e("span",{children:[d.redeemModal.product.variantLabel,": "]}),a("span",{className:"ml-1",children:t.variant.title||""})]}),e("div",{className:"mb-[8px] flex items-center md:mb-[4px]",children:[e("span",{children:[d.redeemModal.product.shippingFeeLabel,": "]}),a("span",{className:"ml-1",children:l({amount:0,currencyCode:t.product.price?.currencyCode,locale:s||"us"})})]})]}),e("div",{className:"text-[15px] font-bold text-[#777] md:text-[12px]",children:[e("div",{className:"mb-[8px] flex items-center md:mb-[4px]",children:[e("span",{children:[d.redeemModal.product.quantityLabel,": "]}),a("span",{className:"ml-1",children:"1"})]}),e("div",{className:"l:flex l:items-center l:justify-between",children:[e("span",{children:[d.redeemModal.product.totalPriceLabel,": "]}),e("span",{className:"ml-1",children:[t.alpc?.consumeCredits," ",d?.pointUnit]})]})]})]})]})]})]})};export{x as ProductInfo};
2
+ //# sourceMappingURL=ProductInfo.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.tsx"],
4
+ "sourcesContent": ["import { Picture } from '@anker-in/headless-ui'\nimport { formatPrice } from '../../context/utils'\nimport type { RedeemableItem as RedeemableItemType } from '../../type'\nimport { CreditsRedeemListCopy } from '../type'\nimport { useHeadlessContext } from '@anker-in/lib'\n\ntype ProductInfoProps = {\n item: RedeemableItemType\n copy: CreditsRedeemListCopy\n}\n\nexport const ProductInfo = ({ item, copy }: ProductInfoProps) => {\n const { locale } = useHeadlessContext()\n\n return (\n <div className=\"flex w-full items-center justify-center md:items-start md:justify-start\">\n <Picture\n className=\"mr-[16px] size-[100px] shrink-0 md:mr-[12px] md:hidden md:size-[44px] [&_img]:h-full [&_img]:w-auto [&_img]:object-contain\"\n source={item.variant.image?.url || item.product?.images[0]?.url}\n alt={item.product.title}\n ></Picture>\n <div className=\"md:flex md:flex-col\">\n <div className=\"md:flex md:items-center\">\n <Picture\n className=\"mr-[16px] size-[100px] shrink-0 md:mr-[12px] md:size-[44px] min-md:hidden [&_img]:h-full [&_img]:w-auto [&_img]:object-contain\"\n source={item.variant.image?.url || item.product?.images[0]?.url}\n alt={item.product.title}\n ></Picture>\n <div className=\"flex-1 text-[16px] font-bold leading-[1.4] min-l:!hidden\" title={item.product.title}>\n {item.product.title}\n </div>\n </div>\n\n <div className=\"mt-[16px] md:mt-[12px]\">\n <div className=\"mb-[12px] line-clamp-1 text-[16px] font-bold l:!hidden\" title={item.product.title}>\n {item.product.title}\n </div>\n <div className=\"flex font-semibold leading-[1.4] md:flex-col\">\n <div className=\"mr-[40px] text-[15px] font-bold text-[#777] md:mr-0 md:text-[12px]\">\n <div className=\"mb-[8px] flex items-center md:mb-[4px]\">\n <span>{copy.redeemModal.product.variantLabel}: </span>\n <span className=\"ml-1\">{item.variant.title || ''}</span>\n </div>\n <div className=\"mb-[8px] flex items-center md:mb-[4px]\">\n <span>{copy.redeemModal.product.shippingFeeLabel}: </span>\n <span className=\"ml-1\">\n {formatPrice({\n amount: 0,\n currencyCode: item.product.price?.currencyCode!,\n locale: locale || 'us',\n })}\n </span>\n </div>\n </div>\n <div className=\"text-[15px] font-bold text-[#777] md:text-[12px]\">\n <div className=\"mb-[8px] flex items-center md:mb-[4px]\">\n <span>{copy.redeemModal.product.quantityLabel}: </span>\n <span className=\"ml-1\">1</span>\n </div>\n <div className=\"l:flex l:items-center l:justify-between\">\n <span>{copy.redeemModal.product.totalPriceLabel}: </span>\n <span className=\"ml-1\">\n {item.alpc?.consumeCredits} {copy?.pointUnit}\n </span>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": "AAgBM,cAAAA,EAME,QAAAC,MANF,oBAhBN,OAAS,WAAAC,MAAe,wBACxB,OAAS,eAAAC,MAAmB,sBAG5B,OAAS,sBAAAC,MAA0B,gBAO5B,MAAMC,EAAc,CAAC,CAAE,KAAAC,EAAM,KAAAC,CAAK,IAAwB,CAC/D,KAAM,CAAE,OAAAC,CAAO,EAAIJ,EAAmB,EAEtC,OACEH,EAAC,OAAI,UAAU,0EACb,UAAAD,EAACE,EAAA,CACC,UAAU,6HACV,OAAQI,EAAK,QAAQ,OAAO,KAAOA,EAAK,SAAS,OAAO,CAAC,GAAG,IAC5D,IAAKA,EAAK,QAAQ,MACnB,EACDL,EAAC,OAAI,UAAU,sBACb,UAAAA,EAAC,OAAI,UAAU,0BACb,UAAAD,EAACE,EAAA,CACC,UAAU,iIACV,OAAQI,EAAK,QAAQ,OAAO,KAAOA,EAAK,SAAS,OAAO,CAAC,GAAG,IAC5D,IAAKA,EAAK,QAAQ,MACnB,EACDN,EAAC,OAAI,UAAU,2DAA2D,MAAOM,EAAK,QAAQ,MAC3F,SAAAA,EAAK,QAAQ,MAChB,GACF,EAEAL,EAAC,OAAI,UAAU,yBACb,UAAAD,EAAC,OAAI,UAAU,yDAAyD,MAAOM,EAAK,QAAQ,MACzF,SAAAA,EAAK,QAAQ,MAChB,EACAL,EAAC,OAAI,UAAU,+CACb,UAAAA,EAAC,OAAI,UAAU,qEACb,UAAAA,EAAC,OAAI,UAAU,yCACb,UAAAA,EAAC,QAAM,UAAAM,EAAK,YAAY,QAAQ,aAAa,MAAE,EAC/CP,EAAC,QAAK,UAAU,OAAQ,SAAAM,EAAK,QAAQ,OAAS,GAAG,GACnD,EACAL,EAAC,OAAI,UAAU,yCACb,UAAAA,EAAC,QAAM,UAAAM,EAAK,YAAY,QAAQ,iBAAiB,MAAE,EACnDP,EAAC,QAAK,UAAU,OACb,SAAAG,EAAY,CACX,OAAQ,EACR,aAAcG,EAAK,QAAQ,OAAO,aAClC,OAAQE,GAAU,IACpB,CAAC,EACH,GACF,GACF,EACAP,EAAC,OAAI,UAAU,mDACb,UAAAA,EAAC,OAAI,UAAU,yCACb,UAAAA,EAAC,QAAM,UAAAM,EAAK,YAAY,QAAQ,cAAc,MAAE,EAChDP,EAAC,QAAK,UAAU,OAAO,aAAC,GAC1B,EACAC,EAAC,OAAI,UAAU,0CACb,UAAAA,EAAC,QAAM,UAAAM,EAAK,YAAY,QAAQ,gBAAgB,MAAE,EAClDN,EAAC,QAAK,UAAU,OACb,UAAAK,EAAK,MAAM,eAAe,IAAEC,GAAM,WACrC,GACF,GACF,GACF,GACF,GACF,GACF,CAEJ",
6
+ "names": ["jsx", "jsxs", "Picture", "formatPrice", "useHeadlessContext", "ProductInfo", "item", "copy", "locale"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{jsx as e,jsxs as u}from"react/jsx-runtime";import{Button as x,Text as o}from"@anker-in/headless-ui";import n from"classnames";import{ProductInfo as c}from"./ProductInfo";const N=({copy:t,shippingProduct:m,loading:d,address:s,disabled:p,onClose:a,item:l})=>e("div",{className:n("max-h-[500px] overflow-y-auto px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]"),children:u("div",{className:"flex flex-col items-center",children:[e("div",{className:"mb-[16px] grid grid-flow-row gap-y-[4px] md:mb-[12px]",children:t.redeemModal.product.successDesc.map((r,i)=>e(o,{className:"text-[18px] font-bold leading-[1.4] md:text-[14px]",html:r},i))}),m&&e(o,{className:"mb-5 text-[16px] font-bold",html:m}),e("div",{className:"flex w-full items-center rounded-[16px] bg-[#F5F5F7] p-[16px]",children:e(c,{item:l,copy:t})}),e(x,{loading:d||!s,variant:"primary",className:"mx-auto mt-[16px] w-[444px] md:mt-[12px] md:w-full",onClick:a,disabled:p,children:t.redeemModal.product.paymentButton})]})});export{N as Success};
2
+ //# sourceMappingURL=Success.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/components/credits/creditsRedeemList/RedeemProductModal/Success.tsx"],
4
+ "sourcesContent": ["import { Button, Text } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport type { RedeemableItem as RedeemableItemType } from '../../type'\nimport { CreditsRedeemListCopy } from '../type'\nimport { ProductInfo } from './ProductInfo'\n\ntype SuccessProps = {\n copy: CreditsRedeemListCopy\n shippingProduct: string\n loading: boolean\n address: Record<string, any> | undefined\n disabled: boolean\n onClose: () => void\n item: RedeemableItemType\n}\n\nexport const Success = ({ copy, shippingProduct, loading, address, disabled, onClose, item }: SuccessProps) => {\n return (\n <div className={classNames('max-h-[500px] overflow-y-auto px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]')}>\n <div className=\"flex flex-col items-center\">\n <div className=\"mb-[16px] grid grid-flow-row gap-y-[4px] md:mb-[12px]\">\n {copy.redeemModal.product.successDesc.map((description: string, index: number) => (\n <Text key={index} className=\"text-[18px] font-bold leading-[1.4] md:text-[14px]\" html={description}></Text>\n ))}\n </div>\n\n {shippingProduct && <Text className=\"mb-5 text-[16px] font-bold\" html={shippingProduct}></Text>}\n\n <div className=\"flex w-full items-center rounded-[16px] bg-[#F5F5F7] p-[16px]\">\n <ProductInfo item={item} copy={copy} />\n </div>\n\n <Button\n loading={loading || !address}\n variant=\"primary\"\n className=\"mx-auto mt-[16px] w-[444px] md:mt-[12px] md:w-full\"\n onClick={onClose}\n disabled={disabled}\n >\n {copy.redeemModal.product.paymentButton}\n </Button>\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": "AAmBM,OAGM,OAAAA,EAHN,QAAAC,MAAA,oBAnBN,OAAS,UAAAC,EAAQ,QAAAC,MAAY,wBAC7B,OAAOC,MAAgB,aAGvB,OAAS,eAAAC,MAAmB,gBAYrB,MAAMC,EAAU,CAAC,CAAE,KAAAC,EAAM,gBAAAC,EAAiB,QAAAC,EAAS,QAAAC,EAAS,SAAAC,EAAU,QAAAC,EAAS,KAAAC,CAAK,IAEvFb,EAAC,OAAI,UAAWI,EAAW,iFAAiF,EAC1G,SAAAH,EAAC,OAAI,UAAU,6BACb,UAAAD,EAAC,OAAI,UAAU,wDACZ,SAAAO,EAAK,YAAY,QAAQ,YAAY,IAAI,CAACO,EAAqBC,IAC9Df,EAACG,EAAA,CAAiB,UAAU,qDAAqD,KAAMW,GAA5EC,CAAyF,CACrG,EACH,EAECP,GAAmBR,EAACG,EAAA,CAAK,UAAU,6BAA6B,KAAMK,EAAiB,EAExFR,EAAC,OAAI,UAAU,gEACb,SAAAA,EAACK,EAAA,CAAY,KAAMQ,EAAM,KAAMN,EAAM,EACvC,EAEAP,EAACE,EAAA,CACC,QAASO,GAAW,CAACC,EACrB,QAAQ,UACR,UAAU,qDACV,QAASE,EACT,SAAUD,EAET,SAAAJ,EAAK,YAAY,QAAQ,cAC5B,GACF,EACF",
6
+ "names": ["jsx", "jsxs", "Button", "Text", "classNames", "ProductInfo", "Success", "copy", "shippingProduct", "loading", "address", "disabled", "onClose", "item", "description", "index"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{jsx as u,jsxs as X}from"react/jsx-runtime";import R from"classnames";import{useCallback as w,useEffect as F,useMemo as K,useState as l}from"react";import{useCreditsContext as _}from"../../context/provider";import k from"../../context/hooks/useCountries";import{AlpcErrorCode as c}from"../../context/const";import{useAddressValidate as T}from"../../context/hooks/useAddressValidate";import{useRedeemProduct as B}from"../../context/hooks/useRedeemProduct";import{CreditsModalContainer as G}from"../../modal/modalContainer";import{useHeadlessContext as H}from"@anker-in/lib";import{Error as J}from"./Error";import{Success as V}from"./Success";import{Address as z}from"./Address";import{Init as Q}from"./Init";function W({item:s,copy:e,onError:h,...m}){const{fetchCreditInfo:E,profile:I}=_(),{storeDomain:A,locale:N}=H(),{validatorInfo:L}=e,{shippingAddress:S,shippingProduct:v}=e.redeemModal.product,[d,i]=l("init"),[t,x]=l(),[y,n]=l({code:0,message:"",imageUrl:""}),[f,a]=l(!1),{countries:b=[],isLoading:Y}=k({shopifyStoreDomain:A}),{isMutating:p,trigger:P}=B({onSuccess(r){if(!r){i("error"),n({code:0,imageUrl:e.redeemModal.errorImageUrl||"",message:e.redeemModal.commonError||""});return}if(r?.code===0)E(I?.user_id),i("success");else{let o,M;r.code===c.CodeLpcShopifyCouponRuleRedeemLimit?(o=e.redeemModal.redeemLimitError,a(!0)):r.code===c.CodeLpcRuleInventoryNotEnough?(o=e.redeemModal.inventoryNotEnough,a(!0),M=e.redeemModal.inventoryNotEnough):r.code===c.CodeLpcNotEnoughCredits?(o=e.redeemModal.creditsNotEnough,a(!0),E(I?.user_id)):r.code===c.CodeCrossSiteError&&(o=e.redeemModal.crossSiteError,a(!0)),i("error"),n({code:r.code,imageUrl:M||e.redeemModal.errorImageUrl||"",message:o||e.redeemModal.commonError||""}),h&&h(r.code)}},onError(r){i("error"),n({code:0,imageUrl:e.redeemModal.errorImageUrl||"",message:e.redeemModal.commonError||""})}}),g=K(()=>e?.redeemModal.product.form?.flat().find(o=>o.type==="state")?.key,[e?.redeemModal.product.form]),{validate:C,errors:U}=T({address:t,validatorInfo:L,formData:e?.redeemModal.product.form?.flat()||[],errorLabel:{require:e.redeemModal.product.required,email:e.redeemModal.product.invalidEmail}}),O=w(async()=>{const r=[];if(g&&((b.find(q=>q.code===t.country)?.provinces||[]).length||r.push(g)),C({force:!0,ignoreKeys:r}))return;console.log("address",t);let o={...t};o.name&&delete o.name,o.country==="UK"&&(o.country="GB"),P({address:btoa(JSON.stringify(o)),rule_id:Number(s.alpc?.id)})},[s,P,g,C,t,b]);return F(()=>{m.isOpen||(a(!1),n({code:0,message:"",imageUrl:""}))},[m.isOpen,N]),X(G,{...m,className:R("w-[540px] md:h-auto min-md:max-h-[calc(100vh-40px)]",d!=="init"&&"w-[740px] md:w-full"),scrollClassName:"mb-0 min-l:px-0 md:mb-0 px-0",titleClassName:R("h-[56px]",d==="init"&&"bg-[#F5F5F7]"),title:d==="address"?"Order Confirmation":"",children:[d==="error"&&u(J,{errorInfo:y}),d==="success"&&u(V,{copy:e,shippingProduct:v,loading:p,address:t,disabled:f,onClose:m.onClose,item:s}),d==="address"&&u(z,{copy:e,shippingAddress:S,setAddress:x,validateAddress:C,validateErrors:U,shippingProduct:v,loading:p,address:t,disabled:f,handlePayment:O,item:s}),d==="init"&&u(Q,{item:s,copy:e,loading:p,disabled:f,setStatus:i})]})}var ce=W;export{ce as default};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/components/credits/creditsRedeemList/RedeemProductModal/index.tsx"],
4
+ "sourcesContent": ["import classNames from 'classnames'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { useCreditsContext } from '../../context/provider'\nimport useCountries from '../../context/hooks/useCountries'\nimport { AlpcErrorCode } from '../../context/const'\nimport { useAddressValidate } from '../../context/hooks/useAddressValidate'\nimport { useRedeemProduct } from '../../context/hooks/useRedeemProduct'\nimport type { ModalContainerProps } from '../../modal/modalContainer'\nimport { CreditsModalContainer } from '../../modal/modalContainer'\nimport type { RedeemableItem as RedeemableItemType } from '../../type'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { CreditsRedeemListCopy } from '../type'\nimport { Error } from './Error'\nimport { Success } from './Success'\nimport { Address } from './Address'\nimport { Init } from './Init'\n\ntype RedeemProductModalProps = ModalContainerProps & {\n item: RedeemableItemType\n copy: CreditsRedeemListCopy\n onError: (code: AlpcErrorCode) => void\n}\n\nfunction RedeemProductModal({ item, copy, onError, ...props }: RedeemProductModalProps) {\n const { fetchCreditInfo, profile } = useCreditsContext()\n const { storeDomain, locale } = useHeadlessContext()\n\n const { validatorInfo } = copy\n const { shippingAddress, shippingProduct } = copy.redeemModal.product\n\n const [status, setStatus] = useState<'init' | 'address' | 'success' | 'error'>('init')\n const [address, setAddress] = useState<any>()\n const [errorInfo, setErrorInfo] = useState({\n code: 0,\n message: '',\n imageUrl: '',\n })\n const [disabled, setDisabled] = useState(false)\n\n const { countries = [], isLoading: countriesLoading } = useCountries({ shopifyStoreDomain: storeDomain })\n\n const { isMutating: loading, trigger } = useRedeemProduct({\n onSuccess(responseData) {\n if (!responseData) {\n setStatus('error')\n setErrorInfo({\n code: 0,\n imageUrl: copy.redeemModal.errorImageUrl || '',\n message: copy.redeemModal.commonError || '',\n })\n return\n }\n\n if (responseData?.code === 0) {\n fetchCreditInfo(profile?.user_id)\n setStatus('success')\n } else {\n let errorMsg\n let errorImage\n if (responseData.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n errorMsg = copy.redeemModal.redeemLimitError\n setDisabled(true)\n } else if (responseData.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n errorMsg = copy.redeemModal.inventoryNotEnough\n setDisabled(true)\n errorImage = copy.redeemModal.inventoryNotEnough\n } else if (responseData.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n errorMsg = copy.redeemModal.creditsNotEnough\n setDisabled(true)\n fetchCreditInfo(profile?.user_id)\n } else if (responseData.code === AlpcErrorCode.CodeCrossSiteError) {\n errorMsg = copy.redeemModal.crossSiteError\n setDisabled(true)\n }\n\n setStatus('error')\n setErrorInfo({\n code: responseData.code,\n imageUrl: errorImage || copy.redeemModal.errorImageUrl || '',\n message: errorMsg || copy.redeemModal.commonError || '',\n })\n onError && onError(responseData.code)\n }\n },\n onError(error) {\n setStatus('error')\n setErrorInfo({\n code: 0,\n imageUrl: copy.redeemModal.errorImageUrl || '',\n message: copy.redeemModal.commonError || '',\n })\n },\n })\n\n const stateInputKey = useMemo(() => {\n const stateInput = copy?.redeemModal.product.form?.flat().find(item => item.type === 'state')\n return stateInput?.key\n }, [copy?.redeemModal.product.form])\n\n const { validate: validateAddress, errors: validateErrors } = useAddressValidate({\n address: address,\n validatorInfo: validatorInfo,\n formData: copy?.redeemModal.product.form?.flat() || [],\n errorLabel: {\n require: copy.redeemModal.product.required,\n email: copy.redeemModal.product.invalidEmail,\n },\n })\n\n const handlePayment = useCallback(async () => {\n const ignoreKeys: string[] = []\n\n if (stateInputKey) {\n const provinces = countries.find(item => item.code === address.country)?.provinces || []\n\n if (!provinces.length) {\n ignoreKeys.push(stateInputKey as never)\n }\n }\n\n if (\n validateAddress({\n force: true,\n ignoreKeys,\n })\n ) {\n // \u5730\u5740\u6821\u9A8C\u9519\u8BEF\n return\n }\n console.log('address', address)\n let requestAddress = { ...address }\n if (requestAddress.name) {\n delete requestAddress.name\n }\n if (requestAddress.country === 'UK') {\n requestAddress.country = 'GB'\n }\n trigger({\n address: btoa(JSON.stringify(requestAddress)),\n rule_id: Number(item.alpc?.id),\n })\n }, [item, trigger, stateInputKey, validateAddress, address, countries])\n\n useEffect(() => {\n if (!props.isOpen) {\n setDisabled(false)\n setErrorInfo({ code: 0, message: '', imageUrl: '' })\n }\n }, [props.isOpen, locale])\n\n return (\n <CreditsModalContainer\n {...props}\n className={classNames(\n 'w-[540px] md:h-auto min-md:max-h-[calc(100vh-40px)]',\n status !== 'init' && 'w-[740px] md:w-full'\n )}\n scrollClassName=\"mb-0 min-l:px-0 md:mb-0 px-0\"\n titleClassName={classNames('h-[56px]', status === 'init' && 'bg-[#F5F5F7]')}\n title={status === 'address' ? 'Order Confirmation' : ''}\n >\n {status === 'error' && <Error errorInfo={errorInfo} />}\n {status === 'success' && (\n <Success\n copy={copy}\n shippingProduct={shippingProduct}\n loading={loading}\n address={address}\n disabled={disabled}\n onClose={props.onClose}\n item={item}\n />\n )}\n {status === 'address' && (\n <Address\n copy={copy}\n shippingAddress={shippingAddress}\n setAddress={setAddress}\n validateAddress={validateAddress}\n validateErrors={validateErrors}\n shippingProduct={shippingProduct}\n loading={loading}\n address={address}\n disabled={disabled}\n handlePayment={handlePayment}\n item={item}\n />\n )}\n {status === 'init' && (\n <Init item={item} copy={copy} loading={loading} disabled={disabled} setStatus={setStatus} />\n )}\n </CreditsModalContainer>\n )\n}\n\nexport default RedeemProductModal\n"],
5
+ "mappings": "AAuJI,OAUyB,OAAAA,EAVzB,QAAAC,MAAA,oBAvJJ,OAAOC,MAAgB,aACvB,OAAS,eAAAC,EAAa,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAC1D,OAAS,qBAAAC,MAAyB,yBAClC,OAAOC,MAAkB,mCACzB,OAAS,iBAAAC,MAAqB,sBAC9B,OAAS,sBAAAC,MAA0B,yCACnC,OAAS,oBAAAC,MAAwB,uCAEjC,OAAS,yBAAAC,MAA6B,6BAEtC,OAAS,sBAAAC,MAA0B,gBAEnC,OAAS,SAAAC,MAAa,UACtB,OAAS,WAAAC,MAAe,YACxB,OAAS,WAAAC,MAAe,YACxB,OAAS,QAAAC,MAAY,SAQrB,SAASC,EAAmB,CAAE,KAAAC,EAAM,KAAAC,EAAM,QAAAC,EAAS,GAAGC,CAAM,EAA4B,CACtF,KAAM,CAAE,gBAAAC,EAAiB,QAAAC,CAAQ,EAAIjB,EAAkB,EACjD,CAAE,YAAAkB,EAAa,OAAAC,CAAO,EAAIb,EAAmB,EAE7C,CAAE,cAAAc,CAAc,EAAIP,EACpB,CAAE,gBAAAQ,EAAiB,gBAAAC,CAAgB,EAAIT,EAAK,YAAY,QAExD,CAACU,EAAQC,CAAS,EAAIzB,EAAmD,MAAM,EAC/E,CAAC0B,EAASC,CAAU,EAAI3B,EAAc,EACtC,CAAC4B,EAAWC,CAAY,EAAI7B,EAAS,CACzC,KAAM,EACN,QAAS,GACT,SAAU,EACZ,CAAC,EACK,CAAC8B,EAAUC,CAAW,EAAI/B,EAAS,EAAK,EAExC,CAAE,UAAAgC,EAAY,CAAC,EAA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AW,WACV9B,EAACe,EAAA,CACC,KAAMK,EACN,gBAAiBS,EACjB,QAASW,EACT,QAASR,EACT,SAAUI,EACV,QAASd,EAAM,QACf,KAAMH,EACR,EAEDW,IAAW,WACV9B,EAACgB,EAAA,CACC,KAAMI,EACN,gBAAiBQ,EACjB,WAAYK,EACZ,gBAAiBc,EACjB,eAAgBC,EAChB,gBAAiBnB,EACjB,QAASW,EACT,QAASR,EACT,SAAUI,EACV,cAAea,EACf,KAAM9B,EACR,EAEDW,IAAW,QACV9B,EAACiB,EAAA,CAAK,KAAME,EAAM,KAAMC,EAAM,QAASoB,EAAS,SAAUJ,EAAU,UAAWL,EAAW,GAE9F,CAEJ,CAEA,IAAOqB,GAAQlC",
6
+ "names": ["jsx", "jsxs", "classNames", "useCallback", "useEffect", "useMemo", "useState", "useCreditsContext", "useCountries", "AlpcErrorCode", "useAddressValidate", "useRedeemProduct", "CreditsModalContainer", "useHeadlessContext", "Error", "Success", "Address", "Init", "RedeemProductModal", "item", "copy", "onError", "props", "fetchCreditInfo", "profile", "storeDomain", "locale", "validatorInfo", "shippingAddress", "shippingProduct", "status", "setStatus", "address", "setAddress", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "countries", "countriesLoading", "loading", "trigger", "responseData", "errorMsg", "errorImage", "error", "stateInputKey", "validateAddress", "validateErrors", "handlePayment", "ignoreKeys", "requestAddress", "RedeemProductModal_default"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{jsx as l,jsxs as a}from"react/jsx-runtime";import{Button as y,Text as n,Picture as p}from"@anker-in/headless-ui";import{useMemo as c}from"react";import s from"classnames";import{useCreditsContext as N}from"../context/provider";import{AlpcConsumeType as u,ConsumeType as f}from"../context/const";import{numberFormat as C}from"../context/utils";import{gaTrack as v}from"../../../helpers/track";function E({copy:t,className:g,item:e,onRulesOpen:b,onRedeem:h}){const{creditInfo:m,profile:i,gtm:{pageGroup:x}}=N(),o=Object.keys(i||{}).length>0,_=c(()=>!!(e.alpc?.remainingInventory<=0&&e.alpc?.isLimited||e.alpc?.consumeType===u.Product&&!e.variant?.availableForSale||o&&i?.activated&&e.alpc?.consumeCredits>Number(m?.available_credit||0)),[e.alpc?.remainingInventory,e.alpc?.isLimited,e.alpc?.consumeType,e.alpc?.consumeCredits,o,i?.activated,m?.available_credit,e.variant?.availableForSale]),d=c(()=>o?e.alpc?.consumeType===u.Product?e.variant?.availableForSale?t.btnRedeem:t?.soldOut||"Sold Out":t.btnRedeem:t.unlockRewards,[o,e.alpc?.consumeType,e.variant?.availableForSale,t.btnRedeem,t.unlockRewards,t?.soldOut]);return a("div",{className:s("flex flex-col items-center rounded-[16px] bg-[#EAEAEC] p-[24px] md:rounded-[12px] md:px-[8px] xl:py-[16px] md-xl:px-[16px]",g),children:[e.config?.type!==f.Product?a("div",{className:"relative mx-auto my-[30px] h-[164px] md:my-0 md:h-[66px] l-xxl:h-[138px] md-l:h-[80px]",children:[l(p,{source:t?.imageMapping[e.config?.type]?.url,className:"h-full [&_img]:h-full [&_img]:w-auto [&_img]:object-contain"}),l("div",{className:"absolute bottom-[8px] left-[16px] font-extrabold text-white md:bottom-[2px] md:left-[5px]",children:e.config?.value?a("div",{className:"flex items-end",children:[l(n,{className:"text-[64px] font-bold leading-none md:text-[20px] l-xxl:text-[40px] md-l:text-[22px]",html:e.config?.value}),l(n,{className:"ml-[4px] text-[24px] font-bold leading-[2] md:ml-[2px] l:text-[12px] xxl:leading-[1.4] l-xxl:text-[20px]",html:e.config?.type===f.GiftCard?t?.giftCardLabel:t?.off})]}):l(n,{size:3,html:e.config?.title||e.alpc?.title})})]}):l("div",{className:s("relative mx-auto h-[224px] w-fit md:my-[10px] l:h-[120px] l-xxl:h-[138px]"),children:l(p,{className:"h-full w-auto [&_img]:h-full [&_img]:object-contain",source:e.config?.image?.url||e.product.images?.[0]?.url})}),a("div",{className:s("mt-[22px] flex w-full flex-1 flex-col justify-between"),children:[l(n,{html:e.config?.title||e.alpc?.title,title:e.config?.title||e.alpc?.title,size:2,className:"text-[24px] font-bold leading-[1.2] l:text-[16px] l-xxl:text-[20px]"}),e.config?.rules?.length>0&&l("button",{type:"button",onClick:()=>{b(e.config?.rules||[]),v({event:"ga4Event",event_name:"lp_button",member_active_status:i?.activated?"active":"not active",event_parameters:{page_group:x,position:t.title,button_name:t?.ruleLabel,info:e.alpc?.id?.toString()}})},className:"mt-[8px] w-fit text-[16px] font-bold underline md:text-[14px] l:mt-0",tabIndex:0,onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&r.preventDefault()},children:t?.ruleLabel}),a("div",{children:[a("div",{className:"mt-[24px] flex items-center l:mt-[12px] l-xl:mt-[16px]",children:[l(p,{className:"size-[20px]",source:"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/icon_hire_purchase.png?v=1757496783"}),l(n,{html:`${C(e.alpc?.consumeCredits)}`,size:2,as:"p",className:"ml-[4px] text-[28px] font-bold leading-[1.2] md:text-[18px] l-xxl:text-[24px] md-l:text-[20px] "})]}),l(y,{disabled:_,variant:"primary",size:"lg",className:"mt-[8px] md:px-[8px] l:w-full",onClick:()=>{h(e),v({event:"ga4Event",event_name:"lp_button",member_active_status:i?.activated?"active":"not active",event_parameters:{page_group:x,position:t.title,button_name:d,info:e.alpc?.id?.toString()}})},children:d})]})]})]})}export{E as RedeemableItem};
2
+ //# sourceMappingURL=RedeemableItem.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/components/credits/creditsRedeemList/RedeemableItem.tsx"],
4
+ "sourcesContent": ["import { Button, Text, Picture } from '@anker-in/headless-ui'\n\nimport { useMemo } from 'react'\n\nimport classNames from 'classnames'\nimport { useCreditsContext } from '../context/provider'\nimport type { RedeemableItem as RedeemableItemType } from '../type'\nimport { AlpcConsumeType, ConsumeType } from '../context/const'\nimport { numberFormat } from '../context/utils'\nimport type { CreditsRedeemListCopy } from './type'\nimport { gaTrack } from '../../../helpers/track'\n\nexport function RedeemableItem({\n copy,\n className,\n item,\n onRulesOpen,\n onRedeem,\n}: {\n copy: CreditsRedeemListCopy\n className?: string\n item: RedeemableItemType\n onRulesOpen: (rules: string[]) => void\n onRedeem: (item: RedeemableItemType) => void\n}) {\n const {\n creditInfo,\n profile,\n gtm: { pageGroup },\n } = useCreditsContext()\n const isLogin = Object.keys(profile || {}).length > 0\n\n const isDisabled = useMemo(() => {\n if (item.alpc?.remainingInventory <= 0 && item.alpc?.isLimited) {\n // \u6709\u5E93\u5B58\u9650\u5236\n return true\n }\n\n if (item.alpc?.consumeType === AlpcConsumeType.Product) {\n if (!item.variant?.availableForSale) {\n return true\n }\n }\n if (isLogin && profile?.activated && item.alpc?.consumeCredits > Number(creditInfo?.available_credit || 0)) {\n return true\n }\n return false\n }, [\n item.alpc?.remainingInventory,\n item.alpc?.isLimited,\n item.alpc?.consumeType,\n item.alpc?.consumeCredits,\n isLogin,\n profile?.activated,\n creditInfo?.available_credit,\n item.variant?.availableForSale,\n ])\n\n const redeemButtonText = useMemo(() => {\n if (!isLogin) {\n return copy.unlockRewards\n }\n\n // \u7F3A\u8D27\u6587\u6848\n if (item.alpc?.consumeType === AlpcConsumeType.Product) {\n return item.variant?.availableForSale ? copy.btnRedeem : copy?.soldOut || 'Sold Out'\n }\n return copy.btnRedeem\n }, [\n isLogin,\n item.alpc?.consumeType,\n item.variant?.availableForSale,\n copy.btnRedeem,\n copy.unlockRewards,\n copy?.soldOut,\n ])\n\n return (\n <div\n className={classNames(\n 'flex flex-col items-center rounded-[16px] bg-[#EAEAEC] p-[24px] md:rounded-[12px] md:px-[8px] xl:py-[16px] md-xl:px-[16px]',\n className\n )}\n >\n {item.config?.type !== ConsumeType.Product ? (\n <div className=\"relative mx-auto my-[30px] h-[164px] md:my-0 md:h-[66px] l-xxl:h-[138px] md-l:h-[80px]\">\n <Picture\n source={copy?.imageMapping[item.config?.type]?.url}\n className=\"h-full [&_img]:h-full [&_img]:w-auto [&_img]:object-contain\"\n ></Picture>\n <div className=\"absolute bottom-[8px] left-[16px] font-extrabold text-white md:bottom-[2px] md:left-[5px]\">\n {item.config?.value ? (\n <div className=\"flex items-end\">\n <Text\n className=\"text-[64px] font-bold leading-none md:text-[20px] l-xxl:text-[40px] md-l:text-[22px]\"\n html={item.config?.value}\n />\n <Text\n className=\"ml-[4px] text-[24px] font-bold leading-[2] md:ml-[2px] l:text-[12px] xxl:leading-[1.4] l-xxl:text-[20px]\"\n html={item.config?.type === ConsumeType.GiftCard ? copy?.giftCardLabel : copy?.off}\n />\n </div>\n ) : (\n <Text size={3} html={item.config?.title || item.alpc?.title} />\n )}\n </div>\n </div>\n ) : (\n <div className={classNames('relative mx-auto h-[224px] w-fit md:my-[10px] l:h-[120px] l-xxl:h-[138px]')}>\n <Picture\n className=\"h-full w-auto [&_img]:h-full [&_img]:object-contain\"\n source={item.config?.image?.url || item.product.images?.[0]?.url}\n ></Picture>\n </div>\n )}\n <div className={classNames('mt-[22px] flex w-full flex-1 flex-col justify-between')}>\n <Text\n html={item.config?.title || item.alpc?.title}\n title={item.config?.title || item.alpc?.title}\n size={2}\n className=\"text-[24px] font-bold leading-[1.2] l:text-[16px] l-xxl:text-[20px]\"\n />\n {item.config?.rules?.length > 0 && (\n <button\n type=\"button\"\n onClick={() => {\n onRulesOpen(item.config?.rules || [])\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: pageGroup,\n position: copy.title,\n button_name: copy?.ruleLabel,\n info: item.alpc?.id?.toString(),\n },\n })\n }}\n className=\"mt-[8px] w-fit text-[16px] font-bold underline md:text-[14px] l:mt-0\"\n tabIndex={0}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n }\n }}\n >\n {copy?.ruleLabel}\n </button>\n )}\n <div>\n <div className=\"mt-[24px] flex items-center l:mt-[12px] l-xl:mt-[16px]\">\n <Picture\n className=\"size-[20px]\"\n source=\"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/icon_hire_purchase.png?v=1757496783\"\n />\n <Text\n html={`${numberFormat(item.alpc?.consumeCredits)}`}\n size={2}\n as=\"p\"\n className=\"ml-[4px] text-[28px] font-bold leading-[1.2] md:text-[18px] l-xxl:text-[24px] md-l:text-[20px] \"\n />\n </div>\n\n <Button\n disabled={isDisabled}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[8px] md:px-[8px] l:w-full\"\n onClick={() => {\n onRedeem(item)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: pageGroup,\n position: copy.title,\n button_name: redeemButtonText,\n info: item.alpc?.id?.toString(),\n },\n })\n }}\n >\n {redeemButtonText}\n </Button>\n </div>\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": "AAsFU,cAAAA,EAMI,QAAAC,MANJ,oBAtFV,OAAS,UAAAC,EAAQ,QAAAC,EAAM,WAAAC,MAAe,wBAEtC,OAAS,WAAAC,MAAe,QAExB,OAAOC,MAAgB,aACvB,OAAS,qBAAAC,MAAyB,sBAElC,OAAS,mBAAAC,EAAiB,eAAAC,MAAmB,mBAC7C,OAAS,gBAAAC,MAAoB,mBAE7B,OAAS,WAAAC,MAAe,yBAEjB,SAASC,EAAe,CAC7B,KAAAC,EACA,UAAAC,EACA,KAAAC,EACA,YAAAC,EACA,SAAAC,CACF,EAMG,CACD,KAAM,CACJ,WAAAC,EACA,QAAAC,EACA,IAAK,CAAE,UAAAC,CAAU,CACnB,EAAIb,EAAkB,EAChBc,EAAU,OAAO,KAAKF,GAAW,CAAC,CAAC,EAAE,OAAS,EAE9CG,EAAajB,EAAQ,IACrB,GAAAU,EAAK,MAAM,oBAAsB,GAAKA,EAAK,MAAM,WAKjDA,EAAK,MAAM,cAAgBP,EAAgB,SACzC,CAACO,EAAK,SAAS,kBAIjBM,GAAWF,GAAS,WAAaJ,EAAK,MAAM,eAAiB,OAAOG,GAAY,kBAAoB,CAAC,GAIxG,CACDH,EAAK,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AAM,MACxC,KAAM,EACN,UAAU,sEACZ,EACCA,EAAK,QAAQ,OAAO,OAAS,GAC5Bf,EAAC,UACC,KAAK,SACL,QAAS,IAAM,CACbgB,EAAYD,EAAK,QAAQ,OAAS,CAAC,CAAC,EACpCJ,EAAQ,CACN,MAAO,WACP,WAAY,YACZ,qBAAsBQ,GAAS,UAAY,SAAW,aACtD,iBAAkB,CAChB,WAAYC,EACZ,SAAUP,EAAK,MACf,YAAaA,GAAM,UACnB,KAAME,EAAK,MAAM,IAAI,SAAS,CAChC,CACF,CAAC,CACH,EACA,UAAU,uEACV,SAAU,EACV,UAAWS,GAAK,EACVA,EAAE,MAAQ,SAAWA,EAAE,MAAQ,MACjCA,EAAE,eAAe,CAErB,EAEC,SAAAX,GAAM,UACT,EAEFZ,EAAC,OACC,UAAAA,EAAC,OAAI,UAAU,yDACb,UAAAD,EAACI,EAAA,CACC,UAAU,cACV,OAAO,6FACT,EACAJ,EAACG,EAAA,CACC,KAAM,GAAGO,EAAaK,EAAK,MAAM,cAAc,CAAC,GAChD,KAAM,EACN,GAAG,IACH,UAAU,kGACZ,GACF,EAEAf,EAACE,EAAA,CACC,SAAUoB,EACV,QAAQ,UACR,KAAK,KACL,UAAU,gCACV,QAAS,IAAM,CACbL,EAASF,CAAI,EACbJ,EAAQ,CACN,MAAO,WACP,WAAY,YACZ,qBAAsBQ,GAAS,UAAY,SAAW,aACtD,iBAAkB,CAChB,WAAYC,EACZ,SAAUP,EAAK,MACf,YAAaU,EACb,KAAMR,EAAK,MAAM,IAAI,SAAS,CAChC,CACF,CAAC,CACH,EAEC,SAAAQ,EACH,GACF,GACF,GACF,CAEJ",
6
+ "names": ["jsx", "jsxs", "Button", "Text", "Picture", "useMemo", "classNames", "useCreditsContext", "AlpcConsumeType", "ConsumeType", "numberFormat", "gaTrack", "RedeemableItem", "copy", "className", "item", "onRulesOpen", "onRedeem", "creditInfo", "profile", "pageGroup", "isLogin", "isDisabled", "redeemButtonText", "e"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{jsx as n,jsxs as X}from"react/jsx-runtime";import{Container as F,Heading as D,Tabs as z,TabsList as H,TabsTrigger as j}from"@anker-in/headless-ui";import c from"classnames";import{useCallback as w,useMemo as L,useState as g}from"react";import B from"./RedeemCouponModal";import G from"./RedeemProductModal";import{useCreditsContext as U}from"../context/provider";import V from"../context/hooks/useRedeemableList";import{AlpcConsumeType as f,AlpcErrorCode as q}from"../context/const";import{useProductsByHandles as J}from"@anker-in/lib";import{RedeemableItem as K}from"./RedeemableItem";import Q from"../modal/rulesModal";import{gaTrack as W}from"../../../helpers/track";function pe({copy:t,className:N="",tabClassName:k="",hideTitle:x=!1,cardClassName:_,activate:d}){const{profile:b,openSignUpPopup:I,gtm:{pageGroup:P}}=U(),S=Object.keys(b||{}).length>0,[m,E]=g(t.list[0].label),[o,l]=g(void 0),[p,C]=g(),{listLoading:O,redeemableList:R,getRedeemableList:v}=V(),r=L(()=>R.map(e=>({id:e.id.toString(),title:e.name,consumeCredits:e.consume_credits,remainingInventory:e.remaining_inventory,isLimited:!!e.is_limited,consumeType:e.consume_type,handle:e.sku_handle,sku:e.goods_sku,image:e.goods_url})),[t.list,m,R]),A=r.map(e=>e.handle),{data:T}=J({handles:A}),M=L(()=>t.list.find(s=>s.label===m)?.list.filter(s=>r.some(i=>i.id===s.id)).map(s=>{const i=r.find(a=>a.id===s.id),u=T?.find(a=>a.handle===i?.handle),y=u?.variants.find(a=>a.sku===i?.sku);return i?.consumeType===f.Product&&(!u||!y)?null:{alpc:r.find(a=>a.id===s.id),config:s,product:u,variant:y}}).filter(s=>s!==null),[r,T]),h=w(e=>{e===q.CodeLpcRuleInventoryNotEnough&&v()},[v]);return console.log("popRedeemData",o),X(F,{className:c("relative bg-[#F5F5F7]",N),children:[!x&&n(D,{as:"h2",size:"4",html:t.title}),n(z,{shape:"rounded",align:"left",className:c("sticky top-0 z-20 py-[24px] md:justify-center",k),value:m.toString(),onValueChange:e=>{E(e),W({event:"ga4Event",event_name:"lp_navigation",event_parameters:{navigation:e,page_group:P}})},children:n(H,{children:t.list.map(e=>n(j,{value:e.label,children:e.label},e.label))})}),!!r?.length&&!O&&n("div",{className:c("relative grid grid-cols-4 gap-[16px] md:grid-cols-2 md:gap-[12px] md-xl:grid-cols-3"),children:M?.map(e=>n(K,{copy:t,item:e,onRedeem:s=>{S?!b?.activated&&!d.isSuccess?(d.openAuthCodePopup(),d.setOnSuccess(()=>{l(s)})):l(s):I()},onRulesOpen:C,className:_},e?.alpc?.id))}),o?.alpc?.consumeType===f.Coupon&&t?.redeemModal?.coupon&&o&&n(B,{isOpen:!!o,item:o,copy:t,onError:h,onClose:()=>{l(void 0)}}),o?.alpc?.consumeType===f.Product&&t?.redeemModal&&o&&n(G,{isOpen:!!o,item:o,copy:t,onError:h,onClose:()=>{l(void 0)}}),p&&n(Q,{overlayClassName:"md:px-[16px] md:items-center",className:"md:h-fit md:rounded-b-[16px]",isOpen:p.length>0,onClose:()=>C([]),titleClassName:"border-b-transparent h-[56px]",rules:p,scrollClassName:"md:mt-[8px] md:mb-[24px] md:pt-0",title:t?.ruleLabel,ruleClassName:"text-[#1d1d1f] font-bold"})]})}export{pe as CreditsRedeemList};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/components/credits/creditsRedeemList/index.tsx"],
4
+ "sourcesContent": ["import { Container, Heading, Tabs, TabsList, TabsTrigger } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { useCallback, useMemo, useState } from 'react'\n\nimport RedeemCouponModal from './RedeemCouponModal'\nimport RedeemProductModal from './RedeemProductModal'\nimport { useCreditsContext } from '../context/provider'\nimport useRedeemableList from '../context/hooks/useRedeemableList'\nimport { AlpcConsumeType, AlpcErrorCode } from '../context/const'\nimport { useProductsByHandles } from '@anker-in/lib'\nimport type { RedeemableItem as RedeemableItemType } from '../type'\nimport { RedeemableItem } from './RedeemableItem'\nimport RulesModal from '../modal/rulesModal'\nimport { CreditsRedeemListCopy } from './type'\nimport { gaTrack } from '../../../helpers/track'\n\nexport function CreditsRedeemList({\n copy,\n className = '',\n tabClassName = '',\n hideTitle = false,\n cardClassName,\n activate,\n}: {\n copy: CreditsRedeemListCopy\n className?: string\n tabClassName?: string\n hideTitle?: boolean\n cardClassName?: string\n activate: {\n openAuthCodePopup: () => void\n isSuccess: boolean\n setOnSuccess: (callback: Function) => void\n }\n}) {\n const {\n profile,\n openSignUpPopup,\n gtm: { pageGroup },\n } = useCreditsContext()\n const isLogin = Object.keys(profile || {}).length > 0\n\n const [activeTab, setActiveTab] = useState<string>(copy.list[0].label)\n\n const [popRedeemData, setPopRedeemData] = useState<RedeemableItemType | undefined>(undefined)\n\n const [rules, setRules] = useState<string | string[]>()\n\n const { listLoading, redeemableList, getRedeemableList } = useRedeemableList()\n\n const alpcList = useMemo(() => {\n return redeemableList.map(item => {\n return {\n id: item.id.toString(),\n title: item.name,\n consumeCredits: item.consume_credits,\n remainingInventory: item.remaining_inventory,\n isLimited: !!item.is_limited,\n consumeType: item.consume_type,\n handle: item.sku_handle,\n sku: item.goods_sku,\n image: item.goods_url,\n }\n })\n }, [copy.list, activeTab, redeemableList])\n\n const handles = alpcList.map(item => item.handle)\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n const currentList = copy.list.find(item => item.label === activeTab)\n return currentList?.list\n .filter(item => alpcList.some(alpcItem => alpcItem.id === item.id))\n .map(item => {\n const alpcItem = alpcList.find(alpcItem => alpcItem.id === item.id)\n const product = products?.find(product => product.handle === alpcItem?.handle)\n const variant = product?.variants.find(variant => variant.sku === alpcItem?.sku)\n if (alpcItem?.consumeType === AlpcConsumeType.Product && (!product || !variant)) return null\n return {\n alpc: alpcList.find(alpcItem => alpcItem.id === item.id),\n config: item,\n product,\n variant,\n }\n })\n .filter(item => item !== null) as unknown as RedeemableItemType[]\n }, [alpcList, products])\n\n const handleRedeemError = useCallback(\n (errorCode: AlpcErrorCode) => {\n if (errorCode === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n getRedeemableList()\n }\n },\n [getRedeemableList]\n )\n\n console.log('popRedeemData', popRedeemData)\n\n return (\n <Container className={classNames('relative bg-[#F5F5F7]', className)}>\n {!hideTitle && <Heading as=\"h2\" size=\"4\" html={copy.title} />}\n\n <Tabs\n shape=\"rounded\"\n align=\"left\"\n className={classNames('sticky top-0 z-20 py-[24px] md:justify-center', tabClassName)}\n value={activeTab.toString()}\n onValueChange={value => {\n setActiveTab(value)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_navigation',\n event_parameters: {\n navigation: value,\n page_group: pageGroup,\n },\n })\n }}\n >\n <TabsList>\n {copy.list.map(item => (\n <TabsTrigger key={item.label} value={item.label}>\n {item.label}\n </TabsTrigger>\n ))}\n </TabsList>\n </Tabs>\n {/* PC\u7AEF */}\n {!!alpcList?.length && !listLoading && (\n <div\n className={classNames('relative grid grid-cols-4 gap-[16px] md:grid-cols-2 md:gap-[12px] md-xl:grid-cols-3')}\n >\n {list?.map(item => (\n <RedeemableItem\n key={item?.alpc?.id}\n copy={copy}\n item={item}\n onRedeem={(item: RedeemableItemType) => {\n if (!isLogin) {\n openSignUpPopup()\n } else if (!profile?.activated && !activate.isSuccess) {\n activate.openAuthCodePopup()\n activate.setOnSuccess(() => {\n setPopRedeemData(item)\n })\n } else {\n setPopRedeemData(item)\n }\n }}\n onRulesOpen={setRules}\n className={cardClassName}\n />\n ))}\n </div>\n )}\n\n {popRedeemData?.alpc?.consumeType === AlpcConsumeType.Coupon && copy?.redeemModal?.coupon && popRedeemData && (\n <RedeemCouponModal\n isOpen={!!popRedeemData}\n item={popRedeemData}\n copy={copy}\n onError={handleRedeemError}\n onClose={() => {\n setPopRedeemData(undefined)\n }}\n />\n )}\n {popRedeemData?.alpc?.consumeType === AlpcConsumeType.Product && copy?.redeemModal && popRedeemData && (\n <RedeemProductModal\n isOpen={!!popRedeemData}\n item={popRedeemData}\n copy={copy}\n onError={handleRedeemError}\n onClose={() => {\n setPopRedeemData(undefined)\n }}\n />\n )}\n {rules && (\n <RulesModal\n overlayClassName=\"md:px-[16px] md:items-center\"\n className=\"md:h-fit md:rounded-b-[16px]\"\n isOpen={rules.length > 0}\n onClose={() => setRules([])}\n titleClassName=\"border-b-transparent h-[56px]\"\n rules={rules}\n scrollClassName=\"md:mt-[8px] md:mb-[24px] md:pt-0\"\n title={copy?.ruleLabel}\n ruleClassName=\"text-[#1d1d1f] font-bold\"\n />\n )}\n </Container>\n )\n}\n"],
5
+ "mappings": "AAoGI,OACiB,OAAAA,EADjB,QAAAC,MAAA,oBApGJ,OAAS,aAAAC,EAAW,WAAAC,EAAS,QAAAC,EAAM,YAAAC,EAAU,eAAAC,MAAmB,wBAChE,OAAOC,MAAgB,aACvB,OAAS,eAAAC,EAAa,WAAAC,EAAS,YAAAC,MAAgB,QAE/C,OAAOC,MAAuB,sBAC9B,OAAOC,MAAwB,uBAC/B,OAAS,qBAAAC,MAAyB,sBAClC,OAAOC,MAAuB,qCAC9B,OAAS,mBAAAC,EAAiB,iBAAAC,MAAqB,mBAC/C,OAAS,wBAAAC,MAA4B,gBAErC,OAAS,kBAAAC,MAAsB,mBAC/B,OAAOC,MAAgB,sBAEvB,OAAS,WAAAC,MAAe,yBAEjB,SAASC,GAAkB,CAChC,KAAAC,EACA,UAAAC,EAAY,GACZ,aAAAC,EAAe,GACf,UAAAC,EAAY,GACZ,cAAAC,EACA,SAAAC,CACF,EAWG,CACD,KAAM,CACJ,QAAAC,EACA,gBAAAC,EACA,IAAK,CAAE,UAAAC,CAAU,CACnB,EAAIjB,EAAkB,EAChBkB,EAAU,OAAO,KAAKH,GAAW,CAAC,CAAC,EAAE,OAAS,EAE9C,CAACI,EAAWC,CAAY,EAAIvB,EAAiBY,EAAK,KAAK,CAAC,EAAE,KAAK,EAE/D,CAACY,EAAeC,CAAgB,EAAIzB,EAAyC,MAAS,EAEtF,CAAC0B,EAAOC,CAAQ,EAAI3B,EAA4B,E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ACpFlC,EAACY,EAAA,CACC,OAAQ,CAAC,CAACsB,EACV,KAAMA,EACN,KAAMZ,EACN,QAAS2B,EACT,QAAS,IAAM,CACbd,EAAiB,MAAS,CAC5B,EACF,EAEDC,GACCpC,EAACmB,EAAA,CACC,iBAAiB,+BACjB,UAAU,+BACV,OAAQiB,EAAM,OAAS,EACvB,QAAS,IAAMC,EAAS,CAAC,CAAC,EAC1B,eAAe,gCACf,MAAOD,EACP,gBAAgB,mCAChB,MAAOd,GAAM,UACb,cAAc,2BAChB,GAEJ,CAEJ",
6
+ "names": ["jsx", "jsxs", "Container", "Heading", "Tabs", "TabsList", "TabsTrigger", "classNames", "useCallback", "useMemo", "useState", "RedeemCouponModal", "RedeemProductModal", "useCreditsContext", "useRedeemableList", "AlpcConsumeType", "AlpcErrorCode", "useProductsByHandles", "RedeemableItem", "RulesModal", "gaTrack", "CreditsRedeemList", "copy", "className", "tabClassName", "hideTitle", "cardClassName", "activate", "profile", "openSignUpPopup", "pageGroup", "isLogin", "activeTab", "setActiveTab", "popRedeemData", "setPopRedeemData", "rules", "setRules", "listLoading", "redeemableList", "getRedeemableList", "alpcList", "item", "handles", "products", "list", "alpcItem", "product", "variant", "handleRedeemError", "errorCode", "value"]
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import{Fragment as P,jsx as t,jsxs as s}from"react/jsx-runtime";import{Button as N,Container as I,Heading as r,Picture as f,Text as L}from"@anker-in/headless-ui";import{ChevronDownIcon as T,ChevronUpIcon as D}from"@heroicons/react/24/outline";import{motion as S}from"framer-motion";import{useMemo as A,useState as B}from"react";import{TaskType as p}from"./type";import{useActions as G}from"./useActions";import{useCreditsContext as M}from"../context/provider";import{cn as w}from"../../../helpers/index";const J=({copy:i,activate:m,subscribe:h,uploadReceipt:b,classNames:g})=>{const[n,v]=B(!1),{profile:F}=M(),c=!!F,{actions:x}=G({copy:i,activate:m,subscribe:h,uploadReceipt:b}),y=A(()=>{const e=i.list.map(l=>{if(!x[l.id])return;const{finished:o,notLogin:k,notFinished:u,completed:z}=x[l.id];let d="",a,C;return c?o?(d=z.buttonLabel,a=void 0):(d=u.buttonLabel,a=u.handleClick,C=u.link):(d=k.buttonLabel,a=k.handleClick),{...l,buttonLabel:d,handleClick:a,finished:o,link:C}}).filter(Boolean);return c?e.sort((l,o)=>l?.finished&&!o?.finished?1:!l?.finished&&o?.finished?-1:0):e},[x,i.list,c]);return t(I,{id:"ways-to-get-credits",className:" bg-[#F5F5F7] [&>div]:l:!px-0",children:s("div",{className:"rounded-[16px] bg-[#1D1D1F] py-[64px] px-[140px] text-white md:px-[16px] l:rounded-none md-l:px-[32px] l-xl:px-[77px]",children:[t(r,{as:"h2",size:4,html:i?.title,className:"text-center l:pl-[16px] l:text-left"}),s("div",{className:"mt-[64px] flex items-center justify-between md:mt-[64px] l:mt-[24px] l:flex-col-reverse l:items-start md-l:mt-[32px]",children:[s("div",{className:"pl-[16px] l:mt-[40px] desktop:pl-[24px] lg-desktop:pl-[32px]",children:[t(r,{size:3,as:"h3",html:i.subtitle,className:g?.subtitle}),s("div",{className:"mt-[8px] flex items-center",children:[i.creditsIcon?.url&&t(f,{className:"size-[48px] mr-[8px] stroke-brand xl:size-[30px] [&_path]:stroke-brand",source:i.creditsIcon.url,alt:i.creditsIcon.alt||"credits"}),t(r,{html:i.equalCredits,size:4,as:"h3",className:w("mt-2 text-white md:text-[24px]",g?.equalCreditsText)})]})]}),t(f,{className:"w-full laptop:w-[50%]",source:i.mainImage?.url})]}),s("div",{className:"relative",children:[s(S.div,{className:w("relative mt-[64px] grid grid-cols-3 gap-[16px] overflow-hidden md:mt-[16px] md:grid-cols-1 l:gap-[12px] min-md:!h-auto md-l:mt-[32px] md-l:grid-cols-2"),initial:{height:512},animate:{height:n?"auto":512},transition:{duration:.3},onAnimationComplete:()=>{if(!n&&window.screen.width<768){const e=document.getElementById("ways-to-get-credits");e&&e.scrollIntoView({behavior:"smooth",block:"end"})}},children:[y.map(e=>s("div",{className:"flex min-h-[160px] flex-col justify-between rounded-[16px] bg-white p-[16px] text-[#1D1D1F] desktop:min-h-[192px] desktop:p-[24px] lg-desktop:min-h-[240px] lg-desktop:p-[32px]",children:[s("div",{children:[t(r,{as:"h4",html:e.title,size:2,className:"text-pretty"}),s("div",{className:"mt-[4px] flex items-center",children:[t(f,{className:"size-[24px] xl:size-[18px] [&_path]:size-full",source:"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/20250902-153351.png?v=1756798450"}),t(L,{as:"p",html:e.credits,size:2,className:"ml-[4px] mt-[6px] lg-desktop:text-[18px]"})]})]}),e.handleClick&&!(e.id===p.UploadReceipt&&b.isSuccess)&&!(e.id===p.Activate&&m.isSuccess)&&!(e.id===p.Subscribe&&h.isSuccess)?t(N,{as:e.link?"a":"button",...e.link&&{href:e.link},...e.handleClick&&{onClick:e.handleClick},variant:"primary",loading:e.id===p.Activate&&m.isSendingActivateEmail,size:"lg",className:"mt-[24px] w-fit",children:e.buttonLabel}):t(N,{variant:"primary",size:"lg",className:"mt-[24px] w-fit",disabled:!0,children:e.buttonLabel})]},e.id)),!n&&t("div",{className:"absolute inset-0 min-md:hidden",style:{background:"linear-gradient(180deg, rgba(29, 29, 31, 0) 66.37%, #1D1D1F 100%"}})]}),n?t("button",{className:"mx-auto mt-[12px] block w-fit min-md:hidden",onClick:()=>{v(!1)},children:t(D,{className:"size-[40px] rounded-full bg-[#FFFFFF33] p-[8px]"})}):t(P,{children:t("div",{className:"absolute bottom-0 flex w-full translate-y-1/2 justify-center min-md:hidden",children:t("button",{className:"w-fit",onClick:()=>v(!n),children:t(T,{className:"size-[40px] rounded-full bg-[#FFFFFF33] p-[8px]"})})})})]})]})})};export{J as CreditsWaysToGetCredits};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/components/credits/creditsWaysToGetCredits/index.tsx"],
4
+ "sourcesContent": ["import { Button, Container, Heading, Picture, Text } from '@anker-in/headless-ui'\nimport { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'\nimport { motion } from 'framer-motion'\nimport { useMemo, useState } from 'react'\n\nimport { TaskType, type CreditsWaysToGetCreditsProps } from './type'\nimport { useActions } from './useActions'\nimport { useCreditsContext } from '../context/provider'\nimport { cn } from '../../../helpers/index'\n\nexport const CreditsWaysToGetCredits = ({\n copy,\n activate,\n subscribe,\n uploadReceipt,\n classNames,\n}: CreditsWaysToGetCreditsProps) => {\n const [showMore, setShowMore] = useState(false)\n const { profile } = useCreditsContext()\n const isLogin = !!profile\n\n const { actions } = useActions({ copy, activate, subscribe, uploadReceipt })\n\n const list = useMemo(() => {\n const list = copy.list\n .map(item => {\n if (!actions[item.id as keyof typeof actions]) {\n return undefined\n }\n const { finished, notLogin, notFinished, completed } = actions[item.id as keyof typeof actions]\n let buttonLabel = ''\n let handleClick = undefined\n let link = undefined\n if (!isLogin) {\n buttonLabel = notLogin.buttonLabel\n handleClick = notLogin.handleClick\n } else if (finished) {\n buttonLabel = completed.buttonLabel\n handleClick = undefined\n } else {\n buttonLabel = notFinished.buttonLabel\n handleClick = notFinished.handleClick\n link = (notFinished as { link: string }).link\n }\n return {\n ...item,\n buttonLabel,\n handleClick,\n finished,\n link,\n }\n })\n .filter(Boolean) as {\n title: string\n credits: string\n id: TaskType\n buttonLabel: string\n finished: boolean\n link: string\n handleClick: (() => void) | undefined\n }[]\n\n // \u767B\u5F55\u540E\uFF0C\u4FDD\u7559\u539F\u987A\u5E8F\uFF0C\u5C06\u5DF2\u5B8C\u6210\u7684\u4EFB\u52A1\u653E\u5728\u6700\u540E\n if (isLogin) {\n return list.sort((a, b) => {\n if (a?.finished && !b?.finished) {\n return 1 // a\u5DF2\u5B8C\u6210\uFF0Cb\u672A\u5B8C\u6210\uFF0Ca\u6392\u5728\u540E\u9762\n }\n if (!a?.finished && b?.finished) {\n return -1 // a\u672A\u5B8C\u6210\uFF0Cb\u5DF2\u5B8C\u6210\uFF0Ca\u6392\u5728\u524D\u9762\n }\n return 0 // \u90FD\u5DF2\u5B8C\u6210\u6216\u90FD\u672A\u5B8C\u6210\uFF0C\u4FDD\u6301\u539F\u987A\u5E8F\n })\n } else {\n return list\n }\n }, [actions, copy.list, isLogin])\n\n return (\n <Container id=\"ways-to-get-credits\" className=\" bg-[#F5F5F7] [&>div]:l:!px-0\">\n <div className=\"rounded-[16px] bg-[#1D1D1F] py-[64px] px-[140px] text-white md:px-[16px] l:rounded-none md-l:px-[32px] l-xl:px-[77px]\">\n <Heading as=\"h2\" size={4} html={copy?.title} className=\"text-center l:pl-[16px] l:text-left\" />\n <div className=\"mt-[64px] flex items-center justify-between md:mt-[64px] l:mt-[24px] l:flex-col-reverse l:items-start md-l:mt-[32px]\">\n <div className=\"pl-[16px] l:mt-[40px] desktop:pl-[24px] lg-desktop:pl-[32px]\">\n <Heading size={3} as=\"h3\" html={copy.subtitle} className={classNames?.subtitle} />\n <div className=\"mt-[8px] flex items-center\">\n {copy.creditsIcon?.url && (\n <Picture\n className=\"size-[48px] mr-[8px] stroke-brand xl:size-[30px] [&_path]:stroke-brand\"\n source={copy.creditsIcon.url}\n alt={copy.creditsIcon.alt || 'credits'}\n />\n )}\n <Heading\n html={copy.equalCredits}\n size={4}\n as=\"h3\"\n className={cn('mt-2 text-white md:text-[24px]', classNames?.equalCreditsText)}\n />\n </div>\n </div>\n <Picture className=\"w-full laptop:w-[50%]\" source={copy.mainImage?.url} />\n </div>\n\n <div className=\"relative\">\n <motion.div\n className={cn(\n 'relative mt-[64px] grid grid-cols-3 gap-[16px] overflow-hidden md:mt-[16px] md:grid-cols-1 l:gap-[12px] min-md:!h-auto md-l:mt-[32px] md-l:grid-cols-2'\n )}\n initial={{ height: 512 }}\n animate={{ height: showMore ? 'auto' : 512 }}\n transition={{ duration: 0.3 }}\n onAnimationComplete={() => {\n if (!showMore && window.screen.width < 768) {\n const section = document.getElementById('ways-to-get-credits')\n if (section) {\n section.scrollIntoView({ behavior: 'smooth', block: 'end' })\n }\n }\n }}\n >\n {list.map(item => (\n <div\n key={item.id}\n className=\"flex min-h-[160px] flex-col justify-between rounded-[16px] bg-white p-[16px] text-[#1D1D1F] desktop:min-h-[192px] desktop:p-[24px] lg-desktop:min-h-[240px] lg-desktop:p-[32px]\"\n >\n <div>\n <Heading as=\"h4\" html={item.title} size={2} className=\"text-pretty\" />\n <div className=\"mt-[4px] flex items-center\">\n <Picture\n className=\"size-[24px] xl:size-[18px] [&_path]:size-full\"\n source=\"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/20250902-153351.png?v=1756798450\"\n />\n <Text as=\"p\" html={item.credits} size={2} className=\"ml-[4px] mt-[6px] lg-desktop:text-[18px]\" />\n </div>\n </div>\n\n {item.handleClick &&\n !(item.id === TaskType.UploadReceipt && uploadReceipt.isSuccess) &&\n !(item.id === TaskType.Activate && activate.isSuccess) &&\n !(item.id === TaskType.Subscribe && subscribe.isSuccess) ? (\n <Button\n as={item.link ? 'a' : 'button'}\n {...(item.link && { href: item.link })}\n {...(item.handleClick && { onClick: item.handleClick })}\n variant=\"primary\"\n loading={item.id === TaskType.Activate && activate.isSendingActivateEmail}\n size=\"lg\"\n className=\"mt-[24px] w-fit\"\n >\n {item.buttonLabel}\n </Button>\n ) : (\n <Button variant=\"primary\" size=\"lg\" className=\"mt-[24px] w-fit\" disabled>\n {item.buttonLabel}\n </Button>\n )}\n </div>\n ))}\n {!showMore && (\n <div\n className=\"absolute inset-0 min-md:hidden\"\n style={{ background: 'linear-gradient(180deg, rgba(29, 29, 31, 0) 66.37%, #1D1D1F 100%' }}\n ></div>\n )}\n </motion.div>\n {showMore ? (\n <button\n className=\"mx-auto mt-[12px] block w-fit min-md:hidden\"\n onClick={() => {\n setShowMore(false)\n }}\n >\n <ChevronUpIcon className=\"size-[40px] rounded-full bg-[#FFFFFF33] p-[8px]\"></ChevronUpIcon>\n </button>\n ) : (\n <>\n <div className=\"absolute bottom-0 flex w-full translate-y-1/2 justify-center min-md:hidden\">\n <button className=\"w-fit\" onClick={() => setShowMore(!showMore)}>\n <ChevronDownIcon className=\"size-[40px] rounded-full bg-[#FFFFFF33] p-[8px]\"></ChevronDownIcon>\n </button>\n </div>\n </>\n )}\n </div>\n </div>\n </Container>\n )\n}\n"],
5
+ "mappings": "AAiFQ,OA+FI,YAAAA,EA/FJ,OAAAC,EAII,QAAAC,MAJJ,oBAjFR,OAAS,UAAAC,EAAQ,aAAAC,EAAW,WAAAC,EAAS,WAAAC,EAAS,QAAAC,MAAY,wBAC1D,OAAS,mBAAAC,EAAiB,iBAAAC,MAAqB,8BAC/C,OAAS,UAAAC,MAAc,gBACvB,OAAS,WAAAC,EAAS,YAAAC,MAAgB,QAElC,OAAS,YAAAC,MAAmD,SAC5D,OAAS,cAAAC,MAAkB,eAC3B,OAAS,qBAAAC,MAAyB,sBAClC,OAAS,MAAAC,MAAU,yBAEZ,MAAMC,EAA0B,CAAC,CACtC,KAAAC,EACA,SAAAC,EACA,UAAAC,EACA,cAAAC,EACA,WAAAC,CACF,IAAoC,CAClC,KAAM,CAACC,EAAUC,CAAW,EAAIZ,EAAS,EAAK,EACxC,CAAE,QAAAa,CAAQ,EAAIV,EAAkB,EAChCW,EAAU,CAAC,CAACD,EAEZ,CAAE,QAAAE,CAAQ,EAAIb,EAAW,CAAE,KAAAI,EAAM,SAAAC,EAAU,UAAAC,EAAW,cAAAC,CAAc,CAAC,EAErEO,EAAOjB,EAAQ,IAAM,CACzB,MAAMiB,EAAOV,EAAK,KACf,IAAIW,GAAQ,CACX,GAAI,CAACF,EAAQE,EAAK,EAA0B,EAC1C,OAEF,KAAM,CAAE,SAAAC,EAAU,SAAAC,EAAU,YAAAC,EAAa,UAAAC,CAAU,EAAIN,EAAQE,EAAK,EAA0B,EAC9F,IAAIK,EAAc,GACdC,EACA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AAC,UACC,UAAU,8CACV,QAAS,IAAM,CACbuB,EAAY,EAAK,CACnB,EAEA,SAAAvB,EAACQ,EAAA,CAAc,UAAU,kDAAkD,EAC7E,EAEAR,EAAAD,EAAA,CACE,SAAAC,EAAC,OAAI,UAAU,6EACb,SAAAA,EAAC,UAAO,UAAU,QAAQ,QAAS,IAAMuB,EAAY,CAACD,CAAQ,EAC5D,SAAAtB,EAACO,EAAA,CAAgB,UAAU,kDAAkD,EAC/E,EACF,EACF,GAEJ,GACF,EACF,CAEJ",
6
+ "names": ["Fragment", "jsx", "jsxs", "Button", "Container", "Heading", "Picture", "Text", "ChevronDownIcon", "ChevronUpIcon", "motion", "useMemo", "useState", "TaskType", "useActions", "useCreditsContext", "cn", "CreditsWaysToGetCredits", "copy", "activate", "subscribe", "uploadReceipt", "classNames", "showMore", "setShowMore", "profile", "isLogin", "actions", "list", "item", "finished", "notLogin", "notFinished", "completed", "buttonLabel", "handleClick", "link", "a", "b", "section"]
7
+ }
@@ -0,0 +1,2 @@
1
+ var t=(e=>(e.Activate="activate",e.Subscribe="subscribe",e.CompleteProfile="completeProfile",e.FirstPurchase="firstPurchase",e.UploadReceipt="uploadReceipt",e.Shop="shop",e))(t||{});export{t as TaskType};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/components/credits/creditsWaysToGetCredits/type.ts"],
4
+ "sourcesContent": ["import type { ReceiptCopy } from '../modal/creditsUploadReceiptModal'\n\nexport type BenefitItem = {\n title: string\n credits: string\n id: string\n}\n\nexport type WaysToGetCreditsCopy = {\n title: string\n subtitle: string\n equalCredits: string\n musicIcon: string\n list: BenefitItem[]\n mainImage: {\n url: string\n alt: string\n }\n joinNow: string\n activate: string\n completed: string\n completeProfile: string\n makeFirstPurchase: string\n goShopLink: string\n uploadReceipt: string\n shopNow: string\n subscribe: string\n sendEmailSuccess: string\n creditsIcon: {\n url: string\n alt: string\n }\n receipt: ReceiptCopy\n}\n\nexport enum TaskType {\n Activate = 'activate',\n Subscribe = 'subscribe',\n CompleteProfile = 'completeProfile',\n FirstPurchase = 'firstPurchase',\n UploadReceipt = 'uploadReceipt',\n Shop = 'shop',\n}\n\nexport type CreditsWaysToGetCreditsProps = {\n copy: WaysToGetCreditsCopy\n classNames?: {\n equalCreditsText?: string\n subtitle?: string\n }\n activate: {\n openAuthCodePopup: () => void\n isSuccess: boolean\n isSendingActivateEmail: boolean\n }\n subscribe: {\n openSubscribePopup: () => void\n isSuccess: boolean\n }\n uploadReceipt: {\n openUploadReceiptPopup: () => void\n isSuccess: boolean\n }\n}\n"],
5
+ "mappings": "AAmCO,IAAKA,OACVA,EAAA,SAAW,WACXA,EAAA,UAAY,YACZA,EAAA,gBAAkB,kBAClBA,EAAA,cAAgB,gBAChBA,EAAA,cAAgB,gBAChBA,EAAA,KAAO,OANGA,OAAA",
6
+ "names": ["TaskType"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{TaskType as t}from"./type";import{useCreditsContext as C}from"../context/provider";import{useMemo as u}from"react";import P from"../context/hooks/useReceiptUploaded";import{useFirstPurchaseFinished as g}from"../context/hooks/useFirstPurchaseFinished";import{useSubscribed as v}from"../context/hooks/useSubscribed";import{useHeadlessContext as F}from"@anker-in/lib";import{gaTrack as w}from"../../../helpers/track";const G=({copy:e,subscribe:c,uploadReceipt:m,activate:p,gaParameters:n})=>{const{openSignUpPopup:a,gtm:h,profile:o}=C(),l=v(),s=g(),r=P(),{appName:k,passportUrl:b}=F();console.log("passportUrl",b);const d=u(()=>(o?.first_name||o?.last_name)&&o?.phone_number&&o?.dob,[o]);return u(()=>{const i=({buttonName:f,id:N,callback:L})=>{w({event:"ga4Event",event_name:"lp_button",member_active_status:o?.activated?"active":"not active",event_parameters:{page_group:h.pageGroup,position:n?.position||e.title,button_name:f,info:N}}),L()};return{actions:{[t.Activate]:{finished:o?.activated,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:a,id:t.Activate})},notFinished:{buttonLabel:e?.activate,handleClick:()=>i({buttonName:e?.activate,callback:()=>p.openAuthCodePopup(),id:t.Activate})},completed:{buttonLabel:e?.completed}},[t.Subscribe]:{finished:l,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:a,id:t.Subscribe})},notFinished:{buttonLabel:e?.subscribe,handleClick:()=>i({buttonName:e?.subscribe,callback:()=>c.openSubscribePopup(),id:t.Subscribe})},completed:{buttonLabel:e?.completed}},[t.CompleteProfile]:{finished:d,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:a,id:t.CompleteProfile})},notFinished:{buttonLabel:e?.completeProfile,link:`${b}/account/profile?app=${k}`,handleClick:()=>i({buttonName:e?.completeProfile,callback:()=>{},id:t.CompleteProfile})},completed:{buttonLabel:e?.completed}},[t.FirstPurchase]:{finished:s,notLogin:{buttonLabel:e?.makeFirstPurchase,handleClick:()=>i({buttonName:e?.makeFirstPurchase,callback:a,id:t.FirstPurchase})},notFinished:{buttonLabel:e?.makeFirstPurchase,link:e?.goShopLink,handleClick:()=>i({buttonName:e?.makeFirstPurchase,callback:()=>{},id:t.FirstPurchase})},completed:{buttonLabel:e?.completed}},[t.UploadReceipt]:{finished:r,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:a,id:t.UploadReceipt})},notFinished:{buttonLabel:e?.uploadReceipt,handleClick:()=>i({buttonName:e?.uploadReceipt,callback:()=>m.openUploadReceiptPopup(),id:t.UploadReceipt})},completed:{buttonLabel:e?.completed}},[t.Shop]:{finished:!1,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:a,id:t.Shop})},notFinished:{buttonLabel:e?.shopNow,link:e?.goShopLink,handleClick:()=>i({buttonName:e?.shopNow,callback:()=>{},id:t.Shop})},completed:{buttonLabel:e?.completed}}}}},[o?.activated,e?.joinNow,e?.activate,e?.completed,e?.subscribe,e?.completeProfile,e?.makeFirstPurchase,e?.uploadReceipt,e?.shopNow,e.title,e?.goShopLink,l,d,s,r,n?.position,a])};export{G as useActions};
2
+ //# sourceMappingURL=useActions.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/components/credits/creditsWaysToGetCredits/useActions.ts"],
4
+ "sourcesContent": ["import { TaskType } from './type'\nimport { useCreditsContext } from '../context/provider'\nimport { useMemo } from 'react'\nimport useReceiptUploaded from '../context/hooks/useReceiptUploaded'\nimport { useFirstPurchaseFinished } from '../context/hooks/useFirstPurchaseFinished'\nimport { useSubscribed } from '../context/hooks/useSubscribed'\nimport type { CreditsWaysToGetCreditsProps } from './type'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { gaTrack } from '../../../helpers/track'\n\nexport const useActions = ({\n copy,\n subscribe,\n uploadReceipt,\n activate,\n gaParameters,\n}: CreditsWaysToGetCreditsProps & {\n gaParameters?: {\n position: string\n }\n}) => {\n const { openSignUpPopup, gtm, profile } = useCreditsContext()\n const isSubscribed = useSubscribed()\n const firstPurchaseFinished = useFirstPurchaseFinished()\n const uploadedReceipt = useReceiptUploaded()\n const { appName, passportUrl } = useHeadlessContext()\n console.log('passportUrl', passportUrl)\n\n const profileCompleted = useMemo(() => {\n return (profile?.first_name || profile?.last_name) && profile?.phone_number && profile?.dob\n }, [profile])\n\n return useMemo(() => {\n const handleClickWithTrack = ({\n buttonName,\n id,\n callback,\n }: {\n buttonName: string\n id?: string\n callback: () => void\n }) => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: gaParameters?.position || copy.title,\n button_name: buttonName,\n info: id,\n },\n })\n callback()\n }\n return {\n actions: {\n [TaskType.Activate]: {\n finished: profile?.activated,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Activate }),\n },\n notFinished: {\n buttonLabel: copy?.activate,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.activate,\n callback: () => activate.openAuthCodePopup(),\n id: TaskType.Activate,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.Subscribe]: {\n finished: isSubscribed,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Subscribe }),\n },\n notFinished: {\n buttonLabel: copy?.subscribe,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.subscribe,\n callback: () => subscribe.openSubscribePopup(),\n id: TaskType.Subscribe,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.CompleteProfile]: {\n finished: profileCompleted,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.CompleteProfile,\n }),\n },\n notFinished: {\n buttonLabel: copy?.completeProfile,\n link: `${passportUrl}/account/profile?app=${appName}`,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.completeProfile,\n callback: () => {},\n id: TaskType.CompleteProfile,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.FirstPurchase]: {\n finished: firstPurchaseFinished,\n notLogin: {\n buttonLabel: copy?.makeFirstPurchase,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.makeFirstPurchase,\n callback: openSignUpPopup,\n id: TaskType.FirstPurchase,\n }),\n },\n notFinished: {\n buttonLabel: copy?.makeFirstPurchase,\n link: copy?.goShopLink,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.makeFirstPurchase,\n callback: () => {},\n id: TaskType.FirstPurchase,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.UploadReceipt]: {\n finished: uploadedReceipt,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.UploadReceipt,\n }),\n },\n notFinished: {\n buttonLabel: copy?.uploadReceipt,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.uploadReceipt,\n callback: () => uploadReceipt.openUploadReceiptPopup(),\n id: TaskType.UploadReceipt,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.Shop]: {\n finished: false,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.Shop,\n }),\n },\n notFinished: {\n buttonLabel: copy?.shopNow,\n link: copy?.goShopLink,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.shopNow,\n callback: () => {},\n id: TaskType.Shop,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n },\n }\n }, [\n profile?.activated,\n copy?.joinNow,\n copy?.activate,\n copy?.completed,\n copy?.subscribe,\n copy?.completeProfile,\n copy?.makeFirstPurchase,\n copy?.uploadReceipt,\n copy?.shopNow,\n copy.title,\n copy?.goShopLink,\n isSubscribed,\n profileCompleted,\n firstPurchaseFinished,\n uploadedReceipt,\n gaParameters?.position,\n openSignUpPopup,\n ])\n}\n"],
5
+ "mappings": "AAAA,OAAS,YAAAA,MAAgB,SACzB,OAAS,qBAAAC,MAAyB,sBAClC,OAAS,WAAAC,MAAe,QACxB,OAAOC,MAAwB,sCAC/B,OAAS,4BAAAC,MAAgC,4CACzC,OAAS,iBAAAC,MAAqB,iCAE9B,OAAS,sBAAAC,MAA0B,gBACnC,OAAS,WAAAC,MAAe,yBAEjB,MAAMC,EAAa,CAAC,CACzB,KAAAC,EACA,UAAAC,EACA,cAAAC,EACA,SAAAC,EACA,aAAAC,CACF,IAIM,CACJ,KAAM,CAAE,gBAAAC,EAAiB,IAAAC,EAAK,QA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aS,GAAM,QACnB,YAAa,IACXc,EAAqB,CACnB,WAAYd,GAAM,QAClB,SAAUK,EACV,GAAId,EAAS,IACf,CAAC,CACL,EACA,YAAa,CACX,YAAaS,GAAM,QACnB,KAAMA,GAAM,WACZ,YAAa,IACXc,EAAqB,CACnB,WAAYd,GAAM,QAClB,SAAU,IAAM,CAAC,EACjB,GAAIT,EAAS,IACf,CAAC,CACL,EACA,UAAW,CACT,YAAaS,GAAM,SACrB,CACF,CACF,CACF,CACF,EAAG,CACDO,GAAS,UACTP,GAAM,QACNA,GAAM,SACNA,GAAM,UACNA,GAAM,UACNA,GAAM,gBACNA,GAAM,kBACNA,GAAM,cACNA,GAAM,QACNA,EAAK,MACLA,GAAM,WACNQ,EACAK,EACAJ,EACAC,EACAN,GAAc,SACdC,CACF,CAAC,CACH",
6
+ "names": ["TaskType", "useCreditsContext", "useMemo", "useReceiptUploaded", "useFirstPurchaseFinished", "useSubscribed", "useHeadlessContext", "gaTrack", "useActions", "copy", "subscribe", "uploadReceipt", "activate", "gaParameters", "openSignUpPopup", "gtm", "profile", "isSubscribed", "firstPurchaseFinished", "uploadedReceipt", "appName", "passportUrl", "profileCompleted", "handleClickWithTrack", "buttonName", "id", "callback"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{CreditsProvider as t,useCreditsContext as o}from"./context/provider";import{useUploadReceipt as d}from"./context/hooks/useUploadReceipt";import{CreditsUploadReceiptModal as p}from"./modal/creditsUploadReceiptModal";import{CreditsBanner as f}from"./creditsBanner";import{CreditsBenefits as x}from"./creditsBenefits";import{CreditsInfoCard as n}from"./creditsInfoCard";import{CreditsWaysToGetCredits as R}from"./creditsWaysToGetCredits";import{CreditsFaq as u}from"./creditsFaq";import{CreditsCash as B}from"./creditsCash";import{CreditsRedeemList as q}from"./creditsRedeemList";export{f as CreditsBanner,x as CreditsBenefits,B as CreditsCash,u as CreditsFaq,n as CreditsInfoCard,t as CreditsProvider,q as CreditsRedeemList,p as CreditsUploadReceiptModal,R as CreditsWaysToGetCredits,o as useCreditsContext,d as useCreditsUploadReceipt};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/components/credits/index.ts"],
4
+ "sourcesContent": ["export { CreditsProvider, useCreditsContext } from './context/provider'\n\nexport { useUploadReceipt as useCreditsUploadReceipt } from './context/hooks/useUploadReceipt'\nexport { CreditsUploadReceiptModal } from './modal/creditsUploadReceiptModal'\nexport { CreditsBanner } from './creditsBanner'\nexport { CreditsBenefits } from './creditsBenefits'\nexport { CreditsInfoCard } from './creditsInfoCard'\nexport { CreditsWaysToGetCredits } from './creditsWaysToGetCredits'\nexport { CreditsFaq } from './creditsFaq'\nexport { CreditsCash } from './creditsCash'\nexport { CreditsRedeemList } from './creditsRedeemList'\n"],
5
+ "mappings": "AAAA,OAAS,mBAAAA,EAAiB,qBAAAC,MAAyB,qBAEnD,OAA6B,oBAApBC,MAAmD,mCAC5D,OAAS,6BAAAC,MAAiC,oCAC1C,OAAS,iBAAAC,MAAqB,kBAC9B,OAAS,mBAAAC,MAAuB,oBAChC,OAAS,mBAAAC,MAAuB,oBAChC,OAAS,2BAAAC,MAA+B,4BACxC,OAAS,cAAAC,MAAkB,eAC3B,OAAS,eAAAC,MAAmB,gBAC5B,OAAS,qBAAAC,MAAyB",
6
+ "names": ["CreditsProvider", "useCreditsContext", "useUploadReceipt", "CreditsUploadReceiptModal", "CreditsBanner", "CreditsBenefits", "CreditsInfoCard", "CreditsWaysToGetCredits", "CreditsFaq", "CreditsCash", "CreditsRedeemList"]
7
+ }
@@ -0,0 +1,2 @@
1
+ import{jsx as i,jsxs as l}from"react/jsx-runtime";import{Tabs as E,TabsList as $,TabsTrigger as z,Picture as H}from"@anker-in/headless-ui";import P from"classnames";import K from"copy-to-clipboard";import V from"dayjs";import{useCallback as M,useMemo as p,useState as c}from"react";import{ApprovalStatus as m,AlpcConsumeType as n,RewardType as t}from"../context/const";import{CreditsModalContainer as q}from"./modalContainer";import B from"./tip";import G from"./loadingDots";import w from"../context/hooks/useMyRewards";function J({data:o,...a}){const[r,S]=c(n.Coupon),[d,R]=c(1),[u,F]=c(1),[h,g]=c(-1),_=p(()=>{const e=[];return o.couponTab&&e.push({title:o.couponTab,type:n.Coupon}),o.productTab&&e.push({title:o.productTab,type:n.Product}),e},[o.couponTab,o.productTab]),A=p(()=>({page:a.isOpen?u:0,pageSize:1e3,consumeType:n.Product}),[a.isOpen,u]),D=p(()=>({page:a.isOpen?d:0,pageSize:1e3,consumeType:n.Coupon}),[a.isOpen,d]),{myRewards:v=[],canNext:b,isLoading:O}=w(D),{myRewards:y=[],canNext:x,isLoading:I}=w(A),C=p(()=>r===n.Coupon?v.map(e=>({title:e.goods_title,value:e.consume_credits,type:t.Received,date:new Date(e.create_time*1e3),couponCode:e.coupon_code,orderNumber:""})):r===n.Product?y.map(e=>{let s=t.Pending;return e.fulfillment_status&&e.fulfillment_status!=="null"?e.fulfillment_status==="fulfilled"?s=t.Fulfilled:s=t.Unfulfilled:e.approval_status===m.Success||e.approval_status===m.DoubleConfirm?s=t.ApproveSuccess:e.approval_status===m.Failed&&(s=t.Failed),{title:e.goods_title,value:e.consume_credits,type:s,date:new Date(e.create_time*1e3),orderNumber:e.order_number,couponCode:""}}):[],[r,y,v]),T=p(()=>r===n.Coupon?b:r===n.Product?x:!1,[r,b,x]),k=p(()=>({[t.Received]:o.receivedLabel,[t.Pending]:o.pendingLabel,[t.ApproveFail]:o.failedLabel,[t.ApproveSuccess]:o.approveSuccessLabel,[t.Unfulfilled]:o.unfulfilledLabel,[t.Fulfilled]:o.fulfilledLabel,[t.Failed]:o.failedLabel}),[o]),N=p(()=>({[t.Received]:"",[t.Pending]:o.pendingTip,[t.ApproveFail]:"",[t.ApproveSuccess]:o.confirmedTip,[t.Unfulfilled]:o.processingTip,[t.Fulfilled]:o.ShippedTip,[t.Failed]:""}),[o]),U=p(()=>({[t.Received]:"#52C41A",[t.Pending]:"#999",[t.ApproveFail]:"#F84D4F",[t.ApproveSuccess]:"#999",[t.Unfulfilled]:"#999",[t.Fulfilled]:"#999",[t.Failed]:"#F84D4F"}),[]),Y=M(()=>{T&&(r===n.Coupon?R(d+1):r===n.Product&&F(u+1))},[r,u,d,T]),j=M((e,s)=>{g(s),K(e),setTimeout(()=>{g(-1)},2e3)},[]),L=r===n.Coupon?O:I;return l(q,{title:o.title,className:P("h-[800px] w-[640px]"),useAnimation:!0,animationClassName:"md:translate-y-[100vh]",scrollClassName:"md:mb-0",...a,onScrollEnd:Y,children:[i("div",{className:"",children:i(E,{align:"left",shape:"rounded",value:r.toString(),onValueChange:e=>{S(Number(e))},children:i($,{children:_.map(e=>i(z,{value:e.type.toString(),children:e.title},e.type))})})}),L&&i("div",{className:"flex h-full flex-col items-center justify-center",children:i(G,{})}),!L&&i("div",{className:"mt-[24px] overflow-auto overscroll-contain",children:C.length>0?i("div",{className:"grid gap-[18px] md:gap-[12px]",children:C.map((e,s)=>l("div",{className:"grid gap-[8px]",children:[e?.orderNumber&&l("div",{className:"text-[15px] font-semibold leading-[1.4] text-[#777]",children:[o.orderNumberLabel,": ",e.orderNumber]}),l("div",{className:"flex items-center justify-between rounded-[8px] bg-[#f7f8f9] px-[16px] py-[20px]",children:[l("div",{className:"grid gap-[4px]",children:[i("div",{className:"text-[16px] font-bold leading-[1.4]",children:e.title}),l("div",{className:"text-[14px] font-semibold text-[#999]",children:[o.valueLabel,": ",e.value," ",o?.pointUnit]}),l("div",{className:"text-[14px] font-semibold text-[#999]",children:[e?.couponCode?`${o?.code||"Code"}: ${e.couponCode} `:"",e?.couponCode&&i("span",{className:"cursor-pointer text-[14px] font-semibold text-brand underline",onClick:()=>{j(e.couponCode,s)},role:"button",tabIndex:0,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&f.preventDefault()},children:h===s?o?.copied||"COPIED":o?.copy||"COPY"})]})]}),l("div",{className:"grid gap-[4px] text-right",children:[l("div",{className:P("flex items-center justify-end text-[16px] font-bold leading-[1.4]",`text-[${U[e.type]}]`),children:[i("span",{children:k[e.type]}),N[e.type]&&i(B,{info:N[e.type],index:s})]}),i("div",{className:"text-[14px] font-semibold text-[#999]",children:V(e.date).format("YYYY-MM-DD HH:mm").toString()})]})]})]},s))}):l("div",{className:"flex h-full flex-col items-center justify-center",children:[i(H,{className:"mb-[12px] w-[160px]",source:o?.emptyListImage?.url,alt:o?.emptyListImage?.alt||"empty list image"}),i("div",{className:"text-[16px] font-semibold leading-[1.4]",children:o?.emptyListLabel})]})})]})}var re=J;export{re as default};
2
+ //# sourceMappingURL=MyRewardsModal.js.map