@anker-in/campaign-ui 0.2.10-beta.1 → 0.2.10-beta.10

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 (465) hide show
  1. package/dist/cjs/components/chat/chat-context.d.ts +101 -0
  2. package/dist/cjs/components/chat/{chatContext.js → chat-context.js} +1 -1
  3. package/dist/cjs/components/chat/{chatContext.js.map → chat-context.js.map} +2 -2
  4. package/dist/cjs/components/credits/context/hooks/useActivities.js +1 -1
  5. package/dist/cjs/components/credits/context/hooks/useActivities.js.map +3 -3
  6. package/dist/cjs/components/credits/context/hooks/useMyRewards.js +1 -1
  7. package/dist/cjs/components/credits/context/hooks/useMyRewards.js.map +3 -3
  8. package/dist/cjs/components/credits/context/hooks/useRedeemAndBuy.d.ts +1 -1
  9. package/dist/cjs/components/credits/context/hooks/useRedeemAndBuy.js +1 -1
  10. package/dist/cjs/components/credits/context/hooks/useRedeemAndBuy.js.map +3 -3
  11. package/dist/cjs/components/credits/context/hooks/useRedeemCoupon.js +1 -1
  12. package/dist/cjs/components/credits/context/hooks/useRedeemCoupon.js.map +3 -3
  13. package/dist/cjs/components/credits/context/hooks/useRedeemProduct.js +1 -1
  14. package/dist/cjs/components/credits/context/hooks/useRedeemProduct.js.map +3 -3
  15. package/dist/cjs/components/credits/context/hooks/useRedeemableList.js +1 -1
  16. package/dist/cjs/components/credits/context/hooks/useRedeemableList.js.map +3 -3
  17. package/dist/cjs/components/credits/context/hooks/useSendEmailValidation.js +1 -1
  18. package/dist/cjs/components/credits/context/hooks/useSendEmailValidation.js.map +3 -3
  19. package/dist/cjs/components/credits/context/hooks/useSubscribed.js +1 -1
  20. package/dist/cjs/components/credits/context/hooks/useSubscribed.js.map +3 -3
  21. package/dist/cjs/components/credits/credits-banner/index.d.ts +23 -0
  22. package/dist/cjs/components/credits/{creditsBanner → credits-banner}/index.js.map +2 -2
  23. package/dist/cjs/components/credits/credits-benefits/benefitItem.d.ts +19 -0
  24. package/dist/cjs/components/credits/{creditsBenefits → credits-benefits}/benefitItem.js.map +1 -1
  25. package/dist/cjs/components/credits/credits-benefits/iconInfo.d.ts +2 -0
  26. package/dist/cjs/components/credits/{creditsBenefits → credits-benefits}/iconInfo.js.map +1 -1
  27. package/dist/cjs/components/credits/credits-benefits/index.d.ts +12 -0
  28. package/dist/cjs/components/credits/{creditsBenefits → credits-benefits}/index.js.map +2 -2
  29. package/dist/cjs/components/credits/credits-cash/RedeemableItem.d.ts +15 -0
  30. package/dist/cjs/components/credits/{creditsCash → credits-cash}/RedeemableItem.js.map +1 -1
  31. package/dist/cjs/components/credits/credits-cash/index.d.ts +13 -0
  32. package/dist/cjs/components/credits/credits-cash/index.js +2 -0
  33. package/dist/cjs/components/credits/credits-cash/index.js.map +7 -0
  34. package/dist/cjs/components/credits/credits-cash/type.d.ts +47 -0
  35. package/dist/cjs/components/credits/credits-cash/type.js.map +7 -0
  36. package/dist/cjs/components/credits/credits-faq/faq-item/FaqItem.d.ts +13 -0
  37. package/dist/cjs/components/credits/credits-faq/faq-item/faq-item.d.ts +13 -0
  38. package/dist/cjs/components/credits/{creditsFaq/faqItem/FaqItem.js → credits-faq/faq-item/faq-item.js} +1 -1
  39. package/dist/cjs/components/credits/{creditsFaq/faqItem/FaqItem.js.map → credits-faq/faq-item/faq-item.js.map} +2 -2
  40. package/dist/cjs/components/credits/credits-faq/faqItem/FaqItem.d.ts +13 -0
  41. package/dist/cjs/components/credits/credits-faq/index.d.ts +16 -0
  42. package/dist/cjs/components/credits/{creditsFaq → credits-faq}/index.js.map +2 -2
  43. package/dist/cjs/components/credits/credits-info-card/index.d.ts +20 -0
  44. package/dist/cjs/components/credits/{creditsInfoCard → credits-info-card}/index.js.map +2 -2
  45. package/dist/cjs/components/credits/credits-redeem-list/AddressForm/Input.d.ts +13 -0
  46. package/dist/cjs/components/credits/credits-redeem-list/AddressForm/country-select.d.ts +14 -0
  47. package/dist/cjs/components/credits/credits-redeem-list/AddressForm/form-item.d.ts +6 -0
  48. package/dist/cjs/components/credits/credits-redeem-list/AddressForm/index.d.ts +2 -0
  49. package/dist/cjs/components/credits/credits-redeem-list/AddressForm/state-select.d.ts +15 -0
  50. package/dist/cjs/components/credits/credits-redeem-list/AddressForm/type.d.ts +26 -0
  51. package/dist/cjs/components/credits/credits-redeem-list/RedeemCouponModal.d.ts +9 -0
  52. package/dist/cjs/components/credits/credits-redeem-list/RedeemProductModal/Address.d.ts +20 -0
  53. package/dist/cjs/components/credits/credits-redeem-list/RedeemProductModal/Error.d.ts +8 -0
  54. package/dist/cjs/components/credits/credits-redeem-list/RedeemProductModal/Init.d.ts +11 -0
  55. package/dist/cjs/components/credits/credits-redeem-list/RedeemProductModal/ProductInfo.d.ts +8 -0
  56. package/dist/cjs/components/credits/credits-redeem-list/RedeemProductModal/Success.d.ts +13 -0
  57. package/dist/cjs/components/credits/credits-redeem-list/RedeemProductModal/index.d.ts +11 -0
  58. package/dist/cjs/components/credits/credits-redeem-list/RedeemableItem.d.ts +9 -0
  59. package/dist/cjs/components/credits/{creditsRedeemList → credits-redeem-list}/RedeemableItem.js.map +1 -1
  60. package/dist/cjs/components/credits/credits-redeem-list/address-form/Input.d.ts +13 -0
  61. package/dist/cjs/components/credits/{creditsRedeemList/AddressForm → credits-redeem-list/address-form}/Input.js.map +1 -1
  62. package/dist/cjs/components/credits/credits-redeem-list/address-form/country-select.d.ts +14 -0
  63. package/dist/cjs/components/credits/{creditsRedeemList/AddressForm/CountrySelect.js → credits-redeem-list/address-form/country-select.js} +1 -1
  64. package/dist/cjs/components/credits/{creditsRedeemList/AddressForm/CountrySelect.js.map → credits-redeem-list/address-form/country-select.js.map} +2 -2
  65. package/dist/cjs/components/credits/credits-redeem-list/address-form/form-item.d.ts +6 -0
  66. package/dist/cjs/components/credits/{creditsRedeemList/AddressForm/FormItem.js → credits-redeem-list/address-form/form-item.js} +1 -1
  67. package/dist/cjs/components/credits/{creditsRedeemList/AddressForm/FormItem.js.map → credits-redeem-list/address-form/form-item.js.map} +2 -2
  68. package/dist/cjs/components/credits/credits-redeem-list/address-form/index.d.ts +2 -0
  69. package/dist/cjs/components/credits/credits-redeem-list/address-form/index.js +2 -0
  70. package/dist/cjs/components/credits/credits-redeem-list/address-form/index.js.map +7 -0
  71. package/dist/cjs/components/credits/credits-redeem-list/address-form/state-select.d.ts +15 -0
  72. package/dist/cjs/components/credits/{creditsRedeemList/AddressForm/StateSelect.js → credits-redeem-list/address-form/state-select.js} +1 -1
  73. package/dist/cjs/components/credits/{creditsRedeemList/AddressForm/StateSelect.js.map → credits-redeem-list/address-form/state-select.js.map} +2 -2
  74. package/dist/cjs/components/credits/credits-redeem-list/address-form/type.d.ts +26 -0
  75. package/dist/cjs/components/credits/{creditsRedeemList/AddressForm → credits-redeem-list/address-form}/type.js.map +1 -1
  76. package/dist/cjs/components/credits/credits-redeem-list/index.d.ts +13 -0
  77. package/dist/cjs/components/credits/credits-redeem-list/index.js +2 -0
  78. package/dist/cjs/components/credits/credits-redeem-list/index.js.map +7 -0
  79. package/dist/cjs/components/credits/credits-redeem-list/redeem-coupon-modal.d.ts +9 -0
  80. package/dist/cjs/components/credits/credits-redeem-list/redeem-coupon-modal.js +2 -0
  81. package/dist/cjs/components/credits/credits-redeem-list/redeem-coupon-modal.js.map +7 -0
  82. package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/Address.d.ts +20 -0
  83. package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/Address.js +2 -0
  84. package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/Address.js.map +7 -0
  85. package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/Error.d.ts +8 -0
  86. package/dist/cjs/components/credits/{creditsRedeemList/RedeemProductModal → credits-redeem-list/redeem-product-modal}/Error.js.map +1 -1
  87. package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/Init.d.ts +11 -0
  88. package/dist/cjs/components/credits/{creditsRedeemList/RedeemProductModal → credits-redeem-list/redeem-product-modal}/Init.js.map +1 -1
  89. package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/ProductInfo.d.ts +8 -0
  90. package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/ProductInfo.js +2 -0
  91. package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/ProductInfo.js.map +7 -0
  92. package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/Success.d.ts +13 -0
  93. package/dist/cjs/components/credits/{creditsRedeemList/RedeemProductModal → credits-redeem-list/redeem-product-modal}/Success.js.map +1 -1
  94. package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/index.d.ts +11 -0
  95. package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/index.js +2 -0
  96. package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/index.js.map +7 -0
  97. package/dist/cjs/components/credits/credits-redeem-list/type.d.ts +77 -0
  98. package/dist/cjs/components/credits/{creditsRedeemList → credits-redeem-list}/type.js.map +1 -1
  99. package/dist/cjs/components/credits/credits-ways-to-get-credits/index.d.ts +2 -0
  100. package/dist/cjs/components/credits/{creditsWaysToGetCredits → credits-ways-to-get-credits}/index.js.map +2 -2
  101. package/dist/cjs/components/credits/credits-ways-to-get-credits/type.d.ts +60 -0
  102. package/dist/cjs/components/credits/{creditsWaysToGetCredits → credits-ways-to-get-credits}/type.js.map +1 -1
  103. package/dist/cjs/components/credits/credits-ways-to-get-credits/useActions.d.ts +96 -0
  104. package/dist/cjs/components/credits/credits-ways-to-get-credits/useActions.js +2 -0
  105. package/dist/cjs/components/credits/credits-ways-to-get-credits/useActions.js.map +7 -0
  106. package/dist/cjs/components/credits/creditsCash/type.d.ts +1 -1
  107. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/country-select.d.ts +14 -0
  108. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/form-item.d.ts +6 -0
  109. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/state-select.d.ts +15 -0
  110. package/dist/cjs/components/credits/type.d.ts +1 -1
  111. package/dist/cjs/components/credits/type.js.map +1 -1
  112. package/dist/cjs/index.d.ts +1 -6
  113. package/dist/cjs/index.js +726 -1
  114. package/dist/cjs/index.js.map +4 -4
  115. package/dist/cjs/shopify/context/ShopifyProvider.d.ts +1 -1
  116. package/dist/cjs/shopify/context/index.d.ts +1 -0
  117. package/dist/cjs/shopify/context/shopify-provider.d.ts +10 -0
  118. package/dist/cjs/shopify/fetchers/create-cart.d.ts +1 -2
  119. package/dist/cjs/shopify/hooks/index.d.ts +2 -2
  120. package/dist/cjs/shopify/hooks/use-create-cart.d.ts +2 -0
  121. package/dist/cjs/shopify/hooks/use-products-by-handles.d.ts +4 -0
  122. package/dist/cjs/shopify/hooks/useProductsByHandles.d.ts +1 -1
  123. package/dist/cjs/shopify/types/index.d.ts +2 -0
  124. package/dist/cjs/tsconfig.tsbuildinfo +1 -0
  125. package/dist/esm/components/chat/chat-context.d.ts +101 -0
  126. package/dist/esm/components/chat/chat-context.js +2 -0
  127. package/dist/esm/components/chat/chat-context.js.map +7 -0
  128. package/dist/esm/components/credits/context/hooks/useActivities.js +1 -1
  129. package/dist/esm/components/credits/context/hooks/useActivities.js.map +2 -2
  130. package/dist/esm/components/credits/context/hooks/useAddressValidate.js +1 -1
  131. package/dist/esm/components/credits/context/hooks/useAddressValidate.js.map +3 -3
  132. package/dist/esm/components/credits/context/hooks/useAlpcFetch.js +1 -1
  133. package/dist/esm/components/credits/context/hooks/useAlpcFetch.js.map +3 -3
  134. package/dist/esm/components/credits/context/hooks/useCountries.js +1 -1
  135. package/dist/esm/components/credits/context/hooks/useCountries.js.map +3 -3
  136. package/dist/esm/components/credits/context/hooks/useMyRewards.js +1 -1
  137. package/dist/esm/components/credits/context/hooks/useMyRewards.js.map +2 -2
  138. package/dist/esm/components/credits/context/hooks/useRedeemAndBuy.d.ts +1 -1
  139. package/dist/esm/components/credits/context/hooks/useRedeemAndBuy.js +1 -1
  140. package/dist/esm/components/credits/context/hooks/useRedeemAndBuy.js.map +2 -2
  141. package/dist/esm/components/credits/context/hooks/useRedeemCoupon.js +1 -1
  142. package/dist/esm/components/credits/context/hooks/useRedeemCoupon.js.map +2 -2
  143. package/dist/esm/components/credits/context/hooks/useRedeemProduct.js +1 -1
  144. package/dist/esm/components/credits/context/hooks/useRedeemProduct.js.map +2 -2
  145. package/dist/esm/components/credits/context/hooks/useRedeemableList.js +1 -1
  146. package/dist/esm/components/credits/context/hooks/useRedeemableList.js.map +2 -2
  147. package/dist/esm/components/credits/context/hooks/useSendEmailValidation.js +1 -1
  148. package/dist/esm/components/credits/context/hooks/useSendEmailValidation.js.map +2 -2
  149. package/dist/esm/components/credits/context/hooks/useSubscribed.js +1 -1
  150. package/dist/esm/components/credits/context/hooks/useSubscribed.js.map +2 -2
  151. package/dist/esm/components/credits/context/hooks/useSubscriptions.js +1 -1
  152. package/dist/esm/components/credits/context/hooks/useSubscriptions.js.map +3 -3
  153. package/dist/esm/components/credits/credits-banner/index.d.ts +23 -0
  154. package/dist/esm/components/credits/credits-banner/index.js +2 -0
  155. package/dist/esm/components/credits/credits-banner/index.js.map +7 -0
  156. package/dist/esm/components/credits/credits-benefits/benefitItem.d.ts +19 -0
  157. package/dist/esm/components/credits/credits-benefits/benefitItem.js +2 -0
  158. package/dist/esm/components/credits/credits-benefits/benefitItem.js.map +7 -0
  159. package/dist/esm/components/credits/credits-benefits/iconInfo.d.ts +2 -0
  160. package/dist/esm/components/credits/credits-benefits/iconInfo.js +2 -0
  161. package/dist/esm/components/credits/credits-benefits/iconInfo.js.map +7 -0
  162. package/dist/esm/components/credits/credits-benefits/index.d.ts +12 -0
  163. package/dist/esm/components/credits/credits-benefits/index.js +4 -0
  164. package/dist/esm/components/credits/credits-benefits/index.js.map +7 -0
  165. package/dist/esm/components/credits/credits-cash/RedeemableItem.d.ts +15 -0
  166. package/dist/esm/components/credits/credits-cash/RedeemableItem.js +2 -0
  167. package/dist/esm/components/credits/credits-cash/RedeemableItem.js.map +7 -0
  168. package/dist/esm/components/credits/credits-cash/index.d.ts +13 -0
  169. package/dist/esm/components/credits/credits-cash/index.js +2 -0
  170. package/dist/esm/components/credits/credits-cash/index.js.map +7 -0
  171. package/dist/esm/components/credits/credits-cash/type.d.ts +47 -0
  172. package/dist/esm/components/credits/credits-cash/type.js +1 -0
  173. package/dist/esm/components/credits/credits-cash/type.js.map +7 -0
  174. package/dist/esm/components/credits/credits-faq/faq-item/FaqItem.d.ts +13 -0
  175. package/dist/esm/components/credits/credits-faq/faq-item/faq-item.d.ts +13 -0
  176. package/dist/esm/components/credits/credits-faq/faq-item/faq-item.js +2 -0
  177. package/dist/esm/components/credits/credits-faq/faq-item/faq-item.js.map +7 -0
  178. package/dist/esm/components/credits/credits-faq/faqItem/FaqItem.d.ts +13 -0
  179. package/dist/esm/components/credits/credits-faq/index.d.ts +16 -0
  180. package/dist/esm/components/credits/credits-faq/index.js +2 -0
  181. package/dist/esm/components/credits/credits-faq/index.js.map +7 -0
  182. package/dist/esm/components/credits/credits-info-card/index.d.ts +20 -0
  183. package/dist/esm/components/credits/credits-info-card/index.js +2 -0
  184. package/dist/esm/components/credits/credits-info-card/index.js.map +7 -0
  185. package/dist/esm/components/credits/credits-redeem-list/AddressForm/Input.d.ts +13 -0
  186. package/dist/esm/components/credits/credits-redeem-list/AddressForm/country-select.d.ts +14 -0
  187. package/dist/esm/components/credits/credits-redeem-list/AddressForm/form-item.d.ts +6 -0
  188. package/dist/esm/components/credits/credits-redeem-list/AddressForm/index.d.ts +2 -0
  189. package/dist/esm/components/credits/credits-redeem-list/AddressForm/state-select.d.ts +15 -0
  190. package/dist/esm/components/credits/credits-redeem-list/AddressForm/type.d.ts +26 -0
  191. package/dist/esm/components/credits/credits-redeem-list/RedeemCouponModal.d.ts +9 -0
  192. package/dist/esm/components/credits/credits-redeem-list/RedeemProductModal/Address.d.ts +20 -0
  193. package/dist/esm/components/credits/credits-redeem-list/RedeemProductModal/Error.d.ts +8 -0
  194. package/dist/esm/components/credits/credits-redeem-list/RedeemProductModal/Init.d.ts +11 -0
  195. package/dist/esm/components/credits/credits-redeem-list/RedeemProductModal/ProductInfo.d.ts +8 -0
  196. package/dist/esm/components/credits/credits-redeem-list/RedeemProductModal/Success.d.ts +13 -0
  197. package/dist/esm/components/credits/credits-redeem-list/RedeemProductModal/index.d.ts +11 -0
  198. package/dist/esm/components/credits/credits-redeem-list/RedeemableItem.d.ts +9 -0
  199. package/dist/esm/components/credits/credits-redeem-list/RedeemableItem.js +2 -0
  200. package/dist/esm/components/credits/credits-redeem-list/RedeemableItem.js.map +7 -0
  201. package/dist/esm/components/credits/credits-redeem-list/address-form/Input.d.ts +13 -0
  202. package/dist/esm/components/credits/credits-redeem-list/address-form/Input.js +2 -0
  203. package/dist/esm/components/credits/credits-redeem-list/address-form/Input.js.map +7 -0
  204. package/dist/esm/components/credits/credits-redeem-list/address-form/country-select.d.ts +14 -0
  205. package/dist/esm/components/credits/credits-redeem-list/address-form/country-select.js +2 -0
  206. package/dist/esm/components/credits/credits-redeem-list/address-form/country-select.js.map +7 -0
  207. package/dist/esm/components/credits/credits-redeem-list/address-form/form-item.d.ts +6 -0
  208. package/dist/esm/components/credits/credits-redeem-list/address-form/form-item.js +2 -0
  209. package/dist/esm/components/credits/credits-redeem-list/address-form/form-item.js.map +7 -0
  210. package/dist/esm/components/credits/credits-redeem-list/address-form/index.d.ts +2 -0
  211. package/dist/esm/components/credits/credits-redeem-list/address-form/index.js +2 -0
  212. package/dist/esm/components/credits/credits-redeem-list/address-form/index.js.map +7 -0
  213. package/dist/esm/components/credits/credits-redeem-list/address-form/state-select.d.ts +15 -0
  214. package/dist/esm/components/credits/credits-redeem-list/address-form/state-select.js +2 -0
  215. package/dist/esm/components/credits/credits-redeem-list/address-form/state-select.js.map +7 -0
  216. package/dist/esm/components/credits/credits-redeem-list/address-form/type.d.ts +26 -0
  217. package/dist/esm/components/credits/credits-redeem-list/address-form/type.js +1 -0
  218. package/dist/esm/components/credits/credits-redeem-list/address-form/type.js.map +7 -0
  219. package/dist/esm/components/credits/credits-redeem-list/index.d.ts +13 -0
  220. package/dist/esm/components/credits/credits-redeem-list/index.js +2 -0
  221. package/dist/esm/components/credits/credits-redeem-list/index.js.map +7 -0
  222. package/dist/esm/components/credits/credits-redeem-list/redeem-coupon-modal.d.ts +9 -0
  223. package/dist/esm/components/credits/credits-redeem-list/redeem-coupon-modal.js +2 -0
  224. package/dist/esm/components/credits/credits-redeem-list/redeem-coupon-modal.js.map +7 -0
  225. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Address.d.ts +20 -0
  226. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Address.js +2 -0
  227. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Address.js.map +7 -0
  228. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Error.d.ts +8 -0
  229. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Error.js +2 -0
  230. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Error.js.map +7 -0
  231. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Init.d.ts +11 -0
  232. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Init.js +2 -0
  233. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Init.js.map +7 -0
  234. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/ProductInfo.d.ts +8 -0
  235. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/ProductInfo.js +2 -0
  236. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/ProductInfo.js.map +7 -0
  237. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Success.d.ts +13 -0
  238. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Success.js +2 -0
  239. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Success.js.map +7 -0
  240. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/index.d.ts +11 -0
  241. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/index.js +2 -0
  242. package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/index.js.map +7 -0
  243. package/dist/esm/components/credits/credits-redeem-list/type.d.ts +77 -0
  244. package/dist/esm/components/credits/credits-redeem-list/type.js +1 -0
  245. package/dist/esm/components/credits/credits-redeem-list/type.js.map +7 -0
  246. package/dist/esm/components/credits/credits-ways-to-get-credits/index.d.ts +2 -0
  247. package/dist/esm/components/credits/credits-ways-to-get-credits/index.js +2 -0
  248. package/dist/esm/components/credits/credits-ways-to-get-credits/index.js.map +7 -0
  249. package/dist/esm/components/credits/credits-ways-to-get-credits/type.d.ts +60 -0
  250. package/dist/esm/components/credits/credits-ways-to-get-credits/type.js +2 -0
  251. package/dist/esm/components/credits/credits-ways-to-get-credits/type.js.map +7 -0
  252. package/dist/esm/components/credits/credits-ways-to-get-credits/useActions.d.ts +96 -0
  253. package/dist/esm/components/credits/credits-ways-to-get-credits/useActions.js +2 -0
  254. package/dist/esm/components/credits/credits-ways-to-get-credits/useActions.js.map +7 -0
  255. package/dist/esm/components/credits/creditsBenefits/index.js +3 -3
  256. package/dist/esm/components/credits/creditsBenefits/index.js.map +3 -3
  257. package/dist/esm/components/credits/creditsCash/index.js +1 -1
  258. package/dist/esm/components/credits/creditsCash/index.js.map +2 -2
  259. package/dist/esm/components/credits/creditsCash/type.d.ts +1 -1
  260. package/dist/esm/components/credits/creditsRedeemList/AddressForm/country-select.d.ts +14 -0
  261. package/dist/esm/components/credits/creditsRedeemList/AddressForm/form-item.d.ts +6 -0
  262. package/dist/esm/components/credits/creditsRedeemList/AddressForm/index.js +1 -1
  263. package/dist/esm/components/credits/creditsRedeemList/AddressForm/index.js.map +2 -2
  264. package/dist/esm/components/credits/creditsRedeemList/AddressForm/state-select.d.ts +15 -0
  265. package/dist/esm/components/credits/creditsRedeemList/RedeemCouponModal.js +1 -1
  266. package/dist/esm/components/credits/creditsRedeemList/RedeemCouponModal.js.map +2 -2
  267. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Address.js +1 -1
  268. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Address.js.map +2 -2
  269. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js +1 -1
  270. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js.map +2 -2
  271. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/index.js +1 -1
  272. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/index.js.map +2 -2
  273. package/dist/esm/components/credits/creditsRedeemList/index.js +1 -1
  274. package/dist/esm/components/credits/creditsRedeemList/index.js.map +2 -2
  275. package/dist/esm/components/credits/creditsWaysToGetCredits/useActions.js +1 -1
  276. package/dist/esm/components/credits/creditsWaysToGetCredits/useActions.js.map +2 -2
  277. package/dist/esm/components/credits/modal/loadingDots.js +1 -1
  278. package/dist/esm/components/credits/modal/loadingDots.js.map +2 -2
  279. package/dist/esm/components/credits/type.d.ts +1 -1
  280. package/dist/esm/debug-env.js +2 -0
  281. package/dist/esm/debug-env.js.map +7 -0
  282. package/dist/esm/index.d.ts +1 -6
  283. package/dist/esm/index.js +1 -1
  284. package/dist/esm/index.js.map +3 -3
  285. package/dist/esm/shopify/context/ShopifyProvider.d.ts +1 -1
  286. package/dist/esm/shopify/context/index.d.ts +1 -0
  287. package/dist/esm/shopify/context/shopify-provider.d.ts +10 -0
  288. package/dist/esm/shopify/fetchers/create-cart.d.ts +1 -2
  289. package/dist/esm/shopify/hooks/index.d.ts +2 -2
  290. package/dist/esm/shopify/hooks/use-create-cart.d.ts +2 -0
  291. package/dist/esm/shopify/hooks/use-products-by-handles.d.ts +4 -0
  292. package/dist/esm/shopify/hooks/useProductsByHandles.d.ts +1 -1
  293. package/dist/esm/shopify/types/index.d.ts +2 -0
  294. package/dist/esm/stories/chat.stories.js +2 -0
  295. package/dist/esm/stories/chat.stories.js.map +7 -0
  296. package/dist/esm/tsconfig.tsbuildinfo +1 -0
  297. package/package.json +8 -3
  298. package/src/components/credits/context/hooks/useActivities.ts +1 -1
  299. package/src/components/credits/context/hooks/useAddressValidate.ts +2 -2
  300. package/src/components/credits/context/hooks/useAlpcFetch.ts +3 -3
  301. package/src/components/credits/context/hooks/useCountries.ts +2 -2
  302. package/src/components/credits/context/hooks/useMyRewards.ts +1 -1
  303. package/src/components/credits/context/hooks/useRedeemAndBuy.ts +2 -2
  304. package/src/components/credits/context/hooks/useRedeemCoupon.ts +1 -1
  305. package/src/components/credits/context/hooks/useRedeemProduct.ts +1 -1
  306. package/src/components/credits/context/hooks/useRedeemableList.ts +1 -1
  307. package/src/components/credits/context/hooks/useSendEmailValidation.ts +1 -1
  308. package/src/components/credits/context/hooks/useSubscribed.ts +1 -1
  309. package/src/components/credits/context/hooks/useSubscriptions.ts +2 -2
  310. package/src/components/credits/creditsBenefits/index.tsx +3 -5
  311. package/src/components/credits/creditsCash/index.tsx +2 -2
  312. package/src/components/credits/creditsCash/type.ts +1 -1
  313. package/src/components/credits/creditsRedeemList/AddressForm/index.tsx +1 -1
  314. package/src/components/credits/creditsRedeemList/RedeemCouponModal.tsx +1 -1
  315. package/src/components/credits/creditsRedeemList/RedeemProductModal/Address.tsx +1 -1
  316. package/src/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.tsx +1 -1
  317. package/src/components/credits/creditsRedeemList/RedeemProductModal/index.tsx +1 -1
  318. package/src/components/credits/creditsRedeemList/index.tsx +1 -1
  319. package/src/components/credits/creditsWaysToGetCredits/useActions.ts +1 -1
  320. package/src/components/credits/modal/loadingDots.tsx +2 -2
  321. package/src/components/credits/type.ts +1 -1
  322. package/src/index.ts +2 -21
  323. package/dist/cjs/components/credits/creditsCash/index.js +0 -2
  324. package/dist/cjs/components/credits/creditsCash/index.js.map +0 -7
  325. package/dist/cjs/components/credits/creditsCash/type.js.map +0 -7
  326. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/index.js +0 -2
  327. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/index.js.map +0 -7
  328. package/dist/cjs/components/credits/creditsRedeemList/RedeemCouponModal.js +0 -2
  329. package/dist/cjs/components/credits/creditsRedeemList/RedeemCouponModal.js.map +0 -7
  330. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Address.js +0 -2
  331. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Address.js.map +0 -7
  332. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js +0 -2
  333. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js.map +0 -7
  334. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/index.js +0 -2
  335. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/index.js.map +0 -7
  336. package/dist/cjs/components/credits/creditsRedeemList/index.js +0 -2
  337. package/dist/cjs/components/credits/creditsRedeemList/index.js.map +0 -7
  338. package/dist/cjs/components/credits/creditsWaysToGetCredits/useActions.js +0 -2
  339. package/dist/cjs/components/credits/creditsWaysToGetCredits/useActions.js.map +0 -7
  340. package/src/shopify/MIGRATION_GUIDE.md +0 -156
  341. package/src/shopify/context/ShopifyProvider.tsx +0 -34
  342. package/src/shopify/dist/cart-BNkVu3fh.d.ts +0 -220
  343. package/src/shopify/dist/cart-BcrGTPdx.d.cts +0 -220
  344. package/src/shopify/dist/fetchers.cjs +0 -7945
  345. package/src/shopify/dist/fetchers.cjs.map +0 -1
  346. package/src/shopify/dist/fetchers.d.cts +0 -3
  347. package/src/shopify/dist/fetchers.d.ts +0 -3
  348. package/src/shopify/dist/fetchers.js +0 -7942
  349. package/src/shopify/dist/fetchers.js.map +0 -1
  350. package/src/shopify/dist/fragments.cjs +0 -731
  351. package/src/shopify/dist/fragments.cjs.map +0 -1
  352. package/src/shopify/dist/fragments.d.cts +0 -25
  353. package/src/shopify/dist/fragments.d.ts +0 -25
  354. package/src/shopify/dist/fragments.js +0 -705
  355. package/src/shopify/dist/fragments.js.map +0 -1
  356. package/src/shopify/dist/graphql-D4M28V-x.d.cts +0 -3558
  357. package/src/shopify/dist/graphql-D4M28V-x.d.ts +0 -3558
  358. package/src/shopify/dist/hooks.cjs +0 -9431
  359. package/src/shopify/dist/hooks.cjs.map +0 -1
  360. package/src/shopify/dist/hooks.d.cts +0 -14
  361. package/src/shopify/dist/hooks.d.ts +0 -14
  362. package/src/shopify/dist/hooks.js +0 -9427
  363. package/src/shopify/dist/hooks.js.map +0 -1
  364. package/src/shopify/dist/index-BTtE4HZM.d.ts +0 -42
  365. package/src/shopify/dist/index-BjNIecYX.d.cts +0 -42
  366. package/src/shopify/dist/index.cjs +0 -9642
  367. package/src/shopify/dist/index.cjs.map +0 -1
  368. package/src/shopify/dist/index.d.cts +0 -11
  369. package/src/shopify/dist/index.d.ts +0 -11
  370. package/src/shopify/dist/index.js +0 -9619
  371. package/src/shopify/dist/index.js.map +0 -1
  372. package/src/shopify/dist/product-Bqi3sqb9.d.cts +0 -262
  373. package/src/shopify/dist/product-DNk6jYAP.d.ts +0 -262
  374. package/src/shopify/dist/queries.cjs +0 -615
  375. package/src/shopify/dist/queries.cjs.map +0 -1
  376. package/src/shopify/dist/queries.d.cts +0 -3
  377. package/src/shopify/dist/queries.d.ts +0 -3
  378. package/src/shopify/dist/queries.js +0 -601
  379. package/src/shopify/dist/queries.js.map +0 -1
  380. package/src/shopify/dist/types.cjs +0 -19
  381. package/src/shopify/dist/types.cjs.map +0 -1
  382. package/src/shopify/dist/types.d.cts +0 -282
  383. package/src/shopify/dist/types.d.ts +0 -282
  384. package/src/shopify/dist/types.js +0 -1
  385. package/src/shopify/dist/types.js.map +0 -1
  386. package/src/shopify/dist/utils.cjs +0 -334
  387. package/src/shopify/dist/utils.cjs.map +0 -1
  388. package/src/shopify/dist/utils.d.cts +0 -12
  389. package/src/shopify/dist/utils.d.ts +0 -12
  390. package/src/shopify/dist/utils.js +0 -319
  391. package/src/shopify/dist/utils.js.map +0 -1
  392. package/src/shopify/fetchers/create-cart.ts +0 -40
  393. package/src/shopify/fetchers/get-products-by-handles.ts +0 -41
  394. package/src/shopify/fetchers/index.ts +0 -3
  395. package/src/shopify/fragments/article.ts +0 -51
  396. package/src/shopify/fragments/blog.ts +0 -10
  397. package/src/shopify/fragments/cart.ts +0 -190
  398. package/src/shopify/fragments/collection.ts +0 -15
  399. package/src/shopify/fragments/image.ts +0 -8
  400. package/src/shopify/fragments/index.ts +0 -11
  401. package/src/shopify/fragments/metafields.ts +0 -17
  402. package/src/shopify/fragments/page-info.ts +0 -8
  403. package/src/shopify/fragments/page.ts +0 -12
  404. package/src/shopify/fragments/product.ts +0 -71
  405. package/src/shopify/fragments/seo.ts +0 -6
  406. package/src/shopify/fragments/variant.ts +0 -29
  407. package/src/shopify/gql/fragment-masking.ts +0 -85
  408. package/src/shopify/gql/gql.ts +0 -110
  409. package/src/shopify/gql/graphql.ts +0 -11780
  410. package/src/shopify/gql/index.ts +0 -4
  411. package/src/shopify/hooks/index.ts +0 -2
  412. package/src/shopify/hooks/useCreateCart.ts +0 -24
  413. package/src/shopify/hooks/useProductsByHandles.ts +0 -25
  414. package/src/shopify/mutations/create-cart.ts +0 -16
  415. package/src/shopify/package.json +0 -84
  416. package/src/shopify/queries/get-product-by-handles.ts +0 -32
  417. package/src/shopify/queries/index.ts +0 -2
  418. package/src/shopify/src/index.ts +0 -5
  419. package/src/shopify/tsconfig.json +0 -25
  420. package/src/shopify/tsup.config.ts +0 -21
  421. package/src/shopify/types/article.ts +0 -46
  422. package/src/shopify/types/cart.ts +0 -202
  423. package/src/shopify/types/checkout.ts +0 -44
  424. package/src/shopify/types/collection.ts +0 -104
  425. package/src/shopify/types/common.ts +0 -53
  426. package/src/shopify/types/config.ts +0 -14
  427. package/src/shopify/types/customer.ts +0 -31
  428. package/src/shopify/types/fetcher.ts +0 -61
  429. package/src/shopify/types/index.ts +0 -10
  430. package/src/shopify/types/page.ts +0 -45
  431. package/src/shopify/types/product.ts +0 -176
  432. package/src/shopify/types/search.ts +0 -62
  433. package/src/shopify/types/site.ts +0 -38
  434. package/src/shopify/types/type-helper.ts +0 -5
  435. package/src/shopify/utils/colors.ts +0 -206
  436. package/src/shopify/utils/const.ts +0 -115
  437. package/src/shopify/utils/cookie.ts +0 -39
  438. package/src/shopify/utils/errors.ts +0 -65
  439. package/src/shopify/utils/fetch-graphql-api.ts +0 -67
  440. package/src/shopify/utils/handle-fetch-response.ts +0 -60
  441. package/src/shopify/utils/helper.ts +0 -89
  442. package/src/shopify/utils/normalize/cart.ts +0 -106
  443. package/src/shopify/utils/normalize/customer.ts +0 -18
  444. package/src/shopify/utils/normalize/index.ts +0 -2
  445. package/src/shopify/utils/normalize/metafield.ts +0 -69
  446. package/src/shopify/utils/normalize/product.ts +0 -193
  447. package/src/shopify/utils/store.ts +0 -5
  448. package/src/shopify/utils/type-helper.ts +0 -7
  449. /package/dist/cjs/components/credits/{creditsBanner → credits-banner}/index.js +0 -0
  450. /package/dist/cjs/components/credits/{creditsBenefits → credits-benefits}/benefitItem.js +0 -0
  451. /package/dist/cjs/components/credits/{creditsBenefits → credits-benefits}/iconInfo.js +0 -0
  452. /package/dist/cjs/components/credits/{creditsBenefits → credits-benefits}/index.js +0 -0
  453. /package/dist/cjs/components/credits/{creditsCash → credits-cash}/RedeemableItem.js +0 -0
  454. /package/dist/cjs/components/credits/{creditsCash → credits-cash}/type.js +0 -0
  455. /package/dist/cjs/components/credits/{creditsFaq → credits-faq}/index.js +0 -0
  456. /package/dist/cjs/components/credits/{creditsInfoCard → credits-info-card}/index.js +0 -0
  457. /package/dist/cjs/components/credits/{creditsRedeemList → credits-redeem-list}/RedeemableItem.js +0 -0
  458. /package/dist/cjs/components/credits/{creditsRedeemList/AddressForm → credits-redeem-list/address-form}/Input.js +0 -0
  459. /package/dist/cjs/components/credits/{creditsRedeemList/AddressForm → credits-redeem-list/address-form}/type.js +0 -0
  460. /package/dist/cjs/components/credits/{creditsRedeemList/RedeemProductModal → credits-redeem-list/redeem-product-modal}/Error.js +0 -0
  461. /package/dist/cjs/components/credits/{creditsRedeemList/RedeemProductModal → credits-redeem-list/redeem-product-modal}/Init.js +0 -0
  462. /package/dist/cjs/components/credits/{creditsRedeemList/RedeemProductModal → credits-redeem-list/redeem-product-modal}/Success.js +0 -0
  463. /package/dist/cjs/components/credits/{creditsRedeemList → credits-redeem-list}/type.js +0 -0
  464. /package/dist/cjs/components/credits/{creditsWaysToGetCredits → credits-ways-to-get-credits}/index.js +0 -0
  465. /package/dist/cjs/components/credits/{creditsWaysToGetCredits → credits-ways-to-get-credits}/type.js +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anker-in/campaign-ui",
