@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.
- package/dist/cjs/components/chat/chat-context.d.ts +101 -0
- package/dist/cjs/components/chat/{chatContext.js → chat-context.js} +1 -1
- package/dist/cjs/components/chat/{chatContext.js.map → chat-context.js.map} +2 -2
- package/dist/cjs/components/credits/context/hooks/useActivities.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useActivities.js.map +3 -3
- package/dist/cjs/components/credits/context/hooks/useMyRewards.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useMyRewards.js.map +3 -3
- package/dist/cjs/components/credits/context/hooks/useRedeemAndBuy.d.ts +1 -1
- package/dist/cjs/components/credits/context/hooks/useRedeemAndBuy.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useRedeemAndBuy.js.map +3 -3
- package/dist/cjs/components/credits/context/hooks/useRedeemCoupon.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useRedeemCoupon.js.map +3 -3
- package/dist/cjs/components/credits/context/hooks/useRedeemProduct.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useRedeemProduct.js.map +3 -3
- package/dist/cjs/components/credits/context/hooks/useRedeemableList.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useRedeemableList.js.map +3 -3
- package/dist/cjs/components/credits/context/hooks/useSendEmailValidation.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useSendEmailValidation.js.map +3 -3
- package/dist/cjs/components/credits/context/hooks/useSubscribed.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useSubscribed.js.map +3 -3
- package/dist/cjs/components/credits/credits-banner/index.d.ts +23 -0
- package/dist/cjs/components/credits/{creditsBanner → credits-banner}/index.js.map +2 -2
- package/dist/cjs/components/credits/credits-benefits/benefitItem.d.ts +19 -0
- package/dist/cjs/components/credits/{creditsBenefits → credits-benefits}/benefitItem.js.map +1 -1
- package/dist/cjs/components/credits/credits-benefits/iconInfo.d.ts +2 -0
- package/dist/cjs/components/credits/{creditsBenefits → credits-benefits}/iconInfo.js.map +1 -1
- package/dist/cjs/components/credits/credits-benefits/index.d.ts +12 -0
- package/dist/cjs/components/credits/{creditsBenefits → credits-benefits}/index.js.map +2 -2
- package/dist/cjs/components/credits/credits-cash/RedeemableItem.d.ts +15 -0
- package/dist/cjs/components/credits/{creditsCash → credits-cash}/RedeemableItem.js.map +1 -1
- package/dist/cjs/components/credits/credits-cash/index.d.ts +13 -0
- package/dist/cjs/components/credits/credits-cash/index.js +2 -0
- package/dist/cjs/components/credits/credits-cash/index.js.map +7 -0
- package/dist/cjs/components/credits/credits-cash/type.d.ts +47 -0
- package/dist/cjs/components/credits/credits-cash/type.js.map +7 -0
- package/dist/cjs/components/credits/credits-faq/faq-item/FaqItem.d.ts +13 -0
- package/dist/cjs/components/credits/credits-faq/faq-item/faq-item.d.ts +13 -0
- package/dist/cjs/components/credits/{creditsFaq/faqItem/FaqItem.js → credits-faq/faq-item/faq-item.js} +1 -1
- package/dist/cjs/components/credits/{creditsFaq/faqItem/FaqItem.js.map → credits-faq/faq-item/faq-item.js.map} +2 -2
- package/dist/cjs/components/credits/credits-faq/faqItem/FaqItem.d.ts +13 -0
- package/dist/cjs/components/credits/credits-faq/index.d.ts +16 -0
- package/dist/cjs/components/credits/{creditsFaq → credits-faq}/index.js.map +2 -2
- package/dist/cjs/components/credits/credits-info-card/index.d.ts +20 -0
- package/dist/cjs/components/credits/{creditsInfoCard → credits-info-card}/index.js.map +2 -2
- package/dist/cjs/components/credits/credits-redeem-list/AddressForm/Input.d.ts +13 -0
- package/dist/cjs/components/credits/credits-redeem-list/AddressForm/country-select.d.ts +14 -0
- package/dist/cjs/components/credits/credits-redeem-list/AddressForm/form-item.d.ts +6 -0
- package/dist/cjs/components/credits/credits-redeem-list/AddressForm/index.d.ts +2 -0
- package/dist/cjs/components/credits/credits-redeem-list/AddressForm/state-select.d.ts +15 -0
- package/dist/cjs/components/credits/credits-redeem-list/AddressForm/type.d.ts +26 -0
- package/dist/cjs/components/credits/credits-redeem-list/RedeemCouponModal.d.ts +9 -0
- package/dist/cjs/components/credits/credits-redeem-list/RedeemProductModal/Address.d.ts +20 -0
- package/dist/cjs/components/credits/credits-redeem-list/RedeemProductModal/Error.d.ts +8 -0
- package/dist/cjs/components/credits/credits-redeem-list/RedeemProductModal/Init.d.ts +11 -0
- package/dist/cjs/components/credits/credits-redeem-list/RedeemProductModal/ProductInfo.d.ts +8 -0
- package/dist/cjs/components/credits/credits-redeem-list/RedeemProductModal/Success.d.ts +13 -0
- package/dist/cjs/components/credits/credits-redeem-list/RedeemProductModal/index.d.ts +11 -0
- package/dist/cjs/components/credits/credits-redeem-list/RedeemableItem.d.ts +9 -0
- package/dist/cjs/components/credits/{creditsRedeemList → credits-redeem-list}/RedeemableItem.js.map +1 -1
- package/dist/cjs/components/credits/credits-redeem-list/address-form/Input.d.ts +13 -0
- package/dist/cjs/components/credits/{creditsRedeemList/AddressForm → credits-redeem-list/address-form}/Input.js.map +1 -1
- package/dist/cjs/components/credits/credits-redeem-list/address-form/country-select.d.ts +14 -0
- package/dist/cjs/components/credits/{creditsRedeemList/AddressForm/CountrySelect.js → credits-redeem-list/address-form/country-select.js} +1 -1
- package/dist/cjs/components/credits/{creditsRedeemList/AddressForm/CountrySelect.js.map → credits-redeem-list/address-form/country-select.js.map} +2 -2
- package/dist/cjs/components/credits/credits-redeem-list/address-form/form-item.d.ts +6 -0
- package/dist/cjs/components/credits/{creditsRedeemList/AddressForm/FormItem.js → credits-redeem-list/address-form/form-item.js} +1 -1
- package/dist/cjs/components/credits/{creditsRedeemList/AddressForm/FormItem.js.map → credits-redeem-list/address-form/form-item.js.map} +2 -2
- package/dist/cjs/components/credits/credits-redeem-list/address-form/index.d.ts +2 -0
- package/dist/cjs/components/credits/credits-redeem-list/address-form/index.js +2 -0
- package/dist/cjs/components/credits/credits-redeem-list/address-form/index.js.map +7 -0
- package/dist/cjs/components/credits/credits-redeem-list/address-form/state-select.d.ts +15 -0
- package/dist/cjs/components/credits/{creditsRedeemList/AddressForm/StateSelect.js → credits-redeem-list/address-form/state-select.js} +1 -1
- package/dist/cjs/components/credits/{creditsRedeemList/AddressForm/StateSelect.js.map → credits-redeem-list/address-form/state-select.js.map} +2 -2
- package/dist/cjs/components/credits/credits-redeem-list/address-form/type.d.ts +26 -0
- package/dist/cjs/components/credits/{creditsRedeemList/AddressForm → credits-redeem-list/address-form}/type.js.map +1 -1
- package/dist/cjs/components/credits/credits-redeem-list/index.d.ts +13 -0
- package/dist/cjs/components/credits/credits-redeem-list/index.js +2 -0
- package/dist/cjs/components/credits/credits-redeem-list/index.js.map +7 -0
- package/dist/cjs/components/credits/credits-redeem-list/redeem-coupon-modal.d.ts +9 -0
- package/dist/cjs/components/credits/credits-redeem-list/redeem-coupon-modal.js +2 -0
- package/dist/cjs/components/credits/credits-redeem-list/redeem-coupon-modal.js.map +7 -0
- package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/Address.d.ts +20 -0
- package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/Address.js +2 -0
- package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/Address.js.map +7 -0
- package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/Error.d.ts +8 -0
- package/dist/cjs/components/credits/{creditsRedeemList/RedeemProductModal → credits-redeem-list/redeem-product-modal}/Error.js.map +1 -1
- package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/Init.d.ts +11 -0
- package/dist/cjs/components/credits/{creditsRedeemList/RedeemProductModal → credits-redeem-list/redeem-product-modal}/Init.js.map +1 -1
- package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/ProductInfo.d.ts +8 -0
- package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/ProductInfo.js +2 -0
- package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/ProductInfo.js.map +7 -0
- package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/Success.d.ts +13 -0
- package/dist/cjs/components/credits/{creditsRedeemList/RedeemProductModal → credits-redeem-list/redeem-product-modal}/Success.js.map +1 -1
- package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/index.d.ts +11 -0
- package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/index.js +2 -0
- package/dist/cjs/components/credits/credits-redeem-list/redeem-product-modal/index.js.map +7 -0
- package/dist/cjs/components/credits/credits-redeem-list/type.d.ts +77 -0
- package/dist/cjs/components/credits/{creditsRedeemList → credits-redeem-list}/type.js.map +1 -1
- package/dist/cjs/components/credits/credits-ways-to-get-credits/index.d.ts +2 -0
- package/dist/cjs/components/credits/{creditsWaysToGetCredits → credits-ways-to-get-credits}/index.js.map +2 -2
- package/dist/cjs/components/credits/credits-ways-to-get-credits/type.d.ts +60 -0
- package/dist/cjs/components/credits/{creditsWaysToGetCredits → credits-ways-to-get-credits}/type.js.map +1 -1
- package/dist/cjs/components/credits/credits-ways-to-get-credits/useActions.d.ts +96 -0
- package/dist/cjs/components/credits/credits-ways-to-get-credits/useActions.js +2 -0
- package/dist/cjs/components/credits/credits-ways-to-get-credits/useActions.js.map +7 -0
- package/dist/cjs/components/credits/creditsCash/type.d.ts +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/AddressForm/country-select.d.ts +14 -0
- package/dist/cjs/components/credits/creditsRedeemList/AddressForm/form-item.d.ts +6 -0
- package/dist/cjs/components/credits/creditsRedeemList/AddressForm/state-select.d.ts +15 -0
- package/dist/cjs/components/credits/type.d.ts +1 -1
- package/dist/cjs/components/credits/type.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -6
- package/dist/cjs/index.js +726 -1
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/shopify/context/ShopifyProvider.d.ts +1 -1
- package/dist/cjs/shopify/context/index.d.ts +1 -0
- package/dist/cjs/shopify/context/shopify-provider.d.ts +10 -0
- package/dist/cjs/shopify/fetchers/create-cart.d.ts +1 -2
- package/dist/cjs/shopify/hooks/index.d.ts +2 -2
- package/dist/cjs/shopify/hooks/use-create-cart.d.ts +2 -0
- package/dist/cjs/shopify/hooks/use-products-by-handles.d.ts +4 -0
- package/dist/cjs/shopify/hooks/useProductsByHandles.d.ts +1 -1
- package/dist/cjs/shopify/types/index.d.ts +2 -0
- package/dist/cjs/tsconfig.tsbuildinfo +1 -0
- package/dist/esm/components/chat/chat-context.d.ts +101 -0
- package/dist/esm/components/chat/chat-context.js +2 -0
- package/dist/esm/components/chat/chat-context.js.map +7 -0
- package/dist/esm/components/credits/context/hooks/useActivities.js +1 -1
- package/dist/esm/components/credits/context/hooks/useActivities.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useAddressValidate.js +1 -1
- package/dist/esm/components/credits/context/hooks/useAddressValidate.js.map +3 -3
- package/dist/esm/components/credits/context/hooks/useAlpcFetch.js +1 -1
- package/dist/esm/components/credits/context/hooks/useAlpcFetch.js.map +3 -3
- package/dist/esm/components/credits/context/hooks/useCountries.js +1 -1
- package/dist/esm/components/credits/context/hooks/useCountries.js.map +3 -3
- package/dist/esm/components/credits/context/hooks/useMyRewards.js +1 -1
- package/dist/esm/components/credits/context/hooks/useMyRewards.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useRedeemAndBuy.d.ts +1 -1
- package/dist/esm/components/credits/context/hooks/useRedeemAndBuy.js +1 -1
- package/dist/esm/components/credits/context/hooks/useRedeemAndBuy.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useRedeemCoupon.js +1 -1
- package/dist/esm/components/credits/context/hooks/useRedeemCoupon.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useRedeemProduct.js +1 -1
- package/dist/esm/components/credits/context/hooks/useRedeemProduct.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useRedeemableList.js +1 -1
- package/dist/esm/components/credits/context/hooks/useRedeemableList.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useSendEmailValidation.js +1 -1
- package/dist/esm/components/credits/context/hooks/useSendEmailValidation.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useSubscribed.js +1 -1
- package/dist/esm/components/credits/context/hooks/useSubscribed.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useSubscriptions.js +1 -1
- package/dist/esm/components/credits/context/hooks/useSubscriptions.js.map +3 -3
- package/dist/esm/components/credits/credits-banner/index.d.ts +23 -0
- package/dist/esm/components/credits/credits-banner/index.js +2 -0
- package/dist/esm/components/credits/credits-banner/index.js.map +7 -0
- package/dist/esm/components/credits/credits-benefits/benefitItem.d.ts +19 -0
- package/dist/esm/components/credits/credits-benefits/benefitItem.js +2 -0
- package/dist/esm/components/credits/credits-benefits/benefitItem.js.map +7 -0
- package/dist/esm/components/credits/credits-benefits/iconInfo.d.ts +2 -0
- package/dist/esm/components/credits/credits-benefits/iconInfo.js +2 -0
- package/dist/esm/components/credits/credits-benefits/iconInfo.js.map +7 -0
- package/dist/esm/components/credits/credits-benefits/index.d.ts +12 -0
- package/dist/esm/components/credits/credits-benefits/index.js +4 -0
- package/dist/esm/components/credits/credits-benefits/index.js.map +7 -0
- package/dist/esm/components/credits/credits-cash/RedeemableItem.d.ts +15 -0
- package/dist/esm/components/credits/credits-cash/RedeemableItem.js +2 -0
- package/dist/esm/components/credits/credits-cash/RedeemableItem.js.map +7 -0
- package/dist/esm/components/credits/credits-cash/index.d.ts +13 -0
- package/dist/esm/components/credits/credits-cash/index.js +2 -0
- package/dist/esm/components/credits/credits-cash/index.js.map +7 -0
- package/dist/esm/components/credits/credits-cash/type.d.ts +47 -0
- package/dist/esm/components/credits/credits-cash/type.js +1 -0
- package/dist/esm/components/credits/credits-cash/type.js.map +7 -0
- package/dist/esm/components/credits/credits-faq/faq-item/FaqItem.d.ts +13 -0
- package/dist/esm/components/credits/credits-faq/faq-item/faq-item.d.ts +13 -0
- package/dist/esm/components/credits/credits-faq/faq-item/faq-item.js +2 -0
- package/dist/esm/components/credits/credits-faq/faq-item/faq-item.js.map +7 -0
- package/dist/esm/components/credits/credits-faq/faqItem/FaqItem.d.ts +13 -0
- package/dist/esm/components/credits/credits-faq/index.d.ts +16 -0
- package/dist/esm/components/credits/credits-faq/index.js +2 -0
- package/dist/esm/components/credits/credits-faq/index.js.map +7 -0
- package/dist/esm/components/credits/credits-info-card/index.d.ts +20 -0
- package/dist/esm/components/credits/credits-info-card/index.js +2 -0
- package/dist/esm/components/credits/credits-info-card/index.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/AddressForm/Input.d.ts +13 -0
- package/dist/esm/components/credits/credits-redeem-list/AddressForm/country-select.d.ts +14 -0
- package/dist/esm/components/credits/credits-redeem-list/AddressForm/form-item.d.ts +6 -0
- package/dist/esm/components/credits/credits-redeem-list/AddressForm/index.d.ts +2 -0
- package/dist/esm/components/credits/credits-redeem-list/AddressForm/state-select.d.ts +15 -0
- package/dist/esm/components/credits/credits-redeem-list/AddressForm/type.d.ts +26 -0
- package/dist/esm/components/credits/credits-redeem-list/RedeemCouponModal.d.ts +9 -0
- package/dist/esm/components/credits/credits-redeem-list/RedeemProductModal/Address.d.ts +20 -0
- package/dist/esm/components/credits/credits-redeem-list/RedeemProductModal/Error.d.ts +8 -0
- package/dist/esm/components/credits/credits-redeem-list/RedeemProductModal/Init.d.ts +11 -0
- package/dist/esm/components/credits/credits-redeem-list/RedeemProductModal/ProductInfo.d.ts +8 -0
- package/dist/esm/components/credits/credits-redeem-list/RedeemProductModal/Success.d.ts +13 -0
- package/dist/esm/components/credits/credits-redeem-list/RedeemProductModal/index.d.ts +11 -0
- package/dist/esm/components/credits/credits-redeem-list/RedeemableItem.d.ts +9 -0
- package/dist/esm/components/credits/credits-redeem-list/RedeemableItem.js +2 -0
- package/dist/esm/components/credits/credits-redeem-list/RedeemableItem.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/Input.d.ts +13 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/Input.js +2 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/Input.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/country-select.d.ts +14 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/country-select.js +2 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/country-select.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/form-item.d.ts +6 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/form-item.js +2 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/form-item.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/index.d.ts +2 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/index.js +2 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/index.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/state-select.d.ts +15 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/state-select.js +2 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/state-select.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/type.d.ts +26 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/type.js +1 -0
- package/dist/esm/components/credits/credits-redeem-list/address-form/type.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/index.d.ts +13 -0
- package/dist/esm/components/credits/credits-redeem-list/index.js +2 -0
- package/dist/esm/components/credits/credits-redeem-list/index.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-coupon-modal.d.ts +9 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-coupon-modal.js +2 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-coupon-modal.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Address.d.ts +20 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Address.js +2 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Address.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Error.d.ts +8 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Error.js +2 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Error.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Init.d.ts +11 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Init.js +2 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Init.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/ProductInfo.d.ts +8 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/ProductInfo.js +2 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/ProductInfo.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Success.d.ts +13 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Success.js +2 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/Success.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/index.d.ts +11 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/index.js +2 -0
- package/dist/esm/components/credits/credits-redeem-list/redeem-product-modal/index.js.map +7 -0
- package/dist/esm/components/credits/credits-redeem-list/type.d.ts +77 -0
- package/dist/esm/components/credits/credits-redeem-list/type.js +1 -0
- package/dist/esm/components/credits/credits-redeem-list/type.js.map +7 -0
- package/dist/esm/components/credits/credits-ways-to-get-credits/index.d.ts +2 -0
- package/dist/esm/components/credits/credits-ways-to-get-credits/index.js +2 -0
- package/dist/esm/components/credits/credits-ways-to-get-credits/index.js.map +7 -0
- package/dist/esm/components/credits/credits-ways-to-get-credits/type.d.ts +60 -0
- package/dist/esm/components/credits/credits-ways-to-get-credits/type.js +2 -0
- package/dist/esm/components/credits/credits-ways-to-get-credits/type.js.map +7 -0
- package/dist/esm/components/credits/credits-ways-to-get-credits/useActions.d.ts +96 -0
- package/dist/esm/components/credits/credits-ways-to-get-credits/useActions.js +2 -0
- package/dist/esm/components/credits/credits-ways-to-get-credits/useActions.js.map +7 -0
- package/dist/esm/components/credits/creditsBenefits/index.js +3 -3
- package/dist/esm/components/credits/creditsBenefits/index.js.map +3 -3
- package/dist/esm/components/credits/creditsCash/index.js +1 -1
- package/dist/esm/components/credits/creditsCash/index.js.map +2 -2
- package/dist/esm/components/credits/creditsCash/type.d.ts +1 -1
- package/dist/esm/components/credits/creditsRedeemList/AddressForm/country-select.d.ts +14 -0
- package/dist/esm/components/credits/creditsRedeemList/AddressForm/form-item.d.ts +6 -0
- package/dist/esm/components/credits/creditsRedeemList/AddressForm/index.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/AddressForm/index.js.map +2 -2
- package/dist/esm/components/credits/creditsRedeemList/AddressForm/state-select.d.ts +15 -0
- package/dist/esm/components/credits/creditsRedeemList/RedeemCouponModal.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemCouponModal.js.map +2 -2
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Address.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Address.js.map +2 -2
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js.map +2 -2
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/index.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/index.js.map +2 -2
- package/dist/esm/components/credits/creditsRedeemList/index.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/index.js.map +2 -2
- package/dist/esm/components/credits/creditsWaysToGetCredits/useActions.js +1 -1
- package/dist/esm/components/credits/creditsWaysToGetCredits/useActions.js.map +2 -2
- package/dist/esm/components/credits/modal/loadingDots.js +1 -1
- package/dist/esm/components/credits/modal/loadingDots.js.map +2 -2
- package/dist/esm/components/credits/type.d.ts +1 -1
- package/dist/esm/debug-env.js +2 -0
- package/dist/esm/debug-env.js.map +7 -0
- package/dist/esm/index.d.ts +1 -6
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/shopify/context/ShopifyProvider.d.ts +1 -1
- package/dist/esm/shopify/context/index.d.ts +1 -0
- package/dist/esm/shopify/context/shopify-provider.d.ts +10 -0
- package/dist/esm/shopify/fetchers/create-cart.d.ts +1 -2
- package/dist/esm/shopify/hooks/index.d.ts +2 -2
- package/dist/esm/shopify/hooks/use-create-cart.d.ts +2 -0
- package/dist/esm/shopify/hooks/use-products-by-handles.d.ts +4 -0
- package/dist/esm/shopify/hooks/useProductsByHandles.d.ts +1 -1
- package/dist/esm/shopify/types/index.d.ts +2 -0
- package/dist/esm/stories/chat.stories.js +2 -0
- package/dist/esm/stories/chat.stories.js.map +7 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -0
- package/package.json +8 -3
- package/src/components/credits/context/hooks/useActivities.ts +1 -1
- package/src/components/credits/context/hooks/useAddressValidate.ts +2 -2
- package/src/components/credits/context/hooks/useAlpcFetch.ts +3 -3
- package/src/components/credits/context/hooks/useCountries.ts +2 -2
- package/src/components/credits/context/hooks/useMyRewards.ts +1 -1
- package/src/components/credits/context/hooks/useRedeemAndBuy.ts +2 -2
- package/src/components/credits/context/hooks/useRedeemCoupon.ts +1 -1
- package/src/components/credits/context/hooks/useRedeemProduct.ts +1 -1
- package/src/components/credits/context/hooks/useRedeemableList.ts +1 -1
- package/src/components/credits/context/hooks/useSendEmailValidation.ts +1 -1
- package/src/components/credits/context/hooks/useSubscribed.ts +1 -1
- package/src/components/credits/context/hooks/useSubscriptions.ts +2 -2
- package/src/components/credits/creditsBenefits/index.tsx +3 -5
- package/src/components/credits/creditsCash/index.tsx +2 -2
- package/src/components/credits/creditsCash/type.ts +1 -1
- package/src/components/credits/creditsRedeemList/AddressForm/index.tsx +1 -1
- package/src/components/credits/creditsRedeemList/RedeemCouponModal.tsx +1 -1
- package/src/components/credits/creditsRedeemList/RedeemProductModal/Address.tsx +1 -1
- package/src/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.tsx +1 -1
- package/src/components/credits/creditsRedeemList/RedeemProductModal/index.tsx +1 -1
- package/src/components/credits/creditsRedeemList/index.tsx +1 -1
- package/src/components/credits/creditsWaysToGetCredits/useActions.ts +1 -1
- package/src/components/credits/modal/loadingDots.tsx +2 -2
- package/src/components/credits/type.ts +1 -1
- package/src/index.ts +2 -21
- package/dist/cjs/components/credits/creditsCash/index.js +0 -2
- package/dist/cjs/components/credits/creditsCash/index.js.map +0 -7
- package/dist/cjs/components/credits/creditsCash/type.js.map +0 -7
- package/dist/cjs/components/credits/creditsRedeemList/AddressForm/index.js +0 -2
- package/dist/cjs/components/credits/creditsRedeemList/AddressForm/index.js.map +0 -7
- package/dist/cjs/components/credits/creditsRedeemList/RedeemCouponModal.js +0 -2
- package/dist/cjs/components/credits/creditsRedeemList/RedeemCouponModal.js.map +0 -7
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Address.js +0 -2
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Address.js.map +0 -7
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js +0 -2
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js.map +0 -7
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/index.js +0 -2
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/index.js.map +0 -7
- package/dist/cjs/components/credits/creditsRedeemList/index.js +0 -2
- package/dist/cjs/components/credits/creditsRedeemList/index.js.map +0 -7
- package/dist/cjs/components/credits/creditsWaysToGetCredits/useActions.js +0 -2
- package/dist/cjs/components/credits/creditsWaysToGetCredits/useActions.js.map +0 -7
- package/src/shopify/MIGRATION_GUIDE.md +0 -156
- package/src/shopify/context/ShopifyProvider.tsx +0 -34
- package/src/shopify/dist/cart-BNkVu3fh.d.ts +0 -220
- package/src/shopify/dist/cart-BcrGTPdx.d.cts +0 -220
- package/src/shopify/dist/fetchers.cjs +0 -7945
- package/src/shopify/dist/fetchers.cjs.map +0 -1
- package/src/shopify/dist/fetchers.d.cts +0 -3
- package/src/shopify/dist/fetchers.d.ts +0 -3
- package/src/shopify/dist/fetchers.js +0 -7942
- package/src/shopify/dist/fetchers.js.map +0 -1
- package/src/shopify/dist/fragments.cjs +0 -731
- package/src/shopify/dist/fragments.cjs.map +0 -1
- package/src/shopify/dist/fragments.d.cts +0 -25
- package/src/shopify/dist/fragments.d.ts +0 -25
- package/src/shopify/dist/fragments.js +0 -705
- package/src/shopify/dist/fragments.js.map +0 -1
- package/src/shopify/dist/graphql-D4M28V-x.d.cts +0 -3558
- package/src/shopify/dist/graphql-D4M28V-x.d.ts +0 -3558
- package/src/shopify/dist/hooks.cjs +0 -9431
- package/src/shopify/dist/hooks.cjs.map +0 -1
- package/src/shopify/dist/hooks.d.cts +0 -14
- package/src/shopify/dist/hooks.d.ts +0 -14
- package/src/shopify/dist/hooks.js +0 -9427
- package/src/shopify/dist/hooks.js.map +0 -1
- package/src/shopify/dist/index-BTtE4HZM.d.ts +0 -42
- package/src/shopify/dist/index-BjNIecYX.d.cts +0 -42
- package/src/shopify/dist/index.cjs +0 -9642
- package/src/shopify/dist/index.cjs.map +0 -1
- package/src/shopify/dist/index.d.cts +0 -11
- package/src/shopify/dist/index.d.ts +0 -11
- package/src/shopify/dist/index.js +0 -9619
- package/src/shopify/dist/index.js.map +0 -1
- package/src/shopify/dist/product-Bqi3sqb9.d.cts +0 -262
- package/src/shopify/dist/product-DNk6jYAP.d.ts +0 -262
- package/src/shopify/dist/queries.cjs +0 -615
- package/src/shopify/dist/queries.cjs.map +0 -1
- package/src/shopify/dist/queries.d.cts +0 -3
- package/src/shopify/dist/queries.d.ts +0 -3
- package/src/shopify/dist/queries.js +0 -601
- package/src/shopify/dist/queries.js.map +0 -1
- package/src/shopify/dist/types.cjs +0 -19
- package/src/shopify/dist/types.cjs.map +0 -1
- package/src/shopify/dist/types.d.cts +0 -282
- package/src/shopify/dist/types.d.ts +0 -282
- package/src/shopify/dist/types.js +0 -1
- package/src/shopify/dist/types.js.map +0 -1
- package/src/shopify/dist/utils.cjs +0 -334
- package/src/shopify/dist/utils.cjs.map +0 -1
- package/src/shopify/dist/utils.d.cts +0 -12
- package/src/shopify/dist/utils.d.ts +0 -12
- package/src/shopify/dist/utils.js +0 -319
- package/src/shopify/dist/utils.js.map +0 -1
- package/src/shopify/fetchers/create-cart.ts +0 -40
- package/src/shopify/fetchers/get-products-by-handles.ts +0 -41
- package/src/shopify/fetchers/index.ts +0 -3
- package/src/shopify/fragments/article.ts +0 -51
- package/src/shopify/fragments/blog.ts +0 -10
- package/src/shopify/fragments/cart.ts +0 -190
- package/src/shopify/fragments/collection.ts +0 -15
- package/src/shopify/fragments/image.ts +0 -8
- package/src/shopify/fragments/index.ts +0 -11
- package/src/shopify/fragments/metafields.ts +0 -17
- package/src/shopify/fragments/page-info.ts +0 -8
- package/src/shopify/fragments/page.ts +0 -12
- package/src/shopify/fragments/product.ts +0 -71
- package/src/shopify/fragments/seo.ts +0 -6
- package/src/shopify/fragments/variant.ts +0 -29
- package/src/shopify/gql/fragment-masking.ts +0 -85
- package/src/shopify/gql/gql.ts +0 -110
- package/src/shopify/gql/graphql.ts +0 -11780
- package/src/shopify/gql/index.ts +0 -4
- package/src/shopify/hooks/index.ts +0 -2
- package/src/shopify/hooks/useCreateCart.ts +0 -24
- package/src/shopify/hooks/useProductsByHandles.ts +0 -25
- package/src/shopify/mutations/create-cart.ts +0 -16
- package/src/shopify/package.json +0 -84
- package/src/shopify/queries/get-product-by-handles.ts +0 -32
- package/src/shopify/queries/index.ts +0 -2
- package/src/shopify/src/index.ts +0 -5
- package/src/shopify/tsconfig.json +0 -25
- package/src/shopify/tsup.config.ts +0 -21
- package/src/shopify/types/article.ts +0 -46
- package/src/shopify/types/cart.ts +0 -202
- package/src/shopify/types/checkout.ts +0 -44
- package/src/shopify/types/collection.ts +0 -104
- package/src/shopify/types/common.ts +0 -53
- package/src/shopify/types/config.ts +0 -14
- package/src/shopify/types/customer.ts +0 -31
- package/src/shopify/types/fetcher.ts +0 -61
- package/src/shopify/types/index.ts +0 -10
- package/src/shopify/types/page.ts +0 -45
- package/src/shopify/types/product.ts +0 -176
- package/src/shopify/types/search.ts +0 -62
- package/src/shopify/types/site.ts +0 -38
- package/src/shopify/types/type-helper.ts +0 -5
- package/src/shopify/utils/colors.ts +0 -206
- package/src/shopify/utils/const.ts +0 -115
- package/src/shopify/utils/cookie.ts +0 -39
- package/src/shopify/utils/errors.ts +0 -65
- package/src/shopify/utils/fetch-graphql-api.ts +0 -67
- package/src/shopify/utils/handle-fetch-response.ts +0 -60
- package/src/shopify/utils/helper.ts +0 -89
- package/src/shopify/utils/normalize/cart.ts +0 -106
- package/src/shopify/utils/normalize/customer.ts +0 -18
- package/src/shopify/utils/normalize/index.ts +0 -2
- package/src/shopify/utils/normalize/metafield.ts +0 -69
- package/src/shopify/utils/normalize/product.ts +0 -193
- package/src/shopify/utils/store.ts +0 -5
- package/src/shopify/utils/type-helper.ts +0 -7
- /package/dist/cjs/components/credits/{creditsBanner → credits-banner}/index.js +0 -0
- /package/dist/cjs/components/credits/{creditsBenefits → credits-benefits}/benefitItem.js +0 -0
- /package/dist/cjs/components/credits/{creditsBenefits → credits-benefits}/iconInfo.js +0 -0
- /package/dist/cjs/components/credits/{creditsBenefits → credits-benefits}/index.js +0 -0
- /package/dist/cjs/components/credits/{creditsCash → credits-cash}/RedeemableItem.js +0 -0
- /package/dist/cjs/components/credits/{creditsCash → credits-cash}/type.js +0 -0
- /package/dist/cjs/components/credits/{creditsFaq → credits-faq}/index.js +0 -0
- /package/dist/cjs/components/credits/{creditsInfoCard → credits-info-card}/index.js +0 -0
- /package/dist/cjs/components/credits/{creditsRedeemList → credits-redeem-list}/RedeemableItem.js +0 -0
- /package/dist/cjs/components/credits/{creditsRedeemList/AddressForm → credits-redeem-list/address-form}/Input.js +0 -0
- /package/dist/cjs/components/credits/{creditsRedeemList/AddressForm → credits-redeem-list/address-form}/type.js +0 -0
- /package/dist/cjs/components/credits/{creditsRedeemList/RedeemProductModal → credits-redeem-list/redeem-product-modal}/Error.js +0 -0
- /package/dist/cjs/components/credits/{creditsRedeemList/RedeemProductModal → credits-redeem-list/redeem-product-modal}/Init.js +0 -0
- /package/dist/cjs/components/credits/{creditsRedeemList/RedeemProductModal → credits-redeem-list/redeem-product-modal}/Success.js +0 -0
- /package/dist/cjs/components/credits/{creditsRedeemList → credits-redeem-list}/type.js +0 -0
- /package/dist/cjs/components/credits/{creditsWaysToGetCredits → credits-ways-to-get-credits}/index.js +0 -0
- /package/dist/cjs/components/credits/{creditsWaysToGetCredits → credits-ways-to-get-credits}/type.js +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../../src/components/credits/creditsRedeemList/RedeemProductModal/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import classNames from 'classnames'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { useCreditsContext } from '../../context/provider'\nimport useCountries from '../../context/hooks/useCountries'\nimport { AlpcErrorCode } from '../../context/const'\nimport { useAddressValidate } from '../../context/hooks/useAddressValidate'\nimport { useRedeemProduct } from '../../context/hooks/useRedeemProduct'\nimport type { ModalContainerProps } from '../../modal/modalContainer'\nimport { CreditsModalContainer } from '../../modal/modalContainer'\nimport type { RedeemableItem as RedeemableItemType } from '../../type'\nimport { useShopifyContext } from '../../../../shopify/context/ShopifyProvider'\nimport { CreditsRedeemListCopy } from '../type'\nimport { Error } from './Error'\nimport { Success } from './Success'\nimport { Address } from './Address'\nimport { Init } from './Init'\n\ntype RedeemProductModalProps = ModalContainerProps & {\n item: RedeemableItemType\n copy: CreditsRedeemListCopy\n onError: (code: AlpcErrorCode) => void\n}\n\nfunction RedeemProductModal({ item, copy, onError, ...props }: RedeemProductModalProps) {\n const { fetchCreditInfo, profile } = useCreditsContext()\n const { storeDomain, locale } = useShopifyContext()\n\n const { validatorInfo } = copy\n const { shippingAddress, shippingProduct } = copy.redeemModal.product\n\n const [status, setStatus] = useState<'init' | 'address' | 'success' | 'error'>('init')\n const [address, setAddress] = useState<any>()\n const [errorInfo, setErrorInfo] = useState({\n code: 0,\n message: '',\n imageUrl: '',\n })\n const [disabled, setDisabled] = useState(false)\n\n const { countries = [], isLoading: countriesLoading } = useCountries({ shopifyStoreDomain: storeDomain })\n\n const { isMutating: loading, trigger } = useRedeemProduct({\n onSuccess(responseData) {\n if (!responseData) {\n setStatus('error')\n setErrorInfo({\n code: 0,\n imageUrl: copy.redeemModal.errorImageUrl || '',\n message: copy.redeemModal.commonError || '',\n })\n return\n }\n\n if (responseData?.code === 0) {\n fetchCreditInfo(profile?.user_id)\n setStatus('success')\n } else {\n let errorMsg\n let errorImage\n if (responseData.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n errorMsg = copy.redeemModal.redeemLimitError\n setDisabled(true)\n } else if (responseData.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n errorMsg = copy.redeemModal.inventoryNotEnough\n setDisabled(true)\n errorImage = copy.redeemModal.inventoryNotEnough\n } else if (responseData.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n errorMsg = copy.redeemModal.creditsNotEnough\n setDisabled(true)\n fetchCreditInfo(profile?.user_id)\n } else if (responseData.code === AlpcErrorCode.CodeCrossSiteError) {\n errorMsg = copy.redeemModal.crossSiteError\n setDisabled(true)\n }\n\n setStatus('error')\n setErrorInfo({\n code: responseData.code,\n imageUrl: errorImage || copy.redeemModal.errorImageUrl || '',\n message: errorMsg || copy.redeemModal.commonError || '',\n })\n onError && onError(responseData.code)\n }\n },\n onError(error) {\n setStatus('error')\n setErrorInfo({\n code: 0,\n imageUrl: copy.redeemModal.errorImageUrl || '',\n message: copy.redeemModal.commonError || '',\n })\n },\n })\n\n const stateInputKey = useMemo(() => {\n const stateInput = copy?.redeemModal.product.form?.flat().find(item => item.type === 'state')\n return stateInput?.key\n }, [copy?.redeemModal.product.form])\n\n const { validate: validateAddress, errors: validateErrors } = useAddressValidate({\n address: address,\n validatorInfo: validatorInfo,\n formData: copy?.redeemModal.product.form?.flat() || [],\n errorLabel: {\n require: copy.redeemModal.product.required,\n email: copy.redeemModal.product.invalidEmail,\n },\n })\n\n const handlePayment = useCallback(async () => {\n const ignoreKeys: string[] = []\n\n if (stateInputKey) {\n const provinces = countries.find(item => item.code === address.country)?.provinces || []\n\n if (!provinces.length) {\n ignoreKeys.push(stateInputKey as never)\n }\n }\n\n if (\n validateAddress({\n force: true,\n ignoreKeys,\n })\n ) {\n // \u5730\u5740\u6821\u9A8C\u9519\u8BEF\n return\n }\n console.log('address', address)\n let requestAddress = { ...address }\n if (requestAddress.name) {\n delete requestAddress.name\n }\n if (requestAddress.country === 'UK') {\n requestAddress.country = 'GB'\n }\n trigger({\n address: btoa(JSON.stringify(requestAddress)),\n rule_id: Number(item.alpc?.id),\n })\n }, [item, trigger, stateInputKey, validateAddress, address, countries])\n\n useEffect(() => {\n if (!props.isOpen) {\n setDisabled(false)\n setErrorInfo({ code: 0, message: '', imageUrl: '' })\n }\n }, [props.isOpen, locale])\n\n return (\n <CreditsModalContainer\n {...props}\n className={classNames(\n 'w-[540px] md:h-auto min-md:max-h-[calc(100vh-40px)]',\n status !== 'init' && 'w-[740px] md:w-full'\n )}\n scrollClassName=\"mb-0 min-l:px-0 md:mb-0 px-0\"\n titleClassName={classNames('h-[56px]', status === 'init' && 'bg-[#F5F5F7]')}\n title={status === 'address' ? 'Order Confirmation' : ''}\n >\n {status === 'error' && <Error errorInfo={errorInfo} />}\n {status === 'success' && (\n <Success\n copy={copy}\n shippingProduct={shippingProduct}\n loading={loading}\n address={address}\n disabled={disabled}\n onClose={props.onClose}\n item={item}\n />\n )}\n {status === 'address' && (\n <Address\n copy={copy}\n shippingAddress={shippingAddress}\n setAddress={setAddress}\n validateAddress={validateAddress}\n validateErrors={validateErrors}\n shippingProduct={shippingProduct}\n loading={loading}\n address={address}\n disabled={disabled}\n handlePayment={handlePayment}\n item={item}\n />\n )}\n {status === 'init' && (\n <Init item={item} copy={copy} loading={loading} disabled={disabled} setStatus={setStatus} />\n )}\n </CreditsModalContainer>\n )\n}\n\nexport default RedeemProductModal\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,EAAAH,IAuJI,IAAAI,EAAA,6BAvJJC,EAAuB,yBACvBC,EAA0D,iBAC1DC,EAAkC,kCAClCC,EAAyB,+CACzBC,EAA8B,+BAC9BC,EAAmC,kDACnCC,EAAiC,gDAEjCC,EAAsC,sCAEtCC,EAAkC,uDAElCC,EAAsB,mBACtBC,EAAwB,qBACxBC,EAAwB,qBACxBC,EAAqB,kBAQrB,SAASC,GAAmB,CAAE,KAAAC,EAAM,KAAAC,EAAM,QAAAC,EAAS,GAAGC,CAAM,EAA4B,CACtF,KAAM,CAAE,gBAAAC,EAAiB,QAAAC,CAAQ,KAAI,qBAAkB,EACjD,CAAE,YAAAC,EAAa,OAAAC,CAAO,KAAI,qBAAkB,EAE5C,CAAE,cAAAC,CAAc,EAAIP,EACpB,CAAE,gBAAAQ,EAAiB,gBAAAC,CAAgB,EAAIT,EAAK,YAAY,QAExD,CAACU,EAAQC,CAAS,KAAI,YAAmD,MAAM,EAC/E,CAACC,EAASC,CAAU,KAAI,YAAc,EACtC,CAACC,EAAWC,CAAY,KAAI,YAAS,CACzC,KAAM,EACN,QAAS,GACT,SAAU,EACZ,CAAC,EACK,CAACC,EAAUC,CAAW,KAAI,YAAS,EAAK,EAExC,CAAE,UAAAC,EAAY,CAAC,EAAG,UAAWC,EAAiB,KAAI,EAAAC,SAAa,CAAE,mBAAoBf,CAAY,CAAC,EAElG,CAAE,WAAYgB,EAAS,QAAAC,CAAQ,KAAI,oBAAiB,CACxD,UAAUC,EAAc,CACtB,GAAI,CAACA,EAAc,CACjBZ,EAAU,OAAO,EACjBI,EAAa,CACX,KAAM,EACN,SAAUf,EAAK,YAAY,eAAiB,GAC5C,QAASA,EAAK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,KAAM/B,EACR,EAEDW,IAAW,WACV,OAAC,QAAK,KAAMX,EAAM,KAAMC,EAAM,QAASqB,EAAS,SAAUL,EAAU,UAAWL,EAAW,GAE9F,CAEJ,CAEA,IAAO7B,GAAQgB",
|
|
6
|
-
"names": ["RedeemProductModal_exports", "__export", "RedeemProductModal_default", "__toCommonJS", "import_jsx_runtime", "import_classnames", "import_react", "import_provider", "import_useCountries", "import_const", "import_useAddressValidate", "import_useRedeemProduct", "import_modalContainer", "import_ShopifyProvider", "import_Error", "import_Success", "import_Address", "import_Init", "RedeemProductModal", "item", "copy", "onError", "props", "fetchCreditInfo", "profile", "storeDomain", "locale", "validatorInfo", "shippingAddress", "shippingProduct", "status", "setStatus", "address", "setAddress", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "countries", "countriesLoading", "useCountries", "loading", "trigger", "responseData", "errorMsg", "errorImage", "error", "stateInputKey", "validateAddress", "validateErrors", "handlePayment", "ignoreKeys", "requestAddress", "classNames"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var J=Object.create;var C=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var Y=(e,t)=>{for(var a in t)C(e,a,{get:t[a],enumerable:!0})},S=(e,t,a,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of Q(t))!X.call(e,d)&&d!==a&&C(e,d,{get:()=>t[d],enumerable:!(f=K(t,d))||f.enumerable});return e};var g=(e,t,a)=>(a=e!=null?J(W(e)):{},S(t||!e||!e.__esModule?C(a,"default",{value:e,enumerable:!0}):a,e)),Z=e=>S(C({},"__esModule",{value:!0}),e);var ee={};Y(ee,{CreditsRedeemList:()=>$});module.exports=Z(ee);var n=require("react/jsx-runtime"),r=require("@anker-in/headless-ui"),R=g(require("classnames")),l=require("react"),E=g(require("./RedeemCouponModal")),O=g(require("./RedeemProductModal")),A=require("../context/provider"),M=g(require("../context/hooks/useRedeemableList")),u=require("../context/const"),F=require("../../../shopify/hooks/useProductsByHandles"),D=require("./RedeemableItem"),z=g(require("../modal/rulesModal")),H=require("../../../helpers/track");function $({copy:e,className:t="",tabClassName:a="",hideTitle:f=!1,cardClassName:d,activate:v}){const{profile:L,openSignUpPopup:j,gtm:{pageGroup:w}}=(0,A.useCreditsContext)(),B=Object.keys(L||{}).length>0,[T,G]=(0,l.useState)(e.list[0].label),[i,b]=(0,l.useState)(void 0),[h,N]=(0,l.useState)(),{listLoading:U,redeemableList:k,getRedeemableList:x}=(0,M.default)(),p=(0,l.useMemo)(()=>k.map(s=>({id:s.id.toString(),title:s.name,consumeCredits:s.consume_credits,remainingInventory:s.remaining_inventory,isLimited:!!s.is_limited,consumeType:s.consume_type,handle:s.sku_handle,sku:s.goods_sku,image:s.goods_url})),[e.list,T,k]),V=p.map(s=>s.handle),{data:_}=(0,F.useProductsByHandles)({handles:V}),q=(0,l.useMemo)(()=>e.list.find(o=>o.label===T)?.list.filter(o=>p.some(c=>c.id===o.id)).map(o=>{const c=p.find(m=>m.id===o.id),y=_?.find(m=>m.handle===c?.handle),P=y?.variants.find(m=>m.sku===c?.sku);return c?.consumeType===u.AlpcConsumeType.Product&&(!y||!P)?null:{alpc:p.find(m=>m.id===o.id),config:o,product:y,variant:P}}).filter(o=>o!==null),[p,_]),I=(0,l.useCallback)(s=>{s===u.AlpcErrorCode.CodeLpcRuleInventoryNotEnough&&x()},[x]);return console.log("popRedeemData",i),(0,n.jsxs)(r.Container,{className:(0,R.default)("relative bg-[#F5F5F7]",t),children:[!f&&(0,n.jsx)(r.Heading,{as:"h2",size:"4",html:e.title}),(0,n.jsx)(r.Tabs,{shape:"rounded",align:"left",className:(0,R.default)("sticky top-0 z-20 py-[24px] md:justify-center",a),value:T.toString(),onValueChange:s=>{G(s),(0,H.gaTrack)({event:"ga4Event",event_name:"lp_navigation",event_parameters:{navigation:s,page_group:w}})},children:(0,n.jsx)(r.TabsList,{children:e.list.map(s=>(0,n.jsx)(r.TabsTrigger,{value:s.label,children:s.label},s.label))})}),!!p?.length&&!U&&(0,n.jsx)("div",{className:(0,R.default)("relative grid grid-cols-4 gap-[16px] md:grid-cols-2 md:gap-[12px] md-xl:grid-cols-3"),children:q?.map(s=>(0,n.jsx)(D.RedeemableItem,{copy:e,item:s,onRedeem:o=>{B?!L?.activated&&!v.isSuccess?(v.openAuthCodePopup(),v.setOnSuccess(()=>{b(o)})):b(o):j()},onRulesOpen:N,className:d},s?.alpc?.id))}),i?.alpc?.consumeType===u.AlpcConsumeType.Coupon&&e?.redeemModal?.coupon&&i&&(0,n.jsx)(E.default,{isOpen:!!i,item:i,copy:e,onError:I,onClose:()=>{b(void 0)}}),i?.alpc?.consumeType===u.AlpcConsumeType.Product&&e?.redeemModal&&i&&(0,n.jsx)(O.default,{isOpen:!!i,item:i,copy:e,onError:I,onClose:()=>{b(void 0)}}),h&&(0,n.jsx)(z.default,{overlayClassName:"md:px-[16px] md:items-center",className:"md:h-fit md:rounded-b-[16px]",isOpen:h.length>0,onClose:()=>N([]),titleClassName:"border-b-transparent h-[56px]",rules:h,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/creditsRedeemList/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Container, Heading, Tabs, TabsList, TabsTrigger } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { useCallback, useMemo, useState } from 'react'\n\nimport RedeemCouponModal from './RedeemCouponModal'\nimport RedeemProductModal from './RedeemProductModal'\nimport { useCreditsContext } from '../context/provider'\nimport useRedeemableList from '../context/hooks/useRedeemableList'\nimport { AlpcConsumeType, AlpcErrorCode } from '../context/const'\nimport { useProductsByHandles } from '../../../shopify/hooks/useProductsByHandles'\nimport type { RedeemableItem as RedeemableItemType } from '../type'\nimport { RedeemableItem } from './RedeemableItem'\nimport RulesModal from '../modal/rulesModal'\nimport { CreditsRedeemListCopy } from './type'\nimport { gaTrack } from '../../../helpers/track'\n\nexport function CreditsRedeemList({\n copy,\n className = '',\n tabClassName = '',\n hideTitle = false,\n cardClassName,\n activate,\n}: {\n copy: CreditsRedeemListCopy\n className?: string\n tabClassName?: string\n hideTitle?: boolean\n cardClassName?: string\n activate: {\n openAuthCodePopup: () => void\n isSuccess: boolean\n setOnSuccess: (callback: Function) => void\n }\n}) {\n const {\n profile,\n openSignUpPopup,\n gtm: { pageGroup },\n } = useCreditsContext()\n const isLogin = Object.keys(profile || {}).length > 0\n\n const [activeTab, setActiveTab] = useState<string>(copy.list[0].label)\n\n const [popRedeemData, setPopRedeemData] = useState<RedeemableItemType | undefined>(undefined)\n\n const [rules, setRules] = useState<string | string[]>()\n\n const { listLoading, redeemableList, getRedeemableList } = useRedeemableList()\n\n const alpcList = useMemo(() => {\n return redeemableList.map(item => {\n return {\n id: item.id.toString(),\n title: item.name,\n consumeCredits: item.consume_credits,\n remainingInventory: item.remaining_inventory,\n isLimited: !!item.is_limited,\n consumeType: item.consume_type,\n handle: item.sku_handle,\n sku: item.goods_sku,\n image: item.goods_url,\n }\n })\n }, [copy.list, activeTab, redeemableList])\n\n const handles = alpcList.map(item => item.handle)\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n const currentList = copy.list.find(item => item.label === activeTab)\n return currentList?.list\n .filter(item => alpcList.some(alpcItem => alpcItem.id === item.id))\n .map(item => {\n const alpcItem = alpcList.find(alpcItem => alpcItem.id === item.id)\n const product = products?.find(product => product.handle === alpcItem?.handle)\n const variant = product?.variants.find(variant => variant.sku === alpcItem?.sku)\n if (alpcItem?.consumeType === AlpcConsumeType.Product && (!product || !variant)) return null\n return {\n alpc: alpcList.find(alpcItem => alpcItem.id === item.id),\n config: item,\n product,\n variant,\n }\n })\n .filter(item => item !== null) as unknown as RedeemableItemType[]\n }, [alpcList, products])\n\n const handleRedeemError = useCallback(\n (errorCode: AlpcErrorCode) => {\n if (errorCode === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n getRedeemableList()\n }\n },\n [getRedeemableList]\n )\n\n console.log('popRedeemData', popRedeemData)\n\n return (\n <Container className={classNames('relative bg-[#F5F5F7]', className)}>\n {!hideTitle && <Heading as=\"h2\" size=\"4\" html={copy.title} />}\n\n <Tabs\n shape=\"rounded\"\n align=\"left\"\n className={classNames('sticky top-0 z-20 py-[24px] md:justify-center', tabClassName)}\n value={activeTab.toString()}\n onValueChange={value => {\n setActiveTab(value)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_navigation',\n event_parameters: {\n navigation: value,\n page_group: pageGroup,\n },\n })\n }}\n >\n <TabsList>\n {copy.list.map(item => (\n <TabsTrigger key={item.label} value={item.label}>\n {item.label}\n </TabsTrigger>\n ))}\n </TabsList>\n </Tabs>\n {/* PC\u7AEF */}\n {!!alpcList?.length && !listLoading && (\n <div\n className={classNames('relative grid grid-cols-4 gap-[16px] md:grid-cols-2 md:gap-[12px] md-xl:grid-cols-3')}\n >\n {list?.map(item => (\n <RedeemableItem\n key={item?.alpc?.id}\n copy={copy}\n item={item}\n onRedeem={(item: RedeemableItemType) => {\n if (!isLogin) {\n openSignUpPopup()\n } else if (!profile?.activated && !activate.isSuccess) {\n activate.openAuthCodePopup()\n activate.setOnSuccess(() => {\n setPopRedeemData(item)\n })\n } else {\n setPopRedeemData(item)\n }\n }}\n onRulesOpen={setRules}\n className={cardClassName}\n />\n ))}\n </div>\n )}\n\n {popRedeemData?.alpc?.consumeType === AlpcConsumeType.Coupon && copy?.redeemModal?.coupon && popRedeemData && (\n <RedeemCouponModal\n isOpen={!!popRedeemData}\n item={popRedeemData}\n copy={copy}\n onError={handleRedeemError}\n onClose={() => {\n setPopRedeemData(undefined)\n }}\n />\n )}\n {popRedeemData?.alpc?.consumeType === AlpcConsumeType.Product && copy?.redeemModal && popRedeemData && (\n <RedeemProductModal\n isOpen={!!popRedeemData}\n item={popRedeemData}\n copy={copy}\n onError={handleRedeemError}\n onClose={() => {\n setPopRedeemData(undefined)\n }}\n />\n )}\n {rules && (\n <RulesModal\n overlayClassName=\"md:px-[16px] md:items-center\"\n className=\"md:h-fit md:rounded-b-[16px]\"\n isOpen={rules.length > 0}\n onClose={() => setRules([])}\n titleClassName=\"border-b-transparent h-[56px]\"\n rules={rules}\n scrollClassName=\"md:mt-[8px] md:mb-[24px] md:pt-0\"\n title={copy?.ruleLabel}\n ruleClassName=\"text-[#1d1d1f] font-bold\"\n />\n )}\n </Container>\n )\n}\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,uBAAAE,IAAA,eAAAC,EAAAH,IAoGI,IAAAI,EAAA,6BApGJC,EAAgE,iCAChEC,EAAuB,yBACvBC,EAA+C,iBAE/CC,EAA8B,kCAC9BC,EAA+B,mCAC/BC,EAAkC,+BAClCC,EAA8B,iDAC9BC,EAA+C,4BAC/CC,EAAqC,uDAErCC,EAA+B,4BAC/BC,EAAuB,kCAEvBC,EAAwB,kCAEjB,SAASd,EAAkB,CAChC,KAAAe,EACA,UAAAC,EAAY,GACZ,aAAAC,EAAe,GACf,UAAAC,EAAY,GACZ,cAAAC,EACA,SAAAC,CACF,EAWG,CACD,KAAM,CACJ,QAAAC,EACA,gBAAAC,EACA,IAAK,CAAE,UAAAC,CAAU,CACnB,KAAI,qBAAkB,EAChBC,EAAU,OAAO,KAAKH,GAAW,CAAC,CAAC,EAAE,OAAS,EAE9C,CAACI,EAAWC,CAAY,KAAI,YAAiBX,EAAK,KAAK,CAAC,EAAE,KAAK,EAE/D,CAACY,EAAeC,CAAgB,KAAI,YAAyC,MAAS,EAEtF,CAACC,EAAOC,CAAQ,KAAI,YAA4B,EAEhD,CAAE,YAAAC,EAAa,eAAAC,EAAgB,kBAAAC,CAAkB,KAAI,EA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ACbf,EAAiB,MAAS,CAC5B,EACF,EAEDC,MACC,OAAC,EAAAoB,QAAA,CACC,iBAAiB,+BACjB,UAAU,+BACV,OAAQpB,EAAM,OAAS,EACvB,QAAS,IAAMC,EAAS,CAAC,CAAC,EAC1B,eAAe,gCACf,MAAOD,EACP,gBAAgB,mCAChB,MAAOd,GAAM,UACb,cAAc,2BAChB,GAEJ,CAEJ",
|
|
6
|
-
"names": ["creditsRedeemList_exports", "__export", "CreditsRedeemList", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_classnames", "import_react", "import_RedeemCouponModal", "import_RedeemProductModal", "import_provider", "import_useRedeemableList", "import_const", "import_useProductsByHandles", "import_RedeemableItem", "import_rulesModal", "import_track", "copy", "className", "tabClassName", "hideTitle", "cardClassName", "activate", "profile", "openSignUpPopup", "pageGroup", "isLogin", "activeTab", "setActiveTab", "popRedeemData", "setPopRedeemData", "rules", "setRules", "listLoading", "redeemableList", "getRedeemableList", "useRedeemableList", "alpcList", "item", "handles", "products", "list", "alpcItem", "product", "variant", "handleRedeemError", "errorCode", "classNames", "value", "RedeemCouponModal", "RedeemProductModal", "RulesModal"]
|
|
7
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var j=Object.create;var r=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,U=Object.prototype.hasOwnProperty;var A=(e,i)=>{for(var a in i)r(e,a,{get:i[a],enumerable:!0})},h=(e,i,a,b)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of R(i))!U.call(e,n)&&n!==a&&r(e,n,{get:()=>i[n],enumerable:!(b=_(i,n))||b.enumerable});return e};var x=(e,i,a)=>(a=e!=null?j(T(e)):{},h(i||!e||!e.__esModule?r(a,"default",{value:e,enumerable:!0}):a,e)),G=e=>h(r({},"__esModule",{value:!0}),e);var E={};A(E,{useActions:()=>W});module.exports=G(E);var t=require("./type"),k=require("../context/provider"),d=require("react"),f=x(require("../context/hooks/useReceiptUploaded")),N=require("../context/hooks/useFirstPurchaseFinished"),L=require("../context/hooks/useSubscribed"),C=require("../../../shopify/context/ShopifyProvider"),P=require("../../../helpers/track");const W=({copy:e,subscribe:i,uploadReceipt:a,activate:b,gaParameters:n})=>{const{openSignUpPopup:s,gtm:g,profile:l}=(0,k.useCreditsContext)(),u=(0,L.useSubscribed)(),c=(0,N.useFirstPurchaseFinished)(),m=(0,f.default)(),{appName:v}=(0,C.useShopifyContext)(),p=(0,d.useMemo)(()=>(l?.first_name||l?.last_name)&&l?.phone_number&&l?.dob,[l]);return(0,d.useMemo)(()=>{const o=({buttonName:F,id:w,callback:S})=>{(0,P.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:l?.activated?"active":"not active",event_parameters:{page_group:g.pageGroup,position:n?.position||e.title,button_name:F,info:w}}),S()};return{actions:{[t.TaskType.Activate]:{finished:l?.activated,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>o({buttonName:e?.joinNow,callback:s,id:t.TaskType.Activate})},notFinished:{buttonLabel:e?.activate,handleClick:()=>o({buttonName:e?.activate,callback:()=>b.openAuthCodePopup(),id:t.TaskType.Activate})},completed:{buttonLabel:e?.completed}},[t.TaskType.Subscribe]:{finished:u,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>o({buttonName:e?.joinNow,callback:s,id:t.TaskType.Subscribe})},notFinished:{buttonLabel:e?.subscribe,handleClick:()=>o({buttonName:e?.subscribe,callback:()=>i.openSubscribePopup(),id:t.TaskType.Subscribe})},completed:{buttonLabel:e?.completed}},[t.TaskType.CompleteProfile]:{finished:p,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>o({buttonName:e?.joinNow,callback:s,id:t.TaskType.CompleteProfile})},notFinished:{buttonLabel:e?.completeProfile,link:`/account/profile?app=${v}`,handleClick:()=>o({buttonName:e?.completeProfile,callback:()=>{},id:t.TaskType.CompleteProfile})},completed:{buttonLabel:e?.completed}},[t.TaskType.FirstPurchase]:{finished:c,notLogin:{buttonLabel:e?.makeFirstPurchase,handleClick:()=>o({buttonName:e?.makeFirstPurchase,callback:s,id:t.TaskType.FirstPurchase})},notFinished:{buttonLabel:e?.makeFirstPurchase,link:e?.goShopLink,handleClick:()=>o({buttonName:e?.makeFirstPurchase,callback:()=>{},id:t.TaskType.FirstPurchase})},completed:{buttonLabel:e?.completed}},[t.TaskType.UploadReceipt]:{finished:m,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>o({buttonName:e?.joinNow,callback:s,id:t.TaskType.UploadReceipt})},notFinished:{buttonLabel:e?.uploadReceipt,handleClick:()=>o({buttonName:e?.uploadReceipt,callback:()=>a.openUploadReceiptPopup(),id:t.TaskType.UploadReceipt})},completed:{buttonLabel:e?.completed}},[t.TaskType.Shop]:{finished:!1,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>o({buttonName:e?.joinNow,callback:s,id:t.TaskType.Shop})},notFinished:{buttonLabel:e?.shopNow,link:e?.goShopLink,handleClick:()=>o({buttonName:e?.shopNow,callback:()=>{},id:t.TaskType.Shop})},completed:{buttonLabel:e?.completed}}}}},[l?.activated,e?.joinNow,e?.activate,e?.completed,e?.subscribe,e?.completeProfile,e?.makeFirstPurchase,e?.uploadReceipt,e?.shopNow,e.title,e?.goShopLink,u,p,c,m,n?.position,s])};
|
|
2
|
-
//# sourceMappingURL=useActions.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/components/credits/creditsWaysToGetCredits/useActions.ts"],
|
|
4
|
-
"sourcesContent": ["import { TaskType } from './type'\nimport { useCreditsContext } from '../context/provider'\nimport { useMemo } from 'react'\nimport useReceiptUploaded from '../context/hooks/useReceiptUploaded'\nimport { useFirstPurchaseFinished } from '../context/hooks/useFirstPurchaseFinished'\nimport { useSubscribed } from '../context/hooks/useSubscribed'\nimport type { CreditsWaysToGetCreditsProps } from './type'\nimport { useShopifyContext } from '../../../shopify/context/ShopifyProvider'\nimport { gaTrack } from '../../../helpers/track'\n\nexport const useActions = ({\n copy,\n subscribe,\n uploadReceipt,\n activate,\n gaParameters,\n}: CreditsWaysToGetCreditsProps & {\n gaParameters?: {\n position: string\n }\n}) => {\n const { openSignUpPopup, gtm, profile } = useCreditsContext()\n const isSubscribed = useSubscribed()\n const firstPurchaseFinished = useFirstPurchaseFinished()\n const uploadedReceipt = useReceiptUploaded()\n const { appName } = useShopifyContext()\n\n const profileCompleted = useMemo(() => {\n return (profile?.first_name || profile?.last_name) && profile?.phone_number && profile?.dob\n }, [profile])\n\n return useMemo(() => {\n const handleClickWithTrack = ({\n buttonName,\n id,\n callback,\n }: {\n buttonName: string\n id?: string\n callback: () => void\n }) => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: gaParameters?.position || copy.title,\n button_name: buttonName,\n info: id,\n },\n })\n callback()\n }\n return {\n actions: {\n [TaskType.Activate]: {\n finished: profile?.activated,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Activate }),\n },\n notFinished: {\n buttonLabel: copy?.activate,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.activate,\n callback: () => activate.openAuthCodePopup(),\n id: TaskType.Activate,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.Subscribe]: {\n finished: isSubscribed,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Subscribe }),\n },\n notFinished: {\n buttonLabel: copy?.subscribe,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.subscribe,\n callback: () => subscribe.openSubscribePopup(),\n id: TaskType.Subscribe,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.CompleteProfile]: {\n finished: profileCompleted,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.CompleteProfile,\n }),\n },\n notFinished: {\n buttonLabel: copy?.completeProfile,\n link: `/account/profile?app=${appName}`,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.completeProfile,\n callback: () => {},\n id: TaskType.CompleteProfile,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.FirstPurchase]: {\n finished: firstPurchaseFinished,\n notLogin: {\n buttonLabel: copy?.makeFirstPurchase,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.makeFirstPurchase,\n callback: openSignUpPopup,\n id: TaskType.FirstPurchase,\n }),\n },\n notFinished: {\n buttonLabel: copy?.makeFirstPurchase,\n link: copy?.goShopLink,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.makeFirstPurchase,\n callback: () => {},\n id: TaskType.FirstPurchase,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.UploadReceipt]: {\n finished: uploadedReceipt,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.UploadReceipt,\n }),\n },\n notFinished: {\n buttonLabel: copy?.uploadReceipt,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.uploadReceipt,\n callback: () => uploadReceipt.openUploadReceiptPopup(),\n id: TaskType.UploadReceipt,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.Shop]: {\n finished: false,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.Shop,\n }),\n },\n notFinished: {\n buttonLabel: copy?.shopNow,\n link: copy?.goShopLink,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.shopNow,\n callback: () => {},\n id: TaskType.Shop,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n },\n }\n }, [\n profile?.activated,\n copy?.joinNow,\n copy?.activate,\n copy?.completed,\n copy?.subscribe,\n copy?.completeProfile,\n copy?.makeFirstPurchase,\n copy?.uploadReceipt,\n copy?.shopNow,\n copy.title,\n copy?.goShopLink,\n isSubscribed,\n profileCompleted,\n firstPurchaseFinished,\n uploadedReceipt,\n gaParameters?.position,\n openSignUpPopup,\n ])\n}\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyB,kBACzBC,EAAkC,+BAClCC,EAAwB,iBACxBC,EAA+B,kDAC/BC,EAAyC,qDACzCC,EAA8B,0CAE9BC,EAAkC,oDAClCC,EAAwB,kCAEjB,MAAMT,EAAa,CAAC,CACzB,KAAAU,EACA,UAAAC,EACA,cAAAC,EACA,SAAAC,EACA,aAAAC,CACF,IAIM,CACJ,KAAM,CAAE,gBAAAC,EAAiB,IAAAC,EAAK,QAAAC,CAAQ,KAAI,qBAAkB,EACtDC,KAAe,iBAAc,EAC7BC,KAAwB,4BAAyB,EACjDC,KAAkB,EAAAC,SAAmB,EACrC,CAAE,QAAAC,CAAQ,KAAI,qBAAkB,EAEhCC,KAAmB,WAAQ,KACvBN,GAAS,YAAcA,GAAS,YAAcA,GAAS,cAAgBA,GAAS,IACvF,CAACA,CAAO,CAAC,EAEZ,SAAO,WAAQ,IAAM,CACnB,MAAMO,EAAuB,CAAC,CAC5B,WAAAC,EACA,GAAAC,EACA,SAAAC,CACF,IAIM,IACJ,WAAQ,CACN,MAAO,WACP,WAAY,YACZ,qBAAsBV,GAAS,UAAY,SAAW,aACtD,iBAAkB,CAChB,WAAYD,EAAI,UAChB,SAAUF,GAAc,UAAYJ,EAAK,MACzC,YAAae,EACb,KAAMC,CACR,CACF,CA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,SAAUK,EACV,GAAI,WAAS,aACf,CAAC,CACL,EACA,YAAa,CACX,YAAaL,GAAM,kBACnB,KAAMA,GAAM,WACZ,YAAa,IACXc,EAAqB,CACnB,WAAYd,GAAM,kBAClB,SAAU,IAAM,CAAC,EACjB,GAAI,WAAS,aACf,CAAC,CACL,EACA,UAAW,CACT,YAAaA,GAAM,SACrB,CACF,EACA,CAAC,WAAS,aAAa,EAAG,CACxB,SAAUU,EACV,SAAU,CACR,YAAaV,GAAM,QACnB,YAAa,IACXc,EAAqB,CACnB,WAAYd,GAAM,QAClB,SAAUK,EACV,GAAI,WAAS,aACf,CAAC,CACL,EACA,YAAa,CACX,YAAaL,GAAM,cACnB,YAAa,IACXc,EAAqB,CACnB,WAAYd,GAAM,cAClB,SAAU,IAAME,EAAc,uBAAuB,EACrD,GAAI,WAAS,aACf,CAAC,CACL,EACA,UAAW,CACT,YAAaF,GAAM,SACrB,CACF,EACA,CAAC,WAAS,IAAI,EAAG,CACf,SAAU,GACV,SAAU,CACR,YAAaA,GAAM,QACnB,YAAa,IACXc,EAAqB,CACnB,WAAYd,GAAM,QAClB,SAAUK,EACV,GAAI,WAAS,IACf,CAAC,CACL,EACA,YAAa,CACX,YAAaL,GAAM,QACnB,KAAMA,GAAM,WACZ,YAAa,IACXc,EAAqB,CACnB,WAAYd,GAAM,QAClB,SAAU,IAAM,CAAC,EACjB,GAAI,WAAS,IACf,CAAC,CACL,EACA,UAAW,CACT,YAAaA,GAAM,SACrB,CACF,CACF,CACF,CACF,EAAG,CACDO,GAAS,UACTP,GAAM,QACNA,GAAM,SACNA,GAAM,UACNA,GAAM,UACNA,GAAM,gBACNA,GAAM,kBACNA,GAAM,cACNA,GAAM,QACNA,EAAK,MACLA,GAAM,WACNQ,EACAK,EACAJ,EACAC,EACAN,GAAc,SACdC,CACF,CAAC,CACH",
|
|
6
|
-
"names": ["useActions_exports", "__export", "useActions", "__toCommonJS", "import_type", "import_provider", "import_react", "import_useReceiptUploaded", "import_useFirstPurchaseFinished", "import_useSubscribed", "import_ShopifyProvider", "import_track", "copy", "subscribe", "uploadReceipt", "activate", "gaParameters", "openSignUpPopup", "gtm", "profile", "isSubscribed", "firstPurchaseFinished", "uploadedReceipt", "useReceiptUploaded", "appName", "profileCompleted", "handleClickWithTrack", "buttonName", "id", "callback"]
|
|
7
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
# Shopify Context 迁移指南
|
|
2
|
-
|
|
3
|
-
## 概述
|
|
4
|
-
|
|
5
|
-
本指南帮助你将现有的环境变量依赖迁移到新的 `ShopifyContext` 系统。
|
|
6
|
-
|
|
7
|
-
## 迁移步骤
|
|
8
|
-
|
|
9
|
-
### 1. 设置 Provider
|
|
10
|
-
|
|
11
|
-
在主应用的根组件中设置 `ShopifyProvider`:
|
|
12
|
-
|
|
13
|
-
```tsx
|
|
14
|
-
import { ShopifyProvider, createShopifyConfig } from '@anker-in/campaign-ui/shopify/context'
|
|
15
|
-
|
|
16
|
-
// 方式 1: 手动配置
|
|
17
|
-
const shopifyConfig = createShopifyConfig({
|
|
18
|
-
brand: 'soundcore',
|
|
19
|
-
env: 'production',
|
|
20
|
-
metafieldNamespacePrefix: 'custom',
|
|
21
|
-
stores: [
|
|
22
|
-
{
|
|
23
|
-
locale: 'us',
|
|
24
|
-
domain: 'store-us.myshopify.com',
|
|
25
|
-
token: 'your-us-token',
|
|
26
|
-
themeDomain: 'us.soundcore.com'
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
locale: 'eu',
|
|
30
|
-
domain: 'store-eu.myshopify.com',
|
|
31
|
-
token: 'your-eu-token',
|
|
32
|
-
themeDomain: 'eu.soundcore.com'
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
function App({ locale }: { locale: string }) {
|
|
38
|
-
return (
|
|
39
|
-
<ShopifyProvider config={shopifyConfig} locale={locale}>
|
|
40
|
-
<YourAppContent />
|
|
41
|
-
</ShopifyProvider>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### 2. 替换环境变量使用
|
|
47
|
-
|
|
48
|
-
#### 旧方式 (环境变量):
|
|
49
|
-
```tsx
|
|
50
|
-
import { I18N_STOREFRONT_TOKEN, I18N_STORE_DOMAIN, BRAND } from './utils/store'
|
|
51
|
-
|
|
52
|
-
const token = I18N_STOREFRONT_TOKEN[locale]
|
|
53
|
-
const domain = I18N_STORE_DOMAIN[locale]
|
|
54
|
-
const brand = BRAND
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
#### 新方式 (Context):
|
|
58
|
-
```tsx
|
|
59
|
-
import { useShopifyContext, useStoreTokens, useStoreDomains, useStoreConfig } from './context'
|
|
60
|
-
|
|
61
|
-
const { currentStore, brand } = useShopifyContext()
|
|
62
|
-
const { currentToken } = useStoreTokens()
|
|
63
|
-
const { currentDomain } = useStoreDomains()
|
|
64
|
-
const { brand: configBrand } = useStoreConfig()
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### 3. 常用迁移模式
|
|
68
|
-
|
|
69
|
-
#### 获取当前店铺信息
|
|
70
|
-
```tsx
|
|
71
|
-
// 旧方式
|
|
72
|
-
const currentStore = I18N_STORE_DOMAIN[locale]
|
|
73
|
-
const currentToken = I18N_STOREFRONT_TOKEN[locale]
|
|
74
|
-
|
|
75
|
-
// 新方式
|
|
76
|
-
const { currentStore } = useShopifyContext()
|
|
77
|
-
const { currentToken } = useStoreTokens()
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
#### 获取 API URL
|
|
81
|
-
```tsx
|
|
82
|
-
// 旧方式
|
|
83
|
-
const apiUrl = `https://${I18N_STORE_DOMAIN[locale]}/api/2025-07/graphql.json`
|
|
84
|
-
|
|
85
|
-
// 新方式
|
|
86
|
-
const { getApiUrlByLocale } = useShopifyContext()
|
|
87
|
-
const apiUrl = getApiUrlByLocale(locale)
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
#### 获取主题域名
|
|
91
|
-
```tsx
|
|
92
|
-
// 旧方式
|
|
93
|
-
const themeDomain = I18N_THEME_DOMAIN[locale]
|
|
94
|
-
|
|
95
|
-
// 新方式
|
|
96
|
-
const { getThemeDomainByLocale } = useShopifyContext()
|
|
97
|
-
const themeDomain = getThemeDomainByLocale(locale)
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### 4. 多国家页面构建
|
|
101
|
-
|
|
102
|
-
对于不同国家的页面,你可以在构建时动态设置 locale:
|
|
103
|
-
|
|
104
|
-
```tsx
|
|
105
|
-
// pages/[locale]/products.tsx
|
|
106
|
-
import { ShopifyProvider, createShopifyConfig } from '@anker-in/campaign-ui/shopify/context'
|
|
107
|
-
|
|
108
|
-
export default function ProductsPage({ locale }: { locale: string }) {
|
|
109
|
-
const shopifyConfig = createShopifyConfig({
|
|
110
|
-
brand: 'soundcore',
|
|
111
|
-
env: process.env.NODE_ENV === 'production' ? 'production' : 'development',
|
|
112
|
-
metafieldNamespacePrefix: 'custom',
|
|
113
|
-
stores: getStoresForLocale(locale) // 根据 locale 获取对应的店铺配置
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<ShopifyProvider config={shopifyConfig} locale={locale}>
|
|
118
|
-
<ProductList />
|
|
119
|
-
</ShopifyProvider>
|
|
120
|
-
)
|
|
121
|
-
}
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### 5. 向后兼容
|
|
125
|
-
|
|
126
|
-
如果你需要逐步迁移,可以使用 `createShopifyConfigFromEnv()` 来保持向后兼容:
|
|
127
|
-
|
|
128
|
-
```tsx
|
|
129
|
-
import { createShopifyConfigFromEnv } from '@anker-in/campaign-ui/shopify/context'
|
|
130
|
-
|
|
131
|
-
// 从环境变量创建配置(向后兼容)
|
|
132
|
-
const shopifyConfig = createShopifyConfigFromEnv()
|
|
133
|
-
|
|
134
|
-
function App({ locale }: { locale: string }) {
|
|
135
|
-
return (
|
|
136
|
-
<ShopifyProvider config={shopifyConfig} locale={locale}>
|
|
137
|
-
<YourAppContent />
|
|
138
|
-
</ShopifyProvider>
|
|
139
|
-
)
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## 优势
|
|
144
|
-
|
|
145
|
-
1. **类型安全**: 完整的 TypeScript 支持
|
|
146
|
-
2. **灵活性**: 支持动态配置,不依赖环境变量
|
|
147
|
-
3. **多店铺支持**: 轻松管理多个国家的店铺配置
|
|
148
|
-
4. **测试友好**: 可以轻松 mock 配置进行测试
|
|
149
|
-
5. **构建时配置**: 支持在构建时根据国家动态设置配置
|
|
150
|
-
|
|
151
|
-
## 注意事项
|
|
152
|
-
|
|
153
|
-
1. 确保在使用任何 shopify 相关 hooks 之前设置了 `ShopifyProvider`
|
|
154
|
-
2. 每个页面/组件只能有一个 `ShopifyProvider`
|
|
155
|
-
3. `locale` 必须在配置的 `stores` 中存在
|
|
156
|
-
4. 建议在生产环境中使用手动配置而不是环境变量
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React, { createContext, useContext, useMemo, ReactNode } from 'react'
|
|
2
|
-
|
|
3
|
-
import { ShopifyConfig, SiteConfig, ShopifyContextValue } from '../types/config'
|
|
4
|
-
|
|
5
|
-
const ShopifyContext = createContext<ShopifyContextValue | null>(null)
|
|
6
|
-
|
|
7
|
-
interface ShopifyProviderProps {
|
|
8
|
-
children: ReactNode
|
|
9
|
-
shopifyConfig: ShopifyConfig
|
|
10
|
-
siteConfig: SiteConfig
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const ShopifyProvider: React.FC<ShopifyProviderProps> = ({ children, siteConfig, shopifyConfig }) => {
|
|
14
|
-
const contextValue = useMemo((): ShopifyContextValue => {
|
|
15
|
-
if (!siteConfig || !shopifyConfig) {
|
|
16
|
-
throw new Error(`No site configuration or shopify configuration found`)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
...siteConfig,
|
|
21
|
-
...shopifyConfig,
|
|
22
|
-
}
|
|
23
|
-
}, [siteConfig, shopifyConfig])
|
|
24
|
-
|
|
25
|
-
return <ShopifyContext.Provider value={contextValue}>{children}</ShopifyContext.Provider>
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const useShopifyContext = (): ShopifyContextValue => {
|
|
29
|
-
const context = useContext(ShopifyContext)
|
|
30
|
-
if (!context) {
|
|
31
|
-
throw new Error('useShopifyContext must be used within a ShopifyProvider')
|
|
32
|
-
}
|
|
33
|
-
return context
|
|
34
|
-
}
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { P as ProductVariant, a as Product, D as DeliveryAddress, B as BaseCartLine, C as Cart$1 } from './graphql-D4M28V-x';
|
|
2
|
-
|
|
3
|
-
type Discount = {
|
|
4
|
-
value?: number;
|
|
5
|
-
percentage?: number;
|
|
6
|
-
amount?: number;
|
|
7
|
-
currencyCode?: string;
|
|
8
|
-
};
|
|
9
|
-
type Measurement = {
|
|
10
|
-
value: number;
|
|
11
|
-
unit: 'KILOGRAMS' | 'GRAMS' | 'POUNDS' | 'OUNCES';
|
|
12
|
-
};
|
|
13
|
-
type Image = {
|
|
14
|
-
url: string;
|
|
15
|
-
altText?: string;
|
|
16
|
-
width?: number;
|
|
17
|
-
height?: number;
|
|
18
|
-
};
|
|
19
|
-
type Maybe<T> = T | null;
|
|
20
|
-
type ExtractVariables<T> = T extends {
|
|
21
|
-
variables?: object;
|
|
22
|
-
} ? T['variables'] : undefined;
|
|
23
|
-
interface CommerceAPIFetchOptions<T> {
|
|
24
|
-
variables?: ExtractVariables<T>;
|
|
25
|
-
preview?: boolean;
|
|
26
|
-
}
|
|
27
|
-
type Connection<T> = {
|
|
28
|
-
edges: Array<Edge<T>>;
|
|
29
|
-
};
|
|
30
|
-
type Edge<T> = {
|
|
31
|
-
node: T;
|
|
32
|
-
};
|
|
33
|
-
type Menu = {
|
|
34
|
-
title: string;
|
|
35
|
-
path: string;
|
|
36
|
-
};
|
|
37
|
-
type Money = {
|
|
38
|
-
amount: string;
|
|
39
|
-
currencyCode: string;
|
|
40
|
-
};
|
|
41
|
-
type SEO = {
|
|
42
|
-
title: string;
|
|
43
|
-
description: string;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
type CartItem = BaseCartLine & {
|
|
47
|
-
id: string;
|
|
48
|
-
quantity: number;
|
|
49
|
-
};
|
|
50
|
-
type Attributes = {
|
|
51
|
-
key: string;
|
|
52
|
-
value: string;
|
|
53
|
-
}[];
|
|
54
|
-
type ShopifyCartOperation = {
|
|
55
|
-
cart: Cart$1;
|
|
56
|
-
variables: {
|
|
57
|
-
cartId: string;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
type ShopifyCreateCartOperation = {
|
|
61
|
-
cartCreate: {
|
|
62
|
-
cart: Cart;
|
|
63
|
-
};
|
|
64
|
-
variables: {
|
|
65
|
-
buyerIdentity?: any;
|
|
66
|
-
lines: {
|
|
67
|
-
merchandiseId: string;
|
|
68
|
-
quantity: number;
|
|
69
|
-
attributes?: any;
|
|
70
|
-
}[];
|
|
71
|
-
attributes?: {};
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
type ShopifyAddToCartOperation = {
|
|
75
|
-
cartLinesAdd: {
|
|
76
|
-
cart: Cart$1;
|
|
77
|
-
};
|
|
78
|
-
variables: {
|
|
79
|
-
cartId: string;
|
|
80
|
-
buyerIdentity?: any;
|
|
81
|
-
lines: {
|
|
82
|
-
merchandiseId: string;
|
|
83
|
-
quantity: number;
|
|
84
|
-
attributes?: any;
|
|
85
|
-
}[];
|
|
86
|
-
attributes?: {};
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
type ShopifyRemoveFromCartOperation = {
|
|
90
|
-
cartLinesRemove: {
|
|
91
|
-
cart: Cart$1;
|
|
92
|
-
};
|
|
93
|
-
variables: {
|
|
94
|
-
cartId: string;
|
|
95
|
-
lineIds: string[];
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
type ShopifyUpdateCartOperation = {
|
|
99
|
-
cartLinesUpdate: {
|
|
100
|
-
cart: Cart$1;
|
|
101
|
-
};
|
|
102
|
-
variables: {
|
|
103
|
-
cartId: string;
|
|
104
|
-
lines: {
|
|
105
|
-
id: string;
|
|
106
|
-
merchandiseId?: string;
|
|
107
|
-
quantity?: number;
|
|
108
|
-
attributes?: any;
|
|
109
|
-
}[];
|
|
110
|
-
attributes?: any;
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
type ShopifyCodesUpdateCartOperation = {
|
|
114
|
-
cartDiscountCodesUpdate: {
|
|
115
|
-
cart: Cart$1;
|
|
116
|
-
};
|
|
117
|
-
variables: {
|
|
118
|
-
cartId: string;
|
|
119
|
-
discountCodes: string[];
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
type CartAttributesUpdateOperation = {
|
|
123
|
-
cartAttributesUpdate: {
|
|
124
|
-
cart: Cart$1;
|
|
125
|
-
};
|
|
126
|
-
variables: {
|
|
127
|
-
cartId: string;
|
|
128
|
-
attributes: any;
|
|
129
|
-
};
|
|
130
|
-
};
|
|
131
|
-
type InputArribute = {
|
|
132
|
-
key?: string;
|
|
133
|
-
value?: string;
|
|
134
|
-
};
|
|
135
|
-
type subInputValue = {
|
|
136
|
-
[key: string]: string;
|
|
137
|
-
};
|
|
138
|
-
type InputLineItem = {
|
|
139
|
-
merchandiseId: string;
|
|
140
|
-
quantity: number;
|
|
141
|
-
attributes: any;
|
|
142
|
-
buyerIdentity?: any;
|
|
143
|
-
sellingPlanId?: string;
|
|
144
|
-
};
|
|
145
|
-
type SelectedOption = {
|
|
146
|
-
id?: string;
|
|
147
|
-
name: string;
|
|
148
|
-
value: string;
|
|
149
|
-
};
|
|
150
|
-
type LineItem = {
|
|
151
|
-
id: string;
|
|
152
|
-
variantId: string;
|
|
153
|
-
productId: string;
|
|
154
|
-
name: string;
|
|
155
|
-
quantity: number;
|
|
156
|
-
discounts: Discount[];
|
|
157
|
-
path: string;
|
|
158
|
-
variant: ProductVariant;
|
|
159
|
-
totalAmount: number;
|
|
160
|
-
subtotalAmount: number;
|
|
161
|
-
options?: SelectedOption[];
|
|
162
|
-
discountAllocations?: DiscountAllocations[];
|
|
163
|
-
product?: Product;
|
|
164
|
-
customAttributes?: any;
|
|
165
|
-
attributes?: any;
|
|
166
|
-
sellingPlan?: string;
|
|
167
|
-
};
|
|
168
|
-
type Discounts = {
|
|
169
|
-
applicable: boolean;
|
|
170
|
-
code: string;
|
|
171
|
-
};
|
|
172
|
-
type DiscountAllocations = {
|
|
173
|
-
amount: number;
|
|
174
|
-
code: string;
|
|
175
|
-
};
|
|
176
|
-
type EstimatedCost = {
|
|
177
|
-
amount: string;
|
|
178
|
-
currencyCode: string;
|
|
179
|
-
};
|
|
180
|
-
type SelectedDeliveryOption = {
|
|
181
|
-
code: string;
|
|
182
|
-
estimatedCost: EstimatedCost;
|
|
183
|
-
handle: string;
|
|
184
|
-
title: string;
|
|
185
|
-
};
|
|
186
|
-
type DeliveryGroups = {
|
|
187
|
-
deliveryAddress: DeliveryAddress;
|
|
188
|
-
deliveryOptions: any;
|
|
189
|
-
id: string;
|
|
190
|
-
selectedDeliveryOption?: any;
|
|
191
|
-
};
|
|
192
|
-
type Cart = {
|
|
193
|
-
id: string;
|
|
194
|
-
customerId?: string;
|
|
195
|
-
email?: string;
|
|
196
|
-
createdAt: string;
|
|
197
|
-
currency: {
|
|
198
|
-
code: string;
|
|
199
|
-
};
|
|
200
|
-
taxesIncluded?: boolean;
|
|
201
|
-
lineItems: LineItem[];
|
|
202
|
-
totalLineItemsDiscount?: number;
|
|
203
|
-
orderDiscounts?: number;
|
|
204
|
-
lineItemsSubtotalPrice: number;
|
|
205
|
-
subtotalPrice: number;
|
|
206
|
-
totalPrice: number;
|
|
207
|
-
totalTaxAmount: number;
|
|
208
|
-
discountCodes: Discounts[];
|
|
209
|
-
discountAllocations?: DiscountAllocations[];
|
|
210
|
-
discounts?: Discount[];
|
|
211
|
-
url?: string;
|
|
212
|
-
ready: boolean;
|
|
213
|
-
orderStatusUrl?: any;
|
|
214
|
-
customAttributes?: any;
|
|
215
|
-
buyerIdentity?: any;
|
|
216
|
-
deliveryAmount?: number;
|
|
217
|
-
deliveryGroups?: DeliveryGroups[];
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
export type { Attributes as A, CommerceAPIFetchOptions as C, Discount as D, ExtractVariables as E, Image as I, LineItem as L, Measurement as M, SEO as S, Maybe as a, Connection as b, Edge as c, Menu as d, Money as e, CartItem as f, ShopifyCartOperation as g, ShopifyCreateCartOperation as h, ShopifyAddToCartOperation as i, ShopifyRemoveFromCartOperation as j, ShopifyUpdateCartOperation as k, ShopifyCodesUpdateCartOperation as l, CartAttributesUpdateOperation as m, InputArribute as n, InputLineItem as o, SelectedOption as p, Discounts as q, DiscountAllocations as r, subInputValue as s, EstimatedCost as t, SelectedDeliveryOption as u, DeliveryGroups as v, Cart as w };
|