3
- "version": "0.2.10-beta.1",
3
+ "version": "0.2.10-beta.10",
4
4
  "type": "commonjs",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "types": "./dist/cjs/index.d.ts",
@@ -43,12 +43,14 @@
43
43
  "@babel/preset-env": "^7.24.6",
44
44
  "@babel/preset-react": "^7.24.6",
45
45
  "@babel/preset-typescript": "^7.24.6",
46
+ "@hyrious/esbuild-plugin-commonjs": "^0.2.6",
46
47
  "@testing-library/jest-dom": "^6.4.6",
47
48
  "@testing-library/react": "^14.3.1",
48
49
  "@types/jest": "^29.5.12",
49
50
  "@types/node": "^20",
50
51
  "babel-jest": "^29.7.0",
51
52
  "esbuild": "^0.20.2",
53
+ "esbuild-copy-static-files": "^0.1.0",
52
54
  "esbuild-style-plugin": "^1.6.3",
53
55
  "eslint-plugin-react-hooks": "^4.6.2",
54
56
  "eslint-plugin-require-extensions": "^0.1.3",
@@ -71,6 +73,7 @@
71
73
  "@radix-ui/react-radio-group": "^1.1.3",
72
74
  "@radix-ui/react-slot": "^1.0.2",
73
75
  "@radix-ui/react-visually-hidden": "^1.0.3",
76
+ "swiper": "^11.1.3",
74
77
  "autoprefixer": "^10.4.19",
75
78
  "class-variance-authority": "^0.7.0",
76
79
  "clsx": "^2.1.1",
@@ -81,11 +84,13 @@
81
84
  "react-codepen-embed": "^1.1.0",
82
85
  "tailwind-merge": "^2.3.0",
83
86
  "tailwindcss": "^3.4.3",
84
- "@anker-in/headless-ui": "1.0.19"
87
+ "@anker-in/headless-ui": "1.0.19",
88
+ "@anker-in/shopify": "^0.0.0-beta.3"
85
89
  },
86
90
  "peerDependencies": {
87
91
  "react": "^18.3.1",
88
- "react-dom": "^18.3.1"
92
+ "react-dom": "^18.3.1",
93
+ "next": ">=12.0.0"
89
94
  },
90
95
  "scripts": {
91
96
  "dev": "pnpm run dev:css & pnpm run dev:js:esm & pnpm run dev:js:cjs & pnpm run dev:js:esm:types & pnpm run dev:js:cjs:types",
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useState } from 'react'
3
3
  import { useAlpcMutation } from './useAlpcFetch'
4
4
  import type { CreditLogResponse } from '../response'
5
5
  import { useCreditsContext } from '../provider'
6
- import { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'
6
+ import { useShopifyContext } from '@anker-in/shopify'
7
7
 
8
8
  function useActivities({ page, pageSize, options = {} }: { page: number; pageSize: number; options?: any }) {
9
9
  const { profile, isLoadingProfile } = useCreditsContext()
@@ -1,6 +1,6 @@
1
- import { useRouter } from 'next/router'
2
1
  import { useCallback, useMemo, useState } from 'react'
3
2
  import { emailValidate } from '../utils'
3
+ import { useShopifyContext } from '@anker-in/shopify'
4
4
 
5
5
  type ValidatorCallback = (value: string, params?: Record<string, any>) => boolean
6
6
 
@@ -106,7 +106,7 @@ export const useAddressValidate = ({
106
106
  email: string
107
107
  }
108
108
  }) => {
109
- const { locale } = useRouter()
109
+ const { locale } = useShopifyContext()
110
110
  const [errors, setErrors] = useState<{ key: string; message: string }[]>([])
111
111
 
112
112
  const addressRules: Rule[] = useMemo(() => {
@@ -1,7 +1,7 @@
1
1
  import Cookies from 'js-cookie'
2
- import { useRouter } from 'next/router'
3
2
  import { useCallback, useRef, useState } from 'react'
4
3
  import useSWR, { type SWRConfiguration } from 'swr'
4
+ import { useShopifyContext } from '@anker-in/shopify'
5
5
 
6
6
  import { getAlpcPath } from '../utils'
7
7
  import { useCreditsContext } from '../provider'
@@ -196,7 +196,7 @@ export const useAlpcFetch = <TData>(
196
196
 
197
197
  const { enable, ...otherSwrOptions } = swrOptions || {}
198
198
 
199
- const { locale = '' } = useRouter()
199
+ const { locale = '' } = useShopifyContext()
200
200
 
201
201
  const { queryKey = [], body: fetchBody = {}, headers, ...fetchOptions } = options
202
202
  const fetchEnable = enable ?? true
@@ -251,7 +251,7 @@ export const useAlpcMutation = <TData, TBody>(options: MutationOptions, mutation
251
251
  const [retry, setRetry] = useState(false)
252
252
  const { removeProfile } = useCreditsContext()
253
253
 
254
- const { locale = '' } = useRouter()
254
+ const { locale = '' } = useShopifyContext()
255
255
 
256
256
  const { url, initData, headers, ...fetchOptions } = options
257
257
 
@@ -1,10 +1,10 @@
1
- import { useRouter } from 'next/router'
2
1
  import { useEffect, useState } from 'react'
3
2
 
3
+ import { useShopifyContext } from '@anker-in/shopify'
4
4
  import { type ShippingCountry, type ShippingZone } from '../../type'
5
5
 
6
6
  function useCountries({ shopifyStoreDomain }: { shopifyStoreDomain: string }) {
7
- const { locale = '' } = useRouter()
7
+ const { locale = '' } = useShopifyContext()
8
8
 
9
9
  const [isLoading, setLoading] = useState(false)
10
10
  const [countries, setCountries] = useState<ShippingCountry[]>([])
@@ -4,7 +4,7 @@ import { ALPC_COUNTRY_MAP, AlpcConsumeType } from '../const'
4
4
  import { useAlpcMutation } from './useAlpcFetch'
5
5
  import type { RedeemLogResponse } from '../response'
6
6
  import { useCreditsContext } from '../provider'
7
- import { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'
7
+ import { useShopifyContext } from '@anker-in/shopify'
8
8
 
9
9
  function useMyRewards({
10
10
  page,
@@ -1,7 +1,7 @@
1
1
  import useSWRMutation from 'swr/mutation'
2
2
  import { useRedeemCoupon } from './useRedeemCoupon'
3
- import { useCreateCartMutation } from '../../../../shopify/hooks/useCreateCart'
4
- import type { ProductVariant } from '../../../../shopify/types/product'
3
+ import { useCreateCartMutation } from '@anker-in/shopify'
4
+ import type { ProductVariant } from '@anker-in/shopify'
5
5
  import { useCreditsContext } from '../provider'
6
6
 
7
7
  export const useRedeemAndBuy = () => {
@@ -1,6 +1,6 @@
1
1
  import { ALPC_COUNTRY_MAP } from '../const'
2
2
  import { useAlpcMutation, type UseMutationConfig } from './useAlpcFetch'
3
- import { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'
3
+ import { useShopifyContext } from '@anker-in/shopify'
4
4
 
5
5
  type RedeemCouponResponse = {
6
6
  code: number
@@ -1,6 +1,6 @@
1
1
  import { ALPC_COUNTRY_MAP } from '../const'
2
2
  import { useAlpcMutation, type UseMutationConfig } from './useAlpcFetch'
3
- import { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'
3
+ import { useShopifyContext } from '@anker-in/shopify'
4
4
 
5
5
  type RedeemProductResponse = {
6
6
  code: number
@@ -4,7 +4,7 @@ import { useAlpcMutation } from './useAlpcFetch'
4
4
  import { ALPC_COUNTRY_MAP } from '../const'
5
5
  import { useCreditsContext } from '../provider'
6
6
  import type { ConsumeCreditRuleResponse } from '../response'
7
- import { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'
7
+ import { useShopifyContext } from '@anker-in/shopify'
8
8
 
9
9
  function useRedeemableList() {
10
10
  let locale = '' as string
@@ -1,7 +1,7 @@
1
1
  import fetcher from '../../../../helpers/fetcher'
2
2
  import useSWRMutation from 'swr/mutation'
3
3
  import { useCreditsContext } from '../provider'
4
- import { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'
4
+ import { useShopifyContext } from '@anker-in/shopify'
5
5
 
6
6
  export function useSendEmailValidation() {
7
7
  const { profile } = useCreditsContext()
@@ -4,7 +4,7 @@ import { TaskSubType } from '../const'
4
4
  import useActivities from './useActivities'
5
5
  import useSubscriptions from './useSubscriptions'
6
6
  import { useCreditsContext } from '../provider'
7
- import { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'
7
+ import { useShopifyContext } from '@anker-in/shopify'
8
8
 
9
9
  export const useSubscribed = () => {
10
10
  const { profile } = useCreditsContext()
@@ -1,12 +1,12 @@
1
- import { useRouter } from 'next/router'
2
1
  import { useCallback, useEffect, useRef, useState } from 'react'
3
2
  import type { Subscription } from '../../type'
4
3
  import fetcher from '../../../../helpers/fetcher'
4
+ import { useShopifyContext } from '@anker-in/shopify'
5
5
 
6
6
  function useSubscriptions(email?: string) {
7
7
  const loading = useRef(false)
8
8
  const [subscriptionData, setSubscriptionData] = useState<Subscription>()
9
- const { locale } = useRouter()
9
+ const { locale } = useShopifyContext()
10
10
 
11
11
  const fetchSubscription = useCallback(async () => {
12
12
  if (!email) {
@@ -3,14 +3,13 @@ import 'swiper/css/grid'
3
3
  import 'swiper/css/pagination'
4
4
 
5
5
  import { Container, Heading } from '@anker-in/headless-ui'
6
- import { useRouter } from 'next/router'
7
6
  import { useState } from 'react'
8
7
  import { Grid, Pagination } from 'swiper/modules'
9
8
  import { Swiper, SwiperSlide } from 'swiper/react'
10
9
 
11
10
  import BenefitItem, { type BenefitItemCopy } from './benefitItem'
12
11
  import { useCreditsContext } from '../context/provider'
13
- import { gaTrack, getGtmGroup } from '../../../helpers/track'
12
+ import { gaTrack } from '../../../helpers/track'
14
13
  import { cn } from '../../../helpers/utils'
15
14
 
16
15
  interface CreditsBenefitsProps {
@@ -22,8 +21,7 @@ interface CreditsBenefitsProps {
22
21
 
23
22
  export const CreditsBenefits = ({ copy }: CreditsBenefitsProps) => {
24
23
  const [activeNoteIndex, setActiveNoteIndex] = useState<number | null>(null)
25
- const { profile } = useCreditsContext()
26
- const router = useRouter()
24
+ const { profile, gtm } = useCreditsContext()
27
25
 
28
26
  const handleClick = ({ item, index }: { item: BenefitItemCopy; index: number }) => {
29
27
  gaTrack({
@@ -31,7 +29,7 @@ export const CreditsBenefits = ({ copy }: CreditsBenefitsProps) => {
31
29
  event_name: 'lp_button',
32
30
  member_active_status: profile?.activated ? 'active' : 'not active',
33
31
  event_parameters: {
34
- page_group: getGtmGroup(router),
32
+ page_group: gtm.pageGroup,
35
33
  position: copy.title,
36
34
  button_name: item.text,
37
35
  info: '',
@@ -5,9 +5,9 @@ import RedeemableItem from './RedeemableItem'
5
5
  import useRedeemableList from '../context/hooks/useRedeemableList'
6
6
  import { cn } from '../../../helpers'
7
7
  import RulesModal from '../modal/rulesModal'
8
- import { useProductsByHandles } from '../../../shopify/hooks/useProductsByHandles'
8
+ import { useProductsByHandles } from '@anker-in/shopify'
9
9
  import { CreditsCashCopy, RedeemItem } from './type'
10
- import { Product } from 'src/shopify/types'
10
+ import { Product } from '@anker-in/shopify'
11
11
 
12
12
  export const CreditsCash = ({
13
13
  copy,
@@ -1,4 +1,4 @@
1
- import { ProductVariant, Product } from 'src/shopify/types'
1
+ import { ProductVariant, Product } from '@anker-in/shopify'
2
2
  import { AlpcConsumeType } from '../context/const'
3
3
 
4
4
  type RedeemableItemConfig = {
@@ -7,7 +7,7 @@ import { Input } from './Input'
7
7
  import { StateSelect } from './StateSelect'
8
8
  import { ALPC_COUNTRY_MAP } from '../../context/const'
9
9
  import { useCreditsContext } from '../../context/provider'
10
- import { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'
10
+ import { useShopifyContext } from '@anker-in/shopify'
11
11
  import { AddressFormProps } from './type'
12
12
 
13
13
  export const AddressForm = ({ countries, countriesLoading, form, validate, errors, onChange }: AddressFormProps) => {
@@ -9,7 +9,7 @@ import { AlpcErrorCode } from '../context/const'
9
9
  import { CreditsModalContainer } from '../modal/modalContainer'
10
10
  import { numberFormat } from '../context/utils'
11
11
  import type { RedeemableItem as RedeemableItemType } from '../type'
12
- import { useShopifyContext } from '../../../shopify/context/ShopifyProvider'
12
+ import { useShopifyContext } from '@anker-in/shopify'
13
13
  import { CreditsRedeemListCopy } from './type'
14
14
 
15
15
  function RedeemCouponModal({
@@ -1,7 +1,7 @@
1
1
  import { Button, Text } from '@anker-in/headless-ui'
2
2
  import classNames from 'classnames'
3
3
  import { AddressForm } from '../AddressForm'
4
- import { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'
4
+ import { useShopifyContext } from '@anker-in/shopify'
5
5
  import type { RedeemableItem as RedeemableItemType } from '../../type'
6
6
  import { CreditsRedeemListCopy } from '../type'
7
7
  import { ProductInfo } from './ProductInfo'
@@ -2,7 +2,7 @@ import { Picture } from '@anker-in/headless-ui'
2
2
  import { formatPrice } from '../../context/utils'
3
3
  import type { RedeemableItem as RedeemableItemType } from '../../type'
4
4
  import { CreditsRedeemListCopy } from '../type'
5
- import { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'
5
+ import { useShopifyContext } from '@anker-in/shopify'
6
6
 
7
7
  type ProductInfoProps = {
8
8
  item: RedeemableItemType
@@ -8,7 +8,7 @@ import { useRedeemProduct } from '../../context/hooks/useRedeemProduct'
8
8
  import type { ModalContainerProps } from '../../modal/modalContainer'
9
9
  import { CreditsModalContainer } from '../../modal/modalContainer'
10
10
  import type { RedeemableItem as RedeemableItemType } from '../../type'
11
- import { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'
11
+ import { useShopifyContext } from '@anker-in/shopify'
12
12
  import { CreditsRedeemListCopy } from '../type'
13
13
  import { Error } from './Error'
14
14
  import { Success } from './Success'
@@ -7,7 +7,7 @@ import RedeemProductModal from './RedeemProductModal'
7
7
  import { useCreditsContext } from '../context/provider'
8
8
  import useRedeemableList from '../context/hooks/useRedeemableList'
9
9
  import { AlpcConsumeType, AlpcErrorCode } from '../context/const'
10
- import { useProductsByHandles } from '../../../shopify/hooks/useProductsByHandles'
10
+ import { useProductsByHandles } from '@anker-in/shopify'
11
11
  import type { RedeemableItem as RedeemableItemType } from '../type'
12
12
  import { RedeemableItem } from './RedeemableItem'
13
13
  import RulesModal from '../modal/rulesModal'
@@ -5,7 +5,7 @@ import useReceiptUploaded from '../context/hooks/useReceiptUploaded'
5
5
  import { useFirstPurchaseFinished } from '../context/hooks/useFirstPurchaseFinished'
6
6
  import { useSubscribed } from '../context/hooks/useSubscribed'
7
7
  import type { CreditsWaysToGetCreditsProps } from './type'
8
- import { useShopifyContext } from '../../../shopify/context/ShopifyProvider'
8
+ import { useShopifyContext } from '@anker-in/shopify'
9
9
  import { gaTrack } from '../../../helpers/track'
10
10
 
11
11
  export const useActions = ({
@@ -6,11 +6,11 @@ interface LoadingProps {
6
6
 
7
7
  function LoadingDots({ className }: LoadingProps) {
8
8
  return (
9
- <span className={cn(className)}>
9
+ <div className={cn(className)}>
10
10
  <span className="dot" key={`dot_1`} />
11
11
  <span className="dot" key={`dot_2`} />
12
12
  <span className="dot" key={`dot_3`} />
13
- </span>
13
+ </div>
14
14
  )
15
15
  }
16
16
 
@@ -1,4 +1,4 @@
1
- import type { Product, ProductVariant } from '../../shopify/types/product'
1
+ import type { Product, ProductVariant } from '@anker-in/shopify'
2
2
  import type { AlpcConsumeType, ConsumeType } from './context/const'
3
3
 
4
4
  export interface Subscription {
package/src/index.ts CHANGED
@@ -1,23 +1,4 @@
1
1
  export * from './components/index'
2
2
 
3
- // 导出 Shopify Context 相关模块
4
- export { ShopifyProvider, useShopifyContext } from './shopify/context/ShopifyProvider'
5
-
6
- // 导出 Shopify 核心模块
7
- export * from './shopify/fetchers'
8
- export * from './shopify/hooks'
9
- export * from './shopify/queries'
10
- export * from './shopify/fragments'
11
-
12
- // 导出 Shopify 核心类型(排除有冲突的 Brand 类型)
13
- export type {
14
- Cart,
15
- LineItem,
16
- Product,
17
- ProductVariant,
18
- ProductImage,
19
- ProductMedia,
20
- ProductPrice,
21
- VariantCoupon,
22
- Discount,
23
- } from './shopify/types'
3
+ // 导出 Shopify 相关模块
4
+ export * from '@anker-in/shopify'
@@ -1,2 +0,0 @@
1
- "use strict";var k=Object.create;var l=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var _=(e,t)=>{for(var s in t)l(e,s,{get:t[s],enumerable:!0})},v=(e,t,s,m)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of D(t))!P.call(e,i)&&i!==s&&l(e,i,{get:()=>t[i],enumerable:!(m=A(t,i))||m.enumerable});return e};var f=(e,t,s)=>(s=e!=null?k(L(e)):{},v(t||!e||!e.__esModule?l(s,"default",{value:e,enumerable:!0}):s,e)),H=e=>v(l({},"__esModule",{value:!0}),e);var B={};_(B,{CreditsCash:()=>M});module.exports=H(B);var r=require("react/jsx-runtime"),c=require("@anker-in/headless-ui"),u=require("react"),y=f(require("./RedeemableItem")),x=f(require("../context/hooks/useRedeemableList")),N=require("../../../helpers"),I=f(require("../modal/rulesModal")),R=require("../../../shopify/hooks/useProductsByHandles");const M=({copy:e,className:t="",hideTitle:s=!1,cardClassName:m,authCodeActivate:i})=>{const[p,g]=(0,u.useState)(),{redeemableList:h}=(0,x.default)(),S="us",F=[],{data:C}=(0,R.useProductsByHandles)({locale:S,handles:e?.list?.map(a=>a.products?.[0]?.handle)||[],metafieldIdentifiers:{variant:F}}),b=(0,u.useMemo)(()=>C?.map(a=>{const o=e.list.find(d=>d.products?.[0]?.handle===a.handle),n=h.find(d=>d.id?.toString()===o?.redeemId?.toString());return{product:a,productVariant:a.variants?.find(d=>d.sku===o?.products?.[0]?.sku)||a.variants?.[0],alpcData:{id:n?.id,consumeCredits:n?.consume_credits,remainingInventory:n?.remaining_inventory,isLimited:n?.is_limited,consumeType:n?.consume_type,title:n?.name,desc:n?.note},config:o}}),[C,e.list,h]);return console.log("list",b),(0,r.jsxs)(c.Container,{className:(0,N.cn)("bg-[#F5F5F5]",t),children:[!s&&(0,r.jsx)(c.Heading,{as:"h2",size:"4",html:e.title}),(0,r.jsx)("div",{className:"relative mt-[24px] grid grid-cols-4 gap-[16px] md:grid-cols-2 md-xl:grid-cols-3",children:b?.map((a,o)=>(0,r.jsx)(y.default,{copy:e,itemData:a,setRules:g,className:m,currencyCode:C?.[0]?.price.currencyCode||"USD",authCodeActivate:i},o))}),p&&(0,r.jsx)(I.default,{overlayClassName:"md:px-[16px] md:items-center",className:"md:h-fit md:rounded-b-[16px]",isOpen:p.length>0,onClose:()=>g([]),titleClassName:"border-b-transparent h-[56px]",rules:p,scrollClassName:"md:mt-[8px] md:mb-[24px] md:pt-0",title:e?.ruleLabel,ruleClassName:"text-[#1d1d1f] font-bold"})]})};
2
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/components/credits/creditsCash/index.tsx"],
4
- "sourcesContent": ["import { Container, Heading } from '@anker-in/headless-ui'\nimport { useMemo, useState } from 'react'\n\nimport RedeemableItem from './RedeemableItem'\nimport useRedeemableList from '../context/hooks/useRedeemableList'\nimport { cn } from '../../../helpers'\nimport RulesModal from '../modal/rulesModal'\nimport { useProductsByHandles } from '../../../shopify/hooks/useProductsByHandles'\nimport { CreditsCashCopy, RedeemItem } from './type'\nimport { Product } from 'src/shopify/types'\n\nexport const CreditsCash = ({\n copy,\n className = '',\n hideTitle = false,\n cardClassName,\n authCodeActivate,\n}: {\n copy: CreditsCashCopy\n className?: string\n hideTitle?: boolean\n cardClassName?: string\n authCodeActivate: {\n openAuthCodePopup: Function\n isSuccess: boolean\n setOnSuccess: (arg: Function) => void\n isSendingActivateEmail: boolean\n }\n}) => {\n const [rules, setRules] = useState<string | string[]>()\n const { redeemableList } = useRedeemableList()\n\n // Temporary variables until proper configuration\n const locale = 'us'\n const variantMetafieldIdentifiers: any[] = []\n\n const { data: productByHandles } = useProductsByHandles({\n locale,\n handles: copy?.list?.map(item => item.products?.[0]?.handle) || [],\n metafieldIdentifiers: {\n variant: variantMetafieldIdentifiers,\n },\n })\n\n const list = useMemo(() => {\n return productByHandles?.map((product: Product) => {\n const config = copy.list.find(item => item.products?.[0]?.handle === product.handle)\n const alpcData = redeemableList.find(item => item.id?.toString() === config?.redeemId?.toString())\n\n return {\n product,\n productVariant:\n product.variants?.find((variant: any) => variant.sku === config?.products?.[0]?.sku) || product.variants?.[0],\n alpcData: {\n id: alpcData?.id,\n consumeCredits: alpcData?.consume_credits,\n remainingInventory: alpcData?.remaining_inventory,\n isLimited: alpcData?.is_limited,\n consumeType: alpcData?.consume_type,\n title: alpcData?.name,\n desc: alpcData?.note,\n },\n config,\n }\n }) as unknown as RedeemItem[]\n }, [productByHandles, copy.list, redeemableList])\n\n console.log('list', list)\n\n return (\n <Container className={cn('bg-[#F5F5F5]', className)}>\n {!hideTitle && <Heading as=\"h2\" size=\"4\" html={copy.title} />}\n <div className=\"relative mt-[24px] grid grid-cols-4 gap-[16px] md:grid-cols-2 md-xl:grid-cols-3\">\n {list?.map((item, index: number) => (\n <RedeemableItem\n key={index}\n copy={copy}\n itemData={item}\n setRules={setRules}\n className={cardClassName}\n currencyCode={productByHandles?.[0]?.price.currencyCode || 'USD'}\n authCodeActivate={authCodeActivate}\n />\n ))}\n </div>\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": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GAsEI,IAAAI,EAAA,6BAtEJC,EAAmC,iCACnCC,EAAkC,iBAElCC,EAA2B,+BAC3BC,EAA8B,iDAC9BC,EAAmB,4BACnBC,EAAuB,kCACvBC,EAAqC,uDAI9B,MAAMT,EAAc,CAAC,CAC1B,KAAAU,EACA,UAAAC,EAAY,GACZ,UAAAC,EAAY,GACZ,cAAAC,EACA,iBAAAC,CACF,IAWM,CACJ,KAAM,CAACC,EAAOC,CAAQ,KAAI,YAA4B,EAChD,CAAE,eAAAC,CAAe,KAAI,EAAAC,SAAkB,EAGvCC,EAAS,KACTC,EAAqC,CAAC,EAEtC,CAAE,KAAMC,CAAiB,KAAI,wBAAqB,CACtD,OAAAF,EACA,QAAST,GAAM,MAAM,IAAIY,GAAQA,EAAK,WAAW,CAAC,GAAG,MAAM,GAAK,CAAC,EACjE,qBAAsB,CACpB,QAASF,CACX,CACF,CAAC,EAEKG,KAAO,WAAQ,IACZF,GAAkB,IAAKG,GAAqB,CACjD,MAAMC,EAASf,EAAK,KAAK,KAAKY,GAAQA,EAAK,WAAW,CAAC,GAAG,SAAWE,EAAQ,MAAM,EAC7EE,EAAWT,EAAe,KAAKK,GAAQA,EAAK,IAAI,SAAS,IAAMG,GAAQ,UAAU,SAAS,CAAC,EAEjG,MAAO,CACL,QAAAD,EACA,eACEA,EAAQ,UAAU,KAAMG,GAAiBA,EAAQ,MAAQF,GAAQ,WAAW,CAAC,GAAG,GAAG,GAAKD,EAAQ,WAAW,CAAC,EAC9G,SAAU,CACR,GAAIE,GAAU,GACd,eAAgBA,GAAU,gBAC1B,mBAAoBA,GAAU,oBAC9B,UAAWA,GAAU,WACrB,YAAaA,GAAU,aACvB,MAAOA,GAAU,KACjB,KAAMA,GAAU,IAClB,EACA,OAAAD,CACF,CACF,CAAC,EACA,CAACJ,EAAkBX,EAAK,KAAMO,CAAc,CAAC,EAEhD,eAAQ,IAAI,OAAQM,CAAI,KAGtB,QAAC,aAAU,aAAW,MAAG,eAAgBZ,CAAS,EAC/C,WAACC,MAAa,OAAC,WAAQ,GAAG,KAAK,KAAK,IAAI,KAAMF,EAAK,MAAO,KAC3D,OAAC,OAAI,UAAU,kFACZ,SAAAa,GAAM,IAAI,CAACD,EAAMM,OAChB,OAAC,EAAAC,QAAA,CAEC,KAAMnB,EACN,SAAUY,EACV,SAAUN,EACV,UAAWH,EACX,aAAcQ,IAAmB,CAAC,GAAG,MAAM,cAAgB,MAC3D,iBAAkBP,GANbc,CAOP,CACD,EACH,EAECb,MACC,OAAC,EAAAe,QAAA,CACC,iBAAiB,+BACjB,UAAU,+BACV,OAAQf,EAAM,OAAS,EACvB,QAAS,IAAMC,EAAS,CAAC,CAAC,EAC1B,eAAe,gCACf,MAAOD,EACP,gBAAgB,mCAChB,MAAOL,GAAM,UACb,cAAc,2BAChB,GAEJ,CAEJ",
6
- "names": ["creditsCash_exports", "__export", "CreditsCash", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_react", "import_RedeemableItem", "import_useRedeemableList", "import_helpers", "import_rulesModal", "import_useProductsByHandles", "copy", "className", "hideTitle", "cardClassName", "authCodeActivate", "rules", "setRules", "redeemableList", "useRedeemableList", "locale", "variantMetafieldIdentifiers", "productByHandles", "item", "list", "product", "config", "alpcData", "variant", "index", "RedeemableItem", "RulesModal"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/components/credits/creditsCash/type.ts"],
4
- "sourcesContent": ["import { ProductVariant, Product } from 'src/shopify/types'\nimport { AlpcConsumeType } from '../context/const'\n\ntype RedeemableItemConfig = {\n title: string\n desc: string\n price: string\n credit: string\n rules: string\n image: {\n url: string\n }\n mobileImage: {\n url: string\n }\n redeemId: number\n}\n\nexport type CreditsCashCopy = {\n title: string\n list: (RedeemableItemConfig & {\n products: { handle: string; sku: string }[]\n })[]\n soldOut: string\n ruleLabel: string\n unlockRewards: string\n btnRedeem: string\n off: string\n insufficientCredits: string\n}\n\nexport type RedeemItem = {\n product: Product\n productVariant: ProductVariant\n alpcData: {\n id: number\n consumeCredits: number\n remainingInventory: number\n isLimited: boolean\n consumeType: AlpcConsumeType.Product\n showCredit: boolean\n title: string\n desc: string\n }\n config: RedeemableItemConfig\n}\n"],
5
- "mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
- "names": ["type_exports", "__toCommonJS"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";var z=Object.create;var y=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var M=(r,s)=>{for(var d in s)y(r,d,{get:s[d],enumerable:!0})},F=(r,s,d,m)=>{if(s&&typeof s=="object"||typeof s=="function")for(let c of D(s))!L.call(r,c)&&c!==d&&y(r,c,{get:()=>s[c],enumerable:!(m=B(s,c))||m.enumerable});return r};var R=(r,s,d)=>(d=r!=null?z(E(r)):{},F(s||!r||!r.__esModule?y(d,"default",{value:r,enumerable:!0}):d,r)),G=r=>F(y({},"__esModule",{value:!0}),r);var T={};M(T,{AddressForm:()=>O});module.exports=G(T);var n=require("react/jsx-runtime"),C=R(require("classnames")),l=require("react"),S=require("./CountrySelect"),_=require("./FormItem"),w=require("./Input"),I=require("./StateSelect"),q=require("../../context/const"),P=require("../../context/provider"),K=require("../../../../shopify/context/ShopifyProvider");const O=({countries:r,countriesLoading:s,form:d,validate:m,errors:c,onChange:p})=>{const{profile:v,customer:t}=(0,P.useCreditsContext)(),{locale:b}=(0,K.useShopifyContext)(),[e,f]=(0,l.useState)(),A=(0,l.useMemo)(()=>r.find(u=>u.code===e?.country)?.provinces||[],[e,r]),h=(0,l.useMemo)(()=>d?.flat().find(u=>u.type==="state")?.key,[d]),k=(0,l.useCallback)(()=>{if(t?.defaultAddress)return{name:(t?.defaultAddress.firstName||"")+" "+(t?.defaultAddress.lastName||""),first_name:t?.defaultAddress.firstName,last_name:t?.defaultAddress.lastName,address1:t?.defaultAddress.address1,address2:t?.defaultAddress.address2,city:t?.defaultAddress.city,phone:t?.defaultAddress.phone,country:t?.defaultAddress.countryCodeV2,province:t?.defaultAddress.province,province_code:t?.defaultAddress.provinceCode,email:t?.email||v?.email,zip:t?.defaultAddress.zip};{let a=q.ALPC_COUNTRY_MAP.get(b)||b;return a==="UK"&&(a="GB"),a==="EU"&&(a="NL"),{email:v?.email,country:a}}},[t,v?.email,b]);return console.log("customer",t),(0,l.useEffect)(()=>{if(t){const a=k();f(a),p(a)}},[t,k]),e?(0,n.jsx)("div",{className:"grid gap-[20px]",children:d&&d.map((a,u)=>(0,n.jsx)("div",{className:"item-center -mx-[6px] flex",children:a.map((o,U)=>{const g=c.find(i=>i.key===o.key)?.message,x=(0,C.default)("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",g?"!border-[#F84D4F]":"border-[#d8d8d8]");return o.type==="state"&&!A.length?null:(0,n.jsx)("div",{className:(0,C.default)("mx-[6px] flex-1"),children:(0,n.jsxs)(_.FormItem,{error:g,required:o.required,label:o.label,children:[o.type==="country"&&(0,n.jsx)(S.CountrySelect,{className:x,countries:r,loading:s,value:e.country,onChange:i=>{e.country!==i&&(e.province="",e.province_code=""),e.country=i,f({...e}),p(e)}}),o.type==="state"&&(0,n.jsx)(I.StateSelect,{className:x,states:A,stateCode:e.province_code,stateName:e.province,onChange:(i,N)=>{e.province_code=i,e.province=N,f({...e}),p(e)}}),o.type!=="state"&&o.type!=="country"&&(0,n.jsx)(w.Input,{placeholder:o.label,className:x,error:g,value:e[o.key],required:o.required,disabled:o.type==="email",onChange:i=>{const N=i.target.value;e[o.key]=N,f({...e}),p(e)},onBlur:()=>{m({ignoreKeys:A.length&&h?[h]:[]})}})]})},U)})},u))}):null};
2
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
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 { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'\nimport { AddressFormProps } from './type'\n\nexport const AddressForm = ({ countries, countriesLoading, form, validate, errors, onChange }: AddressFormProps) => {\n const { profile, customer } = useCreditsContext()\n const { locale } = useShopifyContext()\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": "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",
6
- "names": ["AddressForm_exports", "__export", "AddressForm", "__toCommonJS", "import_jsx_runtime", "import_classnames", "import_react", "import_CountrySelect", "import_FormItem", "import_Input", "import_StateSelect", "import_const", "import_provider", "import_ShopifyProvider", "countries", "countriesLoading", "form", "validate", "errors", "onChange", "profile", "customer", "locale", "address", "setAddress", "states", "item", "stateInputKey", "getDefaultAddress", "defaultCountry", "defaultAddress", "row", "rowIndex", "input", "inputIndex", "error", "inputClassName", "classNames", "selectedCountryCode", "provinceCode", "provinceName", "event", "value"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";var B=Object.create;var f=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var A=(o,t)=>{for(var i in t)f(o,i,{get:t[i],enumerable:!0})},E=(o,t,i,m)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of P(t))!U.call(o,a)&&a!==i&&f(o,a,{get:()=>t[a],enumerable:!(m=z(t,a))||m.enumerable});return o};var w=(o,t,i)=>(i=o!=null?B(O(o)):{},E(t||!o||!o.__esModule?f(i,"default",{value:o,enumerable:!0}):i,o)),D=o=>E(f({},"__esModule",{value:!0}),o);var j={};A(j,{default:()=>$});module.exports=D(j);var e=require("react/jsx-runtime"),d=require("@anker-in/headless-ui"),g=w(require("classnames")),r=require("react"),F=w(require("../context/hooks/useCopy")),R=require("../context/provider"),T=require("../context/hooks/useRedeemCoupon"),c=require("../context/const"),k=require("../modal/modalContainer"),I=require("../context/utils"),L=require("../../../shopify/context/ShopifyProvider");function K({item:o,copy:t,onError:i,...m}){const{locale:a}=(0,L.useShopifyContext)(),[n,S]=(0,r.useState)(),[C,x]=(0,r.useState)(),[b,p]=(0,r.useState)(!1),{copy:y,copied:v}=(0,F.default)(),{profile:u,fetchCreditInfo:N}=(0,R.useCreditsContext)(),{isMutating:h,trigger:M}=(0,T.useRedeemCoupon)({onSuccess(l){if(!l){x(t.redeemModal.commonError);return}if(l?.data?.success)S(l.data.coupon_code),N(u?.user_id);else{let s;l.code===c.AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit?(s=t.redeemModal.redeemLimitError,p(!0)):l.code===c.AlpcErrorCode.CodeLpcRuleInventoryNotEnough?(s=t.redeemModal.inventoryNotEnough,p(!0)):l.code===c.AlpcErrorCode.CodeLpcNotEnoughCredits?(s=t.redeemModal.creditsNotEnough,p(!0),N(u?.user_id)):l.code===c.AlpcErrorCode.CodeCrossSiteError&&(s=t.redeemModal.crossSiteError,p(!0)),x(s||t.redeemModal.commonError||""),i&&i(l.code)}},onError(l){x(l.message||t.redeemModal.commonError)}}),_=(0,r.useCallback)(async()=>{x(""),M({user_id:u?.user_id,rule_id:Number(o.alpc?.id)})},[o,u,M]);return(0,r.useEffect)(()=>{m.isOpen||(p(!1),x(""))},[m.isOpen]),(0,e.jsxs)(k.CreditsModalContainer,{...m,className:"w-[540px] md:h-auto",scrollClassName:"mb-[40px] min-l:px-0 md:mb-[24px] px-0",titleClassName:"h-[56px] bg-[#F5F5F7]",children:[(0,e.jsxs)("div",{className:(0,g.default)("max-h-[500px] overflow-y-auto bg-[#F5F5F7] px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]"),children:[(0,e.jsxs)("div",{className:"relative mx-auto h-[164px] w-[324px]",children:[t?.imageMapping?.coupon?.url&&(0,e.jsx)(d.Picture,{source:t?.imageMapping?.coupon?.url,className:"h-full [&_img]:h-full"}),(0,e.jsx)("div",{className:"absolute bottom-[8px] left-[16px] font-extrabold text-white",children:o.config.value?(0,e.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,e.jsx)(d.Text,{className:"text-[64px] font-bold leading-none",html:o.config.value.toString()}),(0,e.jsx)(d.Text,{className:"text-[24px] font-bold leading-[2]",html:t?.off})]}):(0,e.jsx)(d.Text,{size:3,html:o.alpc?.title})})]}),n?(0,e.jsxs)("div",{className:"mt-[30px] flex items-center justify-center md:mt-[18px]",children:[(0,e.jsx)("div",{className:"mr-[10px] text-[24px] font-bold leading-[1.4] md:leading-[1.2]",children:n}),(0,e.jsx)("div",{className:(0,g.default)("cursor-pointer text-[16px] font-bold leading-[1.2] underline md:text-[14px]",v?"pointer-events-none":"pointer-events-auto"),onClick:()=>{y(n)},role:"button",tabIndex:0,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&l.preventDefault()},children:v?t?.copied:t?.copy})]}):(0,e.jsxs)(d.Text,{as:"p",className:(0,g.default)("mt-[30px] text-center text-[24px] font-bold leading-[1.2] md:mt-[18px] md:text-[20px] md:leading-[1.2]"),children:[(0,I.numberFormat)(o.alpc?.consumeCredits)," ",t?.pointUnit]}),!n&&o.config?.rules?.length>0&&(0,e.jsxs)("div",{className:"mt-[18px] w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]",children:[(0,e.jsxs)("div",{className:"mb-[4px]",children:[t?.ruleLabel,":"]}),(0,e.jsx)("ul",{className:"ml-4 grid grid-flow-row gap-[4px]",children:o.config?.rules?.map((l,s)=>(0,e.jsx)("li",{className:"list-disc",children:(0,e.jsx)(d.Text,{html:l})},s))})]})]}),(0,e.jsxs)("div",{className:"bg-white px-[48px] pt-[24px] text-center md:px-[16px]",children:[n&&!h?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)(d.Text,{className:"mb-[4px] text-[24px] font-bold leading-[1.2] md:text-[20px]",html:t.redeemModal.coupon.successTitle}),(0,e.jsx)(d.Text,{className:"text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:text-[14px]",html:t.redeemModal.coupon.successDesc})]}),(0,e.jsx)(d.Button,{variant:"primary",size:"lg",className:"mt-[16px] w-full",onClick:()=>{window.location.href=t.redeemModal.coupon.successButtonUrl||`/${a}`,m.onClose&&m.onClose()},disabled:b,children:t.redeemModal.coupon.successButton})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(d.Text,{className:"block text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]",html:t.redeemModal.confirmTitle}),(0,e.jsx)(d.Button,{loading:h,variant:"primary",size:"lg",className:"mt-[16px] w-full",onClick:_,disabled:b,children:t.redeemModal.confirmButton})]}),C&&(0,e.jsx)("div",{className:"mx-auto max-w-full py-[12px] text-center",children:(0,e.jsx)(d.Text,{className:"text-[14px] font-semibold text-[#1F2021]",html:C})})]})]})}var $=K;
2
- //# sourceMappingURL=RedeemCouponModal.js.map
@@ -1,7 +0,0 @@
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 { useShopifyContext } from '../../../shopify/context/ShopifyProvider'\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 } = useShopifyContext()\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": "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",
6
- "names": ["RedeemCouponModal_exports", "__export", "RedeemCouponModal_default", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_classnames", "import_react", "import_useCopy", "import_provider", "import_useRedeemCoupon", "import_const", "import_modalContainer", "import_utils", "import_ShopifyProvider", "RedeemCouponModal", "item", "copy", "onError", "props", "locale", "couponCode", "setCouponCode", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "copyText", "copiedStatus", "useCopy", "profile", "fetchCreditInfo", "loading", "trigger", "responseData", "errorMsg", "error", "handleConfirm", "classNames", "e", "text", "index"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";var A=Object.create;var m=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var I=(e,o)=>{for(var s in o)m(e,s,{get:o[s],enumerable:!0})},n=(e,o,s,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let d of w(o))!T.call(e,d)&&d!==s&&m(e,d,{get:()=>o[d],enumerable:!(i=F(o,d))||i.enumerable});return e};var p=(e,o,s)=>(s=e!=null?A(L(e)):{},n(o||!e||!e.__esModule?m(s,"default",{value:e,enumerable:!0}):s,e)),P=e=>n(m({},"__esModule",{value:!0}),e);var B={};I(B,{Address:()=>k});module.exports=P(B);var t=require("react/jsx-runtime"),r=require("@anker-in/headless-ui"),l=p(require("classnames")),x=require("../AddressForm"),c=require("../../../../shopify/context/ShopifyProvider"),f=require("./ProductInfo"),u=p(require("../../context/hooks/useCountries"));const k=({copy:e,shippingAddress:o,setAddress:s,validateAddress:i,validateErrors:d,shippingProduct:a,loading:y,address:v,disabled:b,handlePayment:g,item:h})=>{const{storeDomain:C}=(0,c.useShopifyContext)(),{countries:N=[],isLoading:R}=(0,u.default)({shopifyStoreDomain:C});return(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:(0,l.default)("max-h-[500px] overflow-y-auto px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]"),children:(0,t.jsxs)("div",{children:[o&&(0,t.jsx)(r.Text,{className:"mb-5 text-[16px] font-bold",html:o}),(0,t.jsx)(x.AddressForm,{onChange:s,validate:i,errors:d,form:e.redeemModal.product.addressForm,countries:N,countriesLoading:R})]})}),(0,t.jsxs)("div",{className:"sticky bottom-0 flex flex-col items-center justify-center bg-white px-[48px] py-[24px] l:px-[16px]",children:[(0,t.jsxs)("div",{className:"flex w-full items-center rounded-[16px] bg-[#F5F5F7] p-[16px]",children:[a&&(0,t.jsx)(r.Text,{className:"mb-5 text-[16px] font-bold",html:a}),(0,t.jsx)(f.ProductInfo,{item:h,copy:e})]}),(0,t.jsx)(r.Button,{loading:y||!v,variant:"primary",className:"mx-auto mt-[16px] w-[444px] md:mt-[12px] md:w-full",onClick:g,disabled:b,children:e.redeemModal.product.paymentButton})]})]})};
2
- //# sourceMappingURL=Address.js.map
@@ -1,7 +0,0 @@
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 { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'\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 } = useShopifyContext()\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": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA0CQ,IAAAI,EAAA,6BA1CRC,EAA6B,iCAC7BC,EAAuB,yBACvBC,EAA4B,0BAC5BC,EAAkC,uDAGlCC,EAA4B,yBAC5BC,EAAyB,+CAgBlB,MAAMR,EAAU,CAAC,CACtB,KAAAS,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,KAAI,qBAAkB,EACpC,CAAE,UAAAC,EAAY,CAAC,EAAG,UAAWC,CAAiB,KAAI,EAAAC,SAAa,CAAE,mBAAoBH,CAAY,CAAC,EAExG,SACE,QAAC,OAAI,UAAU,WACb,oBAAC,OAAI,aAAW,EAAAI,SAAW,iFAAiF,EAC1G,oBAAC,OACE,UAAAd,MAAmB,OAAC,QAAK,UAAU,6BAA6B,KAAMA,EAAiB,KACxF,OAAC,eACC,SAAUC,EACV,SAAUC,EACV,OAAQC,EACR,KAAMJ,EAAK,YAAY,QAAQ,YAC/B,UAAWY,EACX,iBAAkBC,EACnB,GACH,EACF,KACA,QAAC,OAAI,UAAU,qGACb,qBAAC,OAAI,UAAU,gEACZ,UAAAR,MAAmB,OAAC,QAAK,UAAU,6BAA6B,KAAMA,EAAiB,KACxF,OAAC,eAAY,KAAMK,EAAM,KAAMV,EAAM,GACvC,KACA,OAAC,UACC,QAASM,GAAW,CAACC,EACrB,QAAQ,UACR,UAAU,qDACV,QAASE,EACT,SAAUD,EAET,SAAAR,EAAK,YAAY,QAAQ,cAC5B,GACF,GACF,CAEJ",
6
- "names": ["Address_exports", "__export", "Address", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_classnames", "import_AddressForm", "import_ShopifyProvider", "import_ProductInfo", "import_useCountries", "copy", "shippingAddress", "setAddress", "validateAddress", "validateErrors", "shippingProduct", "loading", "address", "disabled", "handlePayment", "item", "storeDomain", "countries", "countriesLoading", "useCountries", "classNames"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";var s=Object.defineProperty;var o=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var x=(t,a)=>{for(var d in a)s(t,d,{get:a[d],enumerable:!0})},u=(t,a,d,i)=>{if(a&&typeof a=="object"||typeof a=="function")for(let m of c(a))!n.call(t,m)&&m!==d&&s(t,m,{get:()=>a[m],enumerable:!(i=o(a,m))||i.enumerable});return t};var f=t=>u(s({},"__esModule",{value:!0}),t);var b={};x(b,{ProductInfo:()=>v});module.exports=f(b);var e=require("react/jsx-runtime"),l=require("@anker-in/headless-ui"),r=require("../../context/utils"),p=require("../../../../shopify/context/ShopifyProvider");const v=({item:t,copy:a})=>{const{locale:d}=(0,p.useShopifyContext)();return(0,e.jsxs)("div",{className:"flex w-full items-center justify-center md:items-start md:justify-start",children:[(0,e.jsx)(l.Picture,{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}),(0,e.jsxs)("div",{className:"md:flex md:flex-col",children:[(0,e.jsxs)("div",{className:"md:flex md:items-center",children:[(0,e.jsx)(l.Picture,{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}),(0,e.jsx)("div",{className:"flex-1 text-[16px] font-bold leading-[1.4] min-l:!hidden",title:t.product.title,children:t.product.title})]}),(0,e.jsxs)("div",{className:"mt-[16px] md:mt-[12px]",children:[(0,e.jsx)("div",{className:"mb-[12px] line-clamp-1 text-[16px] font-bold l:!hidden",title:t.product.title,children:t.product.title}),(0,e.jsxs)("div",{className:"flex font-semibold leading-[1.4] md:flex-col",children:[(0,e.jsxs)("div",{className:"mr-[40px] text-[15px] font-bold text-[#777] md:mr-0 md:text-[12px]",children:[(0,e.jsxs)("div",{className:"mb-[8px] flex items-center md:mb-[4px]",children:[(0,e.jsxs)("span",{children:[a.redeemModal.product.variantLabel,": "]}),(0,e.jsx)("span",{className:"ml-1",children:t.variant.title||""})]}),(0,e.jsxs)("div",{className:"mb-[8px] flex items-center md:mb-[4px]",children:[(0,e.jsxs)("span",{children:[a.redeemModal.product.shippingFeeLabel,": "]}),(0,e.jsx)("span",{className:"ml-1",children:(0,r.formatPrice)({amount:0,currencyCode:t.product.price?.currencyCode,locale:d||"us"})})]})]}),(0,e.jsxs)("div",{className:"text-[15px] font-bold text-[#777] md:text-[12px]",children:[(0,e.jsxs)("div",{className:"mb-[8px] flex items-center md:mb-[4px]",children:[(0,e.jsxs)("span",{children:[a.redeemModal.product.quantityLabel,": "]}),(0,e.jsx)("span",{className:"ml-1",children:"1"})]}),(0,e.jsxs)("div",{className:"l:flex l:items-center l:justify-between",children:[(0,e.jsxs)("span",{children:[a.redeemModal.product.totalPriceLabel,": "]}),(0,e.jsxs)("span",{className:"ml-1",children:[t.alpc?.consumeCredits," ",a?.pointUnit]})]})]})]})]})]})]})};
2
- //# sourceMappingURL=ProductInfo.js.map
@@ -1,7 +0,0 @@
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 { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'\n\ntype ProductInfoProps = {\n item: RedeemableItemType\n copy: CreditsRedeemListCopy\n}\n\nexport const ProductInfo = ({ item, copy }: ProductInfoProps) => {\n const { locale } = useShopifyContext()\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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GAgBM,IAAAI,EAAA,6BAhBNC,EAAwB,iCACxBC,EAA4B,+BAG5BC,EAAkC,uDAO3B,MAAML,EAAc,CAAC,CAAE,KAAAM,EAAM,KAAAC,CAAK,IAAwB,CAC/D,KAAM,CAAE,OAAAC,CAAO,KAAI,qBAAkB,EAErC,SACE,QAAC,OAAI,UAAU,0EACb,oBAAC,WACC,UAAU,6HACV,OAAQF,EAAK,QAAQ,OAAO,KAAOA,EAAK,SAAS,OAAO,CAAC,GAAG,IAC5D,IAAKA,EAAK,QAAQ,MACnB,KACD,QAAC,OAAI,UAAU,sBACb,qBAAC,OAAI,UAAU,0BACb,oBAAC,WACC,UAAU,iIACV,OAAQA,EAAK,QAAQ,OAAO,KAAOA,EAAK,SAAS,OAAO,CAAC,GAAG,IAC5D,IAAKA,EAAK,QAAQ,MACnB,KACD,OAAC,OAAI,UAAU,2DAA2D,MAAOA,EAAK,QAAQ,MAC3F,SAAAA,EAAK,QAAQ,MAChB,GACF,KAEA,QAAC,OAAI,UAAU,yBACb,oBAAC,OAAI,UAAU,yDAAyD,MAAOA,EAAK,QAAQ,MACzF,SAAAA,EAAK,QAAQ,MAChB,KACA,QAAC,OAAI,UAAU,+CACb,qBAAC,OAAI,UAAU,qEACb,qBAAC,OAAI,UAAU,yCACb,qBAAC,QAAM,UAAAC,EAAK,YAAY,QAAQ,aAAa,MAAE,KAC/C,OAAC,QAAK,UAAU,OAAQ,SAAAD,EAAK,QAAQ,OAAS,GAAG,GACnD,KACA,QAAC,OAAI,UAAU,yCACb,qBAAC,QAAM,UAAAC,EAAK,YAAY,QAAQ,iBAAiB,MAAE,KACnD,OAAC,QAAK,UAAU,OACb,2BAAY,CACX,OAAQ,EACR,aAAcD,EAAK,QAAQ,OAAO,aAClC,OAAQE,GAAU,IACpB,CAAC,EACH,GACF,GACF,KACA,QAAC,OAAI,UAAU,mDACb,qBAAC,OAAI,UAAU,yCACb,qBAAC,QAAM,UAAAD,EAAK,YAAY,QAAQ,cAAc,MAAE,KAChD,OAAC,QAAK,UAAU,OAAO,aAAC,GAC1B,KACA,QAAC,OAAI,UAAU,0CACb,qBAAC,QAAM,UAAAA,EAAK,YAAY,QAAQ,gBAAgB,MAAE,KAClD,QAAC,QAAK,UAAU,OACb,UAAAD,EAAK,MAAM,eAAe,IAAEC,GAAM,WACrC,GACF,GACF,GACF,GACF,GACF,GACF,CAEJ",
6
- "names": ["ProductInfo_exports", "__export", "ProductInfo", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_utils", "import_ShopifyProvider", "item", "copy", "locale"]
7
- }
@@ -1,2 +0,0 @@
1
- "use strict";var W=Object.create;var g=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var Z=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var j=(r,e)=>{for(var t in e)g(r,t,{get:e[t],enumerable:!0})},N=(r,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Y(e))!$.call(r,i)&&i!==t&&g(r,i,{get:()=>e[i],enumerable:!(a=X(e,i))||a.enumerable});return r};var S=(r,e,t)=>(t=r!=null?W(Z(r)):{},N(e||!r||!r.__esModule?g(t,"default",{value:r,enumerable:!0}):t,r)),D=r=>N(g({},"__esModule",{value:!0}),r);var oe={};j(oe,{default:()=>re});module.exports=D(oe);var l=require("react/jsx-runtime"),v=S(require("classnames")),s=require("react"),y=require("../../context/provider"),L=S(require("../../context/hooks/useCountries")),f=require("../../context/const"),x=require("../../context/hooks/useAddressValidate"),U=require("../../context/hooks/useRedeemProduct"),O=require("../../modal/modalContainer"),q=require("../../../../shopify/context/ShopifyProvider"),w=require("./Error"),F=require("./Success"),K=require("./Address"),_=require("./Init");function ee({item:r,copy:e,onError:t,...a}){const{fetchCreditInfo:i,profile:b}=(0,y.useCreditsContext)(),{storeDomain:k,locale:T}=(0,q.useShopifyContext)(),{validatorInfo:B}=e,{shippingAddress:G,shippingProduct:P}=e.redeemModal.product,[m,c]=(0,s.useState)("init"),[n,J]=(0,s.useState)(),[V,p]=(0,s.useState)({code:0,message:"",imageUrl:""}),[C,u]=(0,s.useState)(!1),{countries:R=[],isLoading:de}=(0,L.default)({shopifyStoreDomain:k}),{isMutating:M,trigger:A}=(0,U.useRedeemProduct)({onSuccess(o){if(!o){c("error"),p({code:0,imageUrl:e.redeemModal.errorImageUrl||"",message:e.redeemModal.commonError||""});return}if(o?.code===0)i(b?.user_id),c("success");else{let d,I;o.code===f.AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit?(d=e.redeemModal.redeemLimitError,u(!0)):o.code===f.AlpcErrorCode.CodeLpcRuleInventoryNotEnough?(d=e.redeemModal.inventoryNotEnough,u(!0),I=e.redeemModal.inventoryNotEnough):o.code===f.AlpcErrorCode.CodeLpcNotEnoughCredits?(d=e.redeemModal.creditsNotEnough,u(!0),i(b?.user_id)):o.code===f.AlpcErrorCode.CodeCrossSiteError&&(d=e.redeemModal.crossSiteError,u(!0)),c("error"),p({code:o.code,imageUrl:I||e.redeemModal.errorImageUrl||"",message:d||e.redeemModal.commonError||""}),t&&t(o.code)}},onError(o){c("error"),p({code:0,imageUrl:e.redeemModal.errorImageUrl||"",message:e.redeemModal.commonError||""})}}),h=(0,s.useMemo)(()=>e?.redeemModal.product.form?.flat().find(d=>d.type==="state")?.key,[e?.redeemModal.product.form]),{validate:E,errors:z}=(0,x.useAddressValidate)({address:n,validatorInfo:B,formData:e?.redeemModal.product.form?.flat()||[],errorLabel:{require:e.redeemModal.product.required,email:e.redeemModal.product.invalidEmail}}),H=(0,s.useCallback)(async()=>{const o=[];if(h&&((R.find(Q=>Q.code===n.country)?.provinces||[]).length||o.push(h)),E({force:!0,ignoreKeys:o}))return;console.log("address",n);let d={...n};d.name&&delete d.name,d.country==="UK"&&(d.country="GB"),A({address:btoa(JSON.stringify(d)),rule_id:Number(r.alpc?.id)})},[r,A,h,E,n,R]);return(0,s.useEffect)(()=>{a.isOpen||(u(!1),p({code:0,message:"",imageUrl:""}))},[a.isOpen,T]),(0,l.jsxs)(O.CreditsModalContainer,{...a,className:(0,v.default)("w-[540px] md:h-auto min-md:max-h-[calc(100vh-40px)]",m!=="init"&&"w-[740px] md:w-full"),scrollClassName:"mb-0 min-l:px-0 md:mb-0 px-0",titleClassName:(0,v.default)("h-[56px]",m==="init"&&"bg-[#F5F5F7]"),title:m==="address"?"Order Confirmation":"",children:[m==="error"&&(0,l.jsx)(w.Error,{errorInfo:V}),m==="success"&&(0,l.jsx)(F.Success,{copy:e,shippingProduct:P,loading:M,address:n,disabled:C,onClose:a.onClose,item:r}),m==="address"&&(0,l.jsx)(K.Address,{copy:e,shippingAddress:G,setAddress:J,validateAddress:E,validateErrors:z,shippingProduct:P,loading:M,address:n,disabled:C,handlePayment:H,item:r}),m==="init"&&(0,l.jsx)(_.Init,{item:r,copy:e,loading:M,disabled:C,setStatus:c})]})}var re=ee;
2
- //# sourceMappingURL=index.js.map