ng-easycommerce-v18 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +16 -0
- package/README.md +27 -0
- package/angular.json +48 -0
- package/package.json +58 -0
- package/projects/ng-easycommerce/README.md +24 -0
- package/projects/ng-easycommerce/ng-package.json +7 -0
- package/projects/ng-easycommerce/package.json +12 -0
- package/projects/ng-easycommerce/src/lib/api/connection.service.ts +79 -0
- package/projects/ng-easycommerce/src/lib/api/index.ts +1 -0
- package/projects/ng-easycommerce/src/lib/assets/ec-i18n/ct.json +274 -0
- package/projects/ng-easycommerce/src/lib/assets/ec-i18n/en.json +380 -0
- package/projects/ng-easycommerce/src/lib/assets/ec-i18n/es.json +387 -0
- package/projects/ng-easycommerce/src/lib/assets/ec-i18n/fr.json +266 -0
- package/projects/ng-easycommerce/src/lib/assets/ec-i18n/gl.json +274 -0
- package/projects/ng-easycommerce/src/lib/assets/ec-i18n/pr.json +274 -0
- package/projects/ng-easycommerce/src/lib/assets/recaptcha/recaptcha-site-keys.json +4 -0
- package/projects/ng-easycommerce/src/lib/assets/recaptcha/recaptcha-sites-prod.json +39 -0
- package/projects/ng-easycommerce/src/lib/assets/recaptcha/recaptcha-sites.json +53 -0
- package/projects/ng-easycommerce/src/lib/classes/checkout/index.ts +1 -0
- package/projects/ng-easycommerce/src/lib/classes/checkout/steps.ts +37 -0
- package/projects/ng-easycommerce/src/lib/classes/filters/attributes-filter.ts +74 -0
- package/projects/ng-easycommerce/src/lib/classes/filters/category-filter.ts +57 -0
- package/projects/ng-easycommerce/src/lib/classes/filters/dynamics-filter.ts +57 -0
- package/projects/ng-easycommerce/src/lib/classes/filters/filter-factory.ts +23 -0
- package/projects/ng-easycommerce/src/lib/classes/filters/filter.ts +89 -0
- package/projects/ng-easycommerce/src/lib/classes/filters/index.ts +6 -0
- package/projects/ng-easycommerce/src/lib/classes/filters/sort-filter.ts +93 -0
- package/projects/ng-easycommerce/src/lib/classes/index.ts +3 -0
- package/projects/ng-easycommerce/src/lib/classes/user.ts +68 -0
- package/projects/ng-easycommerce/src/lib/constants/api.constants.service.ts +69 -0
- package/projects/ng-easycommerce/src/lib/constants/core.constants.service.ts +210 -0
- package/projects/ng-easycommerce/src/lib/constants/index.ts +2 -0
- package/projects/ng-easycommerce/src/lib/ec-components/abstractions-components/block-ec.component.ts +107 -0
- package/projects/ng-easycommerce/src/lib/ec-components/abstractions-components/index.ts +2 -0
- package/projects/ng-easycommerce/src/lib/ec-components/abstractions-components/menu-ec.component.ts +102 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/auth-ec.component.html +10 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/auth-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/auth-ec.component.ts +13 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/confirm-account-ec/confirm-account-ec.component.html +19 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/confirm-account-ec/confirm-account-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/confirm-account-ec/confirm-account-ec.component.ts +34 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/forgot-password-ec/forgot-password-ec.component.html +31 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/forgot-password-ec/forgot-password-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/forgot-password-ec/forgot-password-ec.component.ts +55 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/index.ts +6 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/login-form-ec/login-form-ec.component.html +30 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/login-form-ec/login-form-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/login-form-ec/login-form-ec.component.ts +92 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/register-form-ec/register-form-ec.component.html +55 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/register-form-ec/register-form-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/register-form-ec/register-form-ec.component.ts +102 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/register-wholesaler-form-ec/register-wholesaler-form-ec.component.html +233 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/register-wholesaler-form-ec/register-wholesaler-form-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/auth-ec/register-wholesaler-form-ec/register-wholesaler-form-ec.component.ts +149 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-banner-box-ec/block-banner-box-ec.component.html +113 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-banner-box-ec/block-banner-box-ec.component.scss +12 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-banner-box-ec/block-banner-box-ec.component.ts +100 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-banner-full-ec/block-banner-full-ec.component.html +111 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-banner-full-ec/block-banner-full-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-banner-full-ec/block-banner-full-ec.component.ts +77 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-form-contact-ec/block-form-contact-ec.component.html +62 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-form-contact-ec/block-form-contact-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-form-contact-ec/block-form-contact-ec.component.ts +89 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-html-ec/block-html-ec.component.html +1 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-html-ec/block-html-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-html-ec/block-html-ec.component.ts +33 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-newsletter-ec/block-newsletter-ec.component.html +1 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-newsletter-ec/block-newsletter-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-newsletter-ec/block-newsletter-ec.component.ts +81 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-products-ec/block-products-ec.component.html +40 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-products-ec/block-products-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/block-products-ec/block-products-ec.component.ts +97 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/blocks-ec.component.html +41 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/blocks-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/blocks-ec.component.ts +86 -0
- package/projects/ng-easycommerce/src/lib/ec-components/blocks-ec/index.ts +4 -0
- package/projects/ng-easycommerce/src/lib/ec-components/breadcrumb-ec/breadcrumb-ec.component.html +20 -0
- package/projects/ng-easycommerce/src/lib/ec-components/breadcrumb-ec/breadcrumb-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/breadcrumb-ec/breadcrumb-ec.component.ts +30 -0
- package/projects/ng-easycommerce/src/lib/ec-components/cart-ec/cart-ec.component.html +1 -0
- package/projects/ng-easycommerce/src/lib/ec-components/cart-ec/cart-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/cart-ec/cart-ec.component.ts +24 -0
- package/projects/ng-easycommerce/src/lib/ec-components/cart-ec/cart-item-ec/cart-item-ec.component.html +1 -0
- package/projects/ng-easycommerce/src/lib/ec-components/cart-ec/cart-item-ec/cart-item-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/cart-ec/cart-item-ec/cart-item-ec.component.ts +51 -0
- package/projects/ng-easycommerce/src/lib/ec-components/cart-ec/index.ts +2 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/checkout-ec.component.html +56 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/checkout-ec.component.scss +38 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/checkout-ec.component.ts +67 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/dataform-ec/dataform-ec.component.html +836 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/dataform-ec/dataform-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/dataform-ec/dataform-ec.component.ts +302 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/dataform-ec/input-ec/input-ec.component.html +32 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/dataform-ec/input-ec/input-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/dataform-ec/input-ec/input-ec.component.ts +52 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/detail-checkout-block-ec/detail-checkout-block-ec.component.html +12 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/detail-checkout-block-ec/detail-checkout-block-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/detail-checkout-block-ec/detail-checkout-block-ec.component.ts +48 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/payment-ec/payment-ec.component.html +195 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/payment-ec/payment-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/payment-ec/payment-ec.component.ts +103 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/payment-ec/payment-methods/bank-transfer-ec/bank-transfer-ec.component.html +28 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/payment-ec/payment-methods/bank-transfer-ec/bank-transfer-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/payment-ec/payment-methods/bank-transfer-ec/bank-transfer-ec.component.ts +26 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/payment-ec/payment-methods/index.ts +3 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/payment-ec/payment-methods/mp-redirect-ec/mp-redirect-ec.component.html +33 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/payment-ec/payment-methods/mp-redirect-ec/mp-redirect-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/payment-ec/payment-methods/mp-redirect-ec/mp-redirect-ec.component.ts +116 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/payment-ec/payment-methods/offline-ec/offline-ec.component.html +13 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/payment-ec/payment-methods/offline-ec/offline-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/payment-ec/payment-methods/offline-ec/offline-ec.component.ts +26 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/shipment-ec/shipment-ec.component.html +111 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/shipment-ec/shipment-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/shipment-ec/shipment-ec.component.ts +111 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/step-container-ec/step-container-ec.component.html +33 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/step-container-ec/step-container-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/step-container-ec/step-container-ec.component.ts +39 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/success-ec/success-ec.component.html +59 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/success-ec/success-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/checkout-ec/success-ec/success-ec.component.ts +65 -0
- package/projects/ng-easycommerce/src/lib/ec-components/collection-ec/collection-ec.component.html +16 -0
- package/projects/ng-easycommerce/src/lib/ec-components/collection-ec/collection-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/collection-ec/collection-ec.component.ts +83 -0
- package/projects/ng-easycommerce/src/lib/ec-components/coupon-ec/coupon-ec.component.html +1 -0
- package/projects/ng-easycommerce/src/lib/ec-components/coupon-ec/coupon-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/coupon-ec/coupon-ec.component.ts +32 -0
- package/projects/ng-easycommerce/src/lib/ec-components/filters-ec/filters-ec.component.html +1 -0
- package/projects/ng-easycommerce/src/lib/ec-components/filters-ec/filters-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/filters-ec/filters-ec.component.ts +45 -0
- package/projects/ng-easycommerce/src/lib/ec-components/filters-sort-ec/filters-sort-ec.component.html +1 -0
- package/projects/ng-easycommerce/src/lib/ec-components/filters-sort-ec/filters-sort-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/filters-sort-ec/filters-sort-ec.component.ts +49 -0
- package/projects/ng-easycommerce/src/lib/ec-components/footer-ec/footer-ec.component.html +1 -0
- package/projects/ng-easycommerce/src/lib/ec-components/footer-ec/footer-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/footer-ec/footer-ec.component.spec.ts +23 -0
- package/projects/ng-easycommerce/src/lib/ec-components/footer-ec/footer-ec.component.ts +18 -0
- package/projects/ng-easycommerce/src/lib/ec-components/header-ec/header-ec.component.html +1 -0
- package/projects/ng-easycommerce/src/lib/ec-components/header-ec/header-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/header-ec/header-ec.component.spec.ts +23 -0
- package/projects/ng-easycommerce/src/lib/ec-components/header-ec/header-ec.component.ts +22 -0
- package/projects/ng-easycommerce/src/lib/ec-components/home-ec/home-ec.component.html +1 -0
- package/projects/ng-easycommerce/src/lib/ec-components/home-ec/home-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/home-ec/home-ec.component.spec.ts +23 -0
- package/projects/ng-easycommerce/src/lib/ec-components/home-ec/home-ec.component.ts +16 -0
- package/projects/ng-easycommerce/src/lib/ec-components/index.ts +17 -0
- package/projects/ng-easycommerce/src/lib/ec-components/product-detail-ec/product-detail-ec.component.html +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/product-detail-ec/product-detail-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/product-detail-ec/product-detail-ec.component.ts +82 -0
- package/projects/ng-easycommerce/src/lib/ec-components/product-ec/product-ec.component.html +31 -0
- package/projects/ng-easycommerce/src/lib/ec-components/product-ec/product-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/product-ec/product-ec.component.ts +46 -0
- package/projects/ng-easycommerce/src/lib/ec-components/variants-ec/variants-ec.component.html +65 -0
- package/projects/ng-easycommerce/src/lib/ec-components/variants-ec/variants-ec.component.scss +8 -0
- package/projects/ng-easycommerce/src/lib/ec-components/variants-ec/variants-ec.component.ts +20 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/index.ts +4 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/loading/index.ts +3 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/loading/loading-full-ec/loading-full-ec.component.html +7 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/loading/loading-full-ec/loading-full-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/loading/loading-full-ec/loading-full-ec.component.ts +13 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/loading/loading-inline-ec/loading-inline-ec.component.html +5 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/loading/loading-inline-ec/loading-inline-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/loading/loading-inline-ec/loading-inline-ec.component.ts +13 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/loading/loading-section-ec/loading-section-ec.component.html +3 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/loading/loading-section-ec/loading-section-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/loading/loading-section-ec/loading-section-ec.component.ts +13 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/magnizoom-ec/magnizoom-ec.component.html +11 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/magnizoom-ec/magnizoom-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/magnizoom-ec/magnizoom-ec.component.ts +177 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/price-ec/price-ec.component.html +47 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/price-ec/price-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/price-ec/price-ec.component.ts +22 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/re-captcha-ec/re-captcha-ec.component.html +6 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/re-captcha-ec/re-captcha-ec.component.scss +0 -0
- package/projects/ng-easycommerce/src/lib/ec-components/widgets-ec/re-captcha-ec/re-captcha-ec.component.ts +70 -0
- package/projects/ng-easycommerce/src/lib/ec-guards/auth.guard.ts +19 -0
- package/projects/ng-easycommerce/src/lib/ec-guards/index.ts +1 -0
- package/projects/ng-easycommerce/src/lib/ec-pipe/ec-currency-symbol.pipe.ts +99 -0
- package/projects/ng-easycommerce/src/lib/ec-pipe/index.ts +1 -0
- package/projects/ng-easycommerce/src/lib/ec-services/addressing.service.ts +199 -0
- package/projects/ng-easycommerce/src/lib/ec-services/analytics/analytics.service.ts +76 -0
- package/projects/ng-easycommerce/src/lib/ec-services/analytics/doppler.service.ts +38 -0
- package/projects/ng-easycommerce/src/lib/ec-services/analytics/facebook-pixel.service.ts +214 -0
- package/projects/ng-easycommerce/src/lib/ec-services/analytics/google-analytics.service.ts +284 -0
- package/projects/ng-easycommerce/src/lib/ec-services/analytics/gtm.service.ts +413 -0
- package/projects/ng-easycommerce/src/lib/ec-services/analytics/index.ts +6 -0
- package/projects/ng-easycommerce/src/lib/ec-services/analytics/metricool-pixel.service.ts +46 -0
- package/projects/ng-easycommerce/src/lib/ec-services/auth.service.ts +438 -0
- package/projects/ng-easycommerce/src/lib/ec-services/auth.storage.service.ts +54 -0
- package/projects/ng-easycommerce/src/lib/ec-services/blocks-repository.service.ts +67 -0
- package/projects/ng-easycommerce/src/lib/ec-services/blocks.service.ts +48 -0
- package/projects/ng-easycommerce/src/lib/ec-services/cart.service.ts +492 -0
- package/projects/ng-easycommerce/src/lib/ec-services/channel.service.ts +81 -0
- package/projects/ng-easycommerce/src/lib/ec-services/checkout.service.ts +196 -0
- package/projects/ng-easycommerce/src/lib/ec-services/currency.service.ts +179 -0
- package/projects/ng-easycommerce/src/lib/ec-services/filters.service.ts +133 -0
- package/projects/ng-easycommerce/src/lib/ec-services/form.service.ts +82 -0
- package/projects/ng-easycommerce/src/lib/ec-services/index.ts +24 -0
- package/projects/ng-easycommerce/src/lib/ec-services/local-storage.service.ts +54 -0
- package/projects/ng-easycommerce/src/lib/ec-services/ngx-local-storage.service.ts +66 -0
- package/projects/ng-easycommerce/src/lib/ec-services/options.service.ts +274 -0
- package/projects/ng-easycommerce/src/lib/ec-services/order-utility.service.ts +52 -0
- package/projects/ng-easycommerce/src/lib/ec-services/pagination.service.ts +172 -0
- package/projects/ng-easycommerce/src/lib/ec-services/parameters.service.ts +67 -0
- package/projects/ng-easycommerce/src/lib/ec-services/payment.service.ts +63 -0
- package/projects/ng-easycommerce/src/lib/ec-services/product-detail.service.ts +288 -0
- package/projects/ng-easycommerce/src/lib/ec-services/products.service.ts +162 -0
- package/projects/ng-easycommerce/src/lib/ec-services/re-captcha.service.ts +126 -0
- package/projects/ng-easycommerce/src/lib/ec-services/shipment.service.ts +174 -0
- package/projects/ng-easycommerce/src/lib/ec-services/stores.service.ts +27 -0
- package/projects/ng-easycommerce/src/lib/ec-services/toast.service.ts +84 -0
- package/projects/ng-easycommerce/src/lib/interceptors/auth.interceptor.ts +43 -0
- package/projects/ng-easycommerce/src/lib/interceptors/index.ts +1 -0
- package/projects/ng-easycommerce/src/lib/interfaces/analytics/event-key.ts +14 -0
- package/projects/ng-easycommerce/src/lib/interfaces/analytics/facebook-pixel-data.ts +5 -0
- package/projects/ng-easycommerce/src/lib/interfaces/analytics/gtm-config.ts +6 -0
- package/projects/ng-easycommerce/src/lib/interfaces/analytics/index.ts +3 -0
- package/projects/ng-easycommerce/src/lib/interfaces/blocks.ts +56 -0
- package/projects/ng-easycommerce/src/lib/interfaces/checkout.ts +14 -0
- package/projects/ng-easycommerce/src/lib/interfaces/connection.ts +8 -0
- package/projects/ng-easycommerce/src/lib/interfaces/coupon.ts +5 -0
- package/projects/ng-easycommerce/src/lib/interfaces/currency.ts +10 -0
- package/projects/ng-easycommerce/src/lib/interfaces/deserializable.ts +3 -0
- package/projects/ng-easycommerce/src/lib/interfaces/environment.ts +6 -0
- package/projects/ng-easycommerce/src/lib/interfaces/filter.ts +59 -0
- package/projects/ng-easycommerce/src/lib/interfaces/index.ts +18 -0
- package/projects/ng-easycommerce/src/lib/interfaces/options.ts +28 -0
- package/projects/ng-easycommerce/src/lib/interfaces/pagination.ts +27 -0
- package/projects/ng-easycommerce/src/lib/interfaces/parameter.ts +15 -0
- package/projects/ng-easycommerce/src/lib/interfaces/product.ts +81 -0
- package/projects/ng-easycommerce/src/lib/interfaces/step.ts +19 -0
- package/projects/ng-easycommerce/src/lib/interfaces/storage.ts +7 -0
- package/projects/ng-easycommerce/src/lib/interfaces/store.ts +17 -0
- package/projects/ng-easycommerce/src/lib/interfaces/types/index.ts +1 -0
- package/projects/ng-easycommerce/src/lib/interfaces/types/user.type.ts +5 -0
- package/projects/ng-easycommerce/src/lib/providers/index.ts +1 -0
- package/projects/ng-easycommerce/src/lib/providers/provideEnvironment.ts +24 -0
- package/projects/ng-easycommerce/src/lib/stores/currency.store.ts +20 -0
- package/projects/ng-easycommerce/src/lib/stores/index.ts +1 -0
- package/projects/ng-easycommerce/src/public-api.ts +24 -0
- package/projects/ng-easycommerce/tsconfig.lib.json +15 -0
- package/projects/ng-easycommerce/tsconfig.lib.prod.json +11 -0
- package/projects/ng-easycommerce/tsconfig.spec.json +15 -0
- package/tsconfig.doc.json +4 -0
- package/tsconfig.json +37 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { inject, Injectable } from '@angular/core';
|
|
2
|
+
import { ProductsService } from './products.service';
|
|
3
|
+
import { BehaviorSubject, firstValueFrom } from 'rxjs';
|
|
4
|
+
import { Options, OptionValue, Product } from '../interfaces';
|
|
5
|
+
import { ToastService } from './toast.service';
|
|
6
|
+
import { CartService } from './cart.service';
|
|
7
|
+
|
|
8
|
+
@Injectable({
|
|
9
|
+
providedIn: 'root'
|
|
10
|
+
})
|
|
11
|
+
export class ProductDetailService {
|
|
12
|
+
private _productsService: ProductsService = inject(ProductsService);
|
|
13
|
+
private _toastService: ToastService = inject(ToastService);
|
|
14
|
+
private _cartService: CartService = inject(CartService);
|
|
15
|
+
|
|
16
|
+
private _productSubject = new BehaviorSubject<Product | null>({});
|
|
17
|
+
private _optionsSubject = new BehaviorSubject<any>({});
|
|
18
|
+
private _associatedDataSubject = new BehaviorSubject<any>({ price: '', stock: 0, picture: '' });
|
|
19
|
+
|
|
20
|
+
public product$ = this._productSubject.asObservable();
|
|
21
|
+
public options$ = this._optionsSubject.asObservable();
|
|
22
|
+
public associatedData$ = this._associatedDataSubject.asObservable();
|
|
23
|
+
|
|
24
|
+
private variants: any[] = []
|
|
25
|
+
|
|
26
|
+
constructor() { }
|
|
27
|
+
/**
|
|
28
|
+
* Obtengo el producto a traves de su codigo e inicializo la configuración
|
|
29
|
+
* del Servicio.
|
|
30
|
+
* @param code
|
|
31
|
+
* @param variant
|
|
32
|
+
*/
|
|
33
|
+
loadProduct(code: string, variant: boolean = false) {
|
|
34
|
+
firstValueFrom(this._productsService.getProductByCode(code, variant))
|
|
35
|
+
.then(res => {
|
|
36
|
+
variant ? this.initialize(res, code) : this.initialize(res)
|
|
37
|
+
})
|
|
38
|
+
.catch(err => { console.log(err); this._productSubject.next(null) });
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Carga el producto en el observable y la configuración de las variantes.
|
|
42
|
+
* @param product
|
|
43
|
+
* @param variantCode
|
|
44
|
+
*/
|
|
45
|
+
private initialize(product: Product, variantCode?: string) {
|
|
46
|
+
this._productSubject.next(product);
|
|
47
|
+
const aux: Product['options'] = product.options || [];
|
|
48
|
+
const options = aux?.map(option => this.toOption(option))
|
|
49
|
+
this._optionsSubject.next(options);
|
|
50
|
+
variantCode ? this.updateVariants(variantCode) : this.updateVariants();
|
|
51
|
+
this.variants.length && this.generateAssociatedDataFromVariants();
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Formate los datos para las opciones del producto.
|
|
55
|
+
* @param option
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
private toOption(option: Options) {
|
|
59
|
+
return {
|
|
60
|
+
name: option.label,
|
|
61
|
+
code: option.code,
|
|
62
|
+
type: option.type,
|
|
63
|
+
values: option.values.map((value: any) => ({ name: value.code, description: value.name, image: value.image, mobileImage: value.mobileImage, selected: false }))
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Cambia las opciones, obtiene el producto asociado a la opcion elegida.
|
|
69
|
+
*/
|
|
70
|
+
setOption(optionCode: any, optionValue: any) {
|
|
71
|
+
const options = this._optionsSubject.value;
|
|
72
|
+
const option = options.find((element: any) => element.code == optionCode).values.find((value: any) => value.name == optionValue);
|
|
73
|
+
option.selected = !option.selected;
|
|
74
|
+
options.find((element: any) => element.code == optionCode).values.forEach(
|
|
75
|
+
(value: any) => { if (value.name != option.name) value.selected = false }
|
|
76
|
+
);
|
|
77
|
+
this._optionsSubject.next(options);
|
|
78
|
+
this.updateVariants();
|
|
79
|
+
this.variants.length > 0 ? this.generateAssociatedDataFromVariants() : this._toastService.show('selection-not-available')
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Actualiza el observable de `associatedData` el cual se utiliza para mostrar los datos
|
|
83
|
+
* en el frontend segun el producto y/o variante elegida.
|
|
84
|
+
* Obtiene los datos de la variante y los formatea.
|
|
85
|
+
*/
|
|
86
|
+
generateAssociatedDataFromVariants() {
|
|
87
|
+
let associated: any = {};
|
|
88
|
+
if (this.variants.length == 1) {
|
|
89
|
+
const variant = this.variants[0];
|
|
90
|
+
console.log(variant)
|
|
91
|
+
associated.stock = variant.stock
|
|
92
|
+
associated.price = variant.price.toString();
|
|
93
|
+
associated.saleprice = variant.saleprice && variant.saleprice.toString() || undefined;
|
|
94
|
+
associated.discount = variant?.discount || undefined;
|
|
95
|
+
associated.properties = variant.properties ? this.beautifyProperties(variant.properties) : undefined;
|
|
96
|
+
associated.uniqueExternalCode = variant?.uniqueExternalCode || undefined;
|
|
97
|
+
associated.multipleQuantity = variant?.multipleQuantity || undefined;
|
|
98
|
+
} else {
|
|
99
|
+
associated.price = this.createPrice()
|
|
100
|
+
associated.saleprice = this.createSalePrice()
|
|
101
|
+
associated.stock = (this.variants.map(variant => variant.stock)).reduce((a, b) => a + b)
|
|
102
|
+
associated.discount = this.createDiscount()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
('images' in this.variants[0] && this.variants[0].images.length > 0)
|
|
106
|
+
? associated.picture = this.variants[0].images[0]
|
|
107
|
+
: associated.picture = (this._associatedDataSubject.value?.picture || (this._productSubject.value && this._productSubject.value?.picturesdefault?.[0] || []));
|
|
108
|
+
|
|
109
|
+
associated.maximumAmount = this.variants[0]?.maximumAmount || 0
|
|
110
|
+
associated.minimumAmount = this.variants[0]?.minimumAmount || 0
|
|
111
|
+
|
|
112
|
+
associated.maximumItemsQuantity = this.variants[0]?.stock > 0 && 'maximumItemsQuantity' in this.variants[0] ? this.variants[0]?.maximumItemsQuantity : this.variants[0]?.stock
|
|
113
|
+
associated.minimumItemsQuantity = this.variants[0]?.stock > 0 && 'minimumItemsQuantity' in this.variants[0]
|
|
114
|
+
&& this.variants[0]?.minimumItemsQuantity > 0 ? this.variants[0]?.minimumItemsQuantity
|
|
115
|
+
: (this.variants[0]?.multipleQuantity ? this.variants[0]?.multipleQuantity : 1)
|
|
116
|
+
|
|
117
|
+
associated.finalConsumer = {
|
|
118
|
+
finalConsumerPrice: this.variants[0]?.final_consumer_price,
|
|
119
|
+
originalFinalConsumerPrice: this.variants[0]?.original_final_consumer_price,
|
|
120
|
+
}
|
|
121
|
+
associated.taxes = {
|
|
122
|
+
taxIncluded: this.variants[0]?.taxIncluded,
|
|
123
|
+
taxCategory: this.variants[0]?.taxCategory,
|
|
124
|
+
}
|
|
125
|
+
//console.log(associated)
|
|
126
|
+
this._associatedDataSubject.next(associated);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Mejora los datos de las `properties`.
|
|
130
|
+
* @param properties
|
|
131
|
+
* @returns
|
|
132
|
+
*/
|
|
133
|
+
beautifyProperties(properties: any): any {
|
|
134
|
+
let beautifyData: any = [];
|
|
135
|
+
properties.forEach((prop: any) => {
|
|
136
|
+
for (let key in prop) {
|
|
137
|
+
beautifyData.push({ name: key, value: prop[key] })
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
return beautifyData
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Devuelve un descuento en caso de existir.
|
|
144
|
+
* @returns
|
|
145
|
+
*/
|
|
146
|
+
createDiscount(): any {
|
|
147
|
+
let allDiscounts: string = '';
|
|
148
|
+
this.variants.forEach(variant => {
|
|
149
|
+
variant.discount && (allDiscounts += ', ' + variant.discount);
|
|
150
|
+
})
|
|
151
|
+
if (allDiscounts == '') return undefined;
|
|
152
|
+
return allDiscounts;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Devuelve el precio de venta.
|
|
156
|
+
* @returns
|
|
157
|
+
*/
|
|
158
|
+
createSalePrice(): any {
|
|
159
|
+
let minPrice: number = 0;
|
|
160
|
+
let maxPrice: number = 0;
|
|
161
|
+
let allPrices: any = this.variants.map(v => v.saleprice).filter(e => e !== undefined);
|
|
162
|
+
if (allPrices.length == 0) {
|
|
163
|
+
return undefined
|
|
164
|
+
}
|
|
165
|
+
minPrice = allPrices.reduce((a: number, b: number) => Math.min(a, b));
|
|
166
|
+
maxPrice = allPrices.reduce((a: number, b: number) => Math.max(a, b));
|
|
167
|
+
return minPrice == maxPrice ? maxPrice.toString() : minPrice + ' - ' + maxPrice;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Devuelve el precio o los precios en caso de tener varias variantes con distintos precios.
|
|
171
|
+
* @returns
|
|
172
|
+
*/
|
|
173
|
+
createPrice(): any {
|
|
174
|
+
let minPrice: number = 0;
|
|
175
|
+
let maxPrice: number = 0;
|
|
176
|
+
let allPrice: any = this.variants.map(v => v.price)
|
|
177
|
+
minPrice = allPrice.reduce((a: number, b: number) => Math.min(a, b));
|
|
178
|
+
maxPrice = allPrice.reduce((a: number, b: number) => Math.max(a, b));
|
|
179
|
+
return minPrice == maxPrice ? maxPrice.toString() : minPrice + ' - ' + maxPrice;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Actualiza las variantes.
|
|
183
|
+
* @param code
|
|
184
|
+
*/
|
|
185
|
+
updateVariants = (code?: string) => {
|
|
186
|
+
let variants = this._productSubject.value?.variants
|
|
187
|
+
//console.log(variants)
|
|
188
|
+
if (!code) {
|
|
189
|
+
this._optionsSubject.value.forEach((option: any) => {
|
|
190
|
+
option.values.forEach((value: any) => {
|
|
191
|
+
if (value.selected) {
|
|
192
|
+
variants = variants?.filter(variant => {
|
|
193
|
+
return variant.options.some((variantOption: any) => {
|
|
194
|
+
return (option.code in variantOption && variantOption[option.code] == value.name);
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
})
|
|
200
|
+
} else {
|
|
201
|
+
variants = variants?.filter(variant => variant.code == code);
|
|
202
|
+
}
|
|
203
|
+
this.variants = variants || [];
|
|
204
|
+
code && this.updateOptions();
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Actualiza las opciones
|
|
208
|
+
*/
|
|
209
|
+
private updateOptions = () => {
|
|
210
|
+
let { options } = this.variants.length && this.variants[0];
|
|
211
|
+
options && options.forEach((option: any) => Object.keys(option).forEach(key => this.setOption(key, option[key])))
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Agrega el producto al carrito.
|
|
215
|
+
* @param quantity Cantidad del producto a agregar
|
|
216
|
+
* @param variantCode Codigo de la variante.
|
|
217
|
+
* @returns
|
|
218
|
+
*/
|
|
219
|
+
addToCart(quantity: number, variantCode?: string){
|
|
220
|
+
|
|
221
|
+
if(!this.variants.length){
|
|
222
|
+
this._toastService.show('cant-buy')
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
let productSelected = JSON.parse(JSON.stringify((this._productSubject.getValue())));
|
|
226
|
+
|
|
227
|
+
let variant:any;
|
|
228
|
+
|
|
229
|
+
switch(this.variants.length){
|
|
230
|
+
case 0:
|
|
231
|
+
this._toastService.show('no-variants');
|
|
232
|
+
break;
|
|
233
|
+
case 1:
|
|
234
|
+
this._associatedDataSubject.value.stock == 0
|
|
235
|
+
? this._toastService.show('out-of-stock')
|
|
236
|
+
: variant = this.variants[0]
|
|
237
|
+
break;
|
|
238
|
+
default:
|
|
239
|
+
if(variantCode){
|
|
240
|
+
variant = this.variants.find( variant => variant.code === variantCode)
|
|
241
|
+
if(variant.stock == 0){
|
|
242
|
+
this._toastService.show('out-of-stock')
|
|
243
|
+
variant = undefined
|
|
244
|
+
}
|
|
245
|
+
} else {
|
|
246
|
+
this._toastService.show('variants-left')
|
|
247
|
+
}
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
if(!variant) return;
|
|
251
|
+
if(!this.validateQuantity(quantity)) return;
|
|
252
|
+
|
|
253
|
+
//agregar al servicio del carrito
|
|
254
|
+
this._cartService.addToCart(this.makeAffordableProduct(productSelected), quantity, variant.code);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Genera un producto para hacer mas facíl el envio del elemento al backend.
|
|
258
|
+
* @param productSelected
|
|
259
|
+
* @returns
|
|
260
|
+
*/
|
|
261
|
+
private makeAffordableProduct(productSelected: Product) {
|
|
262
|
+
productSelected.price = parseFloat(this._associatedDataSubject.value.price);
|
|
263
|
+
productSelected.saleprice = parseFloat(this._associatedDataSubject.value.price);
|
|
264
|
+
productSelected.options = [];
|
|
265
|
+
this.variants[0].options.forEach((option:any) => productSelected.options = { ...productSelected.options, ...option })
|
|
266
|
+
return productSelected;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Valida la cantidad que se quiere agregar de un producto.
|
|
270
|
+
* Revisa que no supere el stock, el maximo de items que se puede agregar
|
|
271
|
+
* asi como el minimo.
|
|
272
|
+
* @param quantity
|
|
273
|
+
* @returns
|
|
274
|
+
*/
|
|
275
|
+
private validateQuantity = (quantity: number) => {
|
|
276
|
+
const actualQuantity = this._cartService.getCountFromItemInCart(this.variants[0].code);
|
|
277
|
+
const asociatedData = this._associatedDataSubject.value;
|
|
278
|
+
if ((actualQuantity + quantity) > asociatedData.maximumItemsQuantity) {
|
|
279
|
+
this._toastService.show('maximum-items-quantity', { quantity: asociatedData.maximumItemsQuantity })
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
if ((actualQuantity + quantity) < asociatedData.minimumItemsQuantity) {
|
|
283
|
+
this._toastService.show('minimum-items-quantity', { quantity: asociatedData.minimumItemsQuantity })
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
return true
|
|
287
|
+
}
|
|
288
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { EnvironmentInjector, inject, Injectable, runInInjectionContext, signal } from '@angular/core';
|
|
2
|
+
import { BehaviorSubject, map, Observable, ReplaySubject, shareReplay, switchMap } from 'rxjs';
|
|
3
|
+
import { DefaultFilter, FilterElement, FilterType, IFilter, Options, PaginationSettings, ParamsProductsWithUniqueVariant, Product } from '../interfaces';
|
|
4
|
+
import { ConnectionService } from '../api';
|
|
5
|
+
import { ApiConstantsService, CoreConstantsService } from '../constants';
|
|
6
|
+
import { OptionsService } from './options.service';
|
|
7
|
+
import { PaginationService } from './pagination.service';
|
|
8
|
+
import { Filter, FilterFactory } from '../classes';
|
|
9
|
+
import { FiltersService } from './filters.service';
|
|
10
|
+
|
|
11
|
+
@Injectable({
|
|
12
|
+
providedIn: 'root'
|
|
13
|
+
})
|
|
14
|
+
export class ProductsService {
|
|
15
|
+
private _connection: ConnectionService = inject(ConnectionService);
|
|
16
|
+
private _apiConsts: ApiConstantsService = inject(ApiConstantsService);
|
|
17
|
+
private _optionsService: OptionsService = inject(OptionsService);
|
|
18
|
+
private _paginationService: PaginationService = inject(PaginationService);
|
|
19
|
+
private _consts: CoreConstantsService = inject(CoreConstantsService);
|
|
20
|
+
|
|
21
|
+
private _productsSubject: BehaviorSubject<Product[]> = new BehaviorSubject<Product[]>([])
|
|
22
|
+
public products$: Observable<Product[]> = this._productsSubject.asObservable();
|
|
23
|
+
private _filtersService: FiltersService = inject(FiltersService)
|
|
24
|
+
|
|
25
|
+
private searchValue = signal<string>('');
|
|
26
|
+
|
|
27
|
+
constructor() {
|
|
28
|
+
this._paginationService.reset$.subscribe(res => {
|
|
29
|
+
this._productsSubject.next([])
|
|
30
|
+
})
|
|
31
|
+
this._paginationService.paginationData$.subscribe(
|
|
32
|
+
products => {
|
|
33
|
+
const productsWithUniqueVariant = this._consts.getProductWithUniqueVariant();
|
|
34
|
+
if (productsWithUniqueVariant)
|
|
35
|
+
products = this.getProductsWithUniqueVariant(products, this.getObjectWithVariant())
|
|
36
|
+
const currentProducts = this._productsSubject.value;
|
|
37
|
+
this._productsSubject.next([...currentProducts, ...products]);
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//API URL
|
|
43
|
+
private _shopApiUrl = this._apiConsts.SHOP_API_URL;
|
|
44
|
+
productByCodeApi(code: string, variant: boolean) { return this._shopApiUrl + this._apiConsts.CHANNEL + '/products/by-code/' + (variant ? 'variant/' : '') + code + '?locale=' + this._apiConsts.LOCALE; }
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Setea los filtros para obtener los productos.
|
|
48
|
+
* @param paginationSettings
|
|
49
|
+
* @param searchValue
|
|
50
|
+
*/
|
|
51
|
+
getProductsForFilter(paginationSettings?: PaginationSettings, searchValue?: any): any {
|
|
52
|
+
searchValue ? this.searchValue.set(searchValue) : this.searchValue.set('');
|
|
53
|
+
paginationSettings && this._filtersService.setFilters(paginationSettings)
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Actualiza los productos con los de la siguiente pagina.
|
|
57
|
+
*/
|
|
58
|
+
updateProducts() {
|
|
59
|
+
if (!this._paginationService.getWaiting()) {
|
|
60
|
+
this._paginationService.getNext()
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Devuelve el producto por codigo.
|
|
65
|
+
* @param code Codigo del producto
|
|
66
|
+
* @param variant Para indicar si es variante o no.
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
getProductByCode(code: string, variant: boolean): Observable<Product> {
|
|
70
|
+
return this._connection.get(this.productByCodeApi(code, variant));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Recibe una lista de productos y retorna los mismos productos tantas veces como variantes tenga.
|
|
75
|
+
* cada producto retornado tendrá una única variante.
|
|
76
|
+
* @param products Array. Lista de productos.
|
|
77
|
+
* @param withOption 'type' tipo de opción, code: código de la opción. 'defaultFirstOption': en caso de que no se pueda desdoblar por la opción indicada si el valor es verdadero se intentara desdoblar por la primera opción asociada al producto.
|
|
78
|
+
* 'checkIfStock': en caso de que esta valor sea verdadero se realiza un control de que la variantes cuenten con stock para ser un producto desdoblado por la variante, si el valor es falso no se realiza dicho control y el producto se desdoblara con stock en 0.
|
|
79
|
+
* @returns arreglo con los productos desdoblados por la opción solicitada.
|
|
80
|
+
* (opción por defecto que se intenta hacer el desdoblamiento 'color', o bien si en le parámetro withOption el atributo 'defaultFirstOption' es verdadero se desdobla por la primera opción asociada al producto)
|
|
81
|
+
*/
|
|
82
|
+
getProductsWithUniqueVariant = (products: Product[], withOption: ParamsProductsWithUniqueVariant = { type: 'color', code: 'color', defaultFirstOption: false, checkIfStock: true }) => {
|
|
83
|
+
|
|
84
|
+
!withOption['code'] && withOption['type'] && (withOption['code'] = withOption['type']) || !withOption['code'] && (withOption['code'] = 'color')
|
|
85
|
+
!withOption['type'] && withOption['code'] && (withOption['type'] = withOption['code']) || !withOption['type'] && (withOption['type'] = 'color')
|
|
86
|
+
!withOption.hasOwnProperty('defaultFirstOption') && (withOption['defaultFirstOption'] = false)
|
|
87
|
+
!withOption.hasOwnProperty('checkIfStock') && (withOption['checkIfStock'] = true)
|
|
88
|
+
|
|
89
|
+
let productsUniqueVariant: any[] = [];
|
|
90
|
+
products.forEach((product: any) => {
|
|
91
|
+
let variants = [...product?.variants];
|
|
92
|
+
let option = product.options.find((opt: any) => opt.type.toLowerCase() === withOption.type?.toLowerCase());
|
|
93
|
+
if (option) {
|
|
94
|
+
option.values.forEach((optionValue: any) => {
|
|
95
|
+
let modified_product = JSON.parse(JSON.stringify(product));
|
|
96
|
+
modified_product.options.find((option: any) => option.type.toLowerCase() == withOption.type?.toLowerCase()).values = [{ code: optionValue.code, name: optionValue.name }];
|
|
97
|
+
//busco una variante con ese code para asignarle la lista de imagenes
|
|
98
|
+
let variantAux = variants.find(
|
|
99
|
+
variant => ((withOption.checkIfStock && variant.stock > 0) || withOption.checkIfStock == false)
|
|
100
|
+
&& variant.options.length
|
|
101
|
+
&& variant.options.some((op: any) => (op.hasOwnProperty(withOption.code?.toLowerCase()) || op.hasOwnProperty(withOption.code?.toUpperCase()))
|
|
102
|
+
&& (op[`${withOption.code?.toLowerCase()}`] || op[`${withOption.code?.toUpperCase()}`]) === optionValue.code)
|
|
103
|
+
|
|
104
|
+
);
|
|
105
|
+
//console.log("---",variantAux);
|
|
106
|
+
variantAux && productsUniqueVariant.push(this.productWithVariantValues(modified_product, variantAux, optionValue));
|
|
107
|
+
})
|
|
108
|
+
} else {
|
|
109
|
+
/**
|
|
110
|
+
* se modifica el caso para cuando se toma el primer `option` del producto para
|
|
111
|
+
* armar la lista de productos con variantes.
|
|
112
|
+
*/
|
|
113
|
+
if (withOption.defaultFirstOption && product.options?.length) {
|
|
114
|
+
let firstOptions = product.options[0]
|
|
115
|
+
product.options[0].values.forEach((optionValue: any) => {
|
|
116
|
+
|
|
117
|
+
let modified_product = JSON.parse(JSON.stringify(product));
|
|
118
|
+
modified_product.options.find((option: Options) => option.type == firstOptions.type).values = [{ code: optionValue.code, name: optionValue.name }];
|
|
119
|
+
|
|
120
|
+
let variantAux = variants.find(variant => {
|
|
121
|
+
return variant.options.find((elem: any) => elem[firstOptions.code] == optionValue.code)
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
if (variantAux && variantAux.images.length == 0) {
|
|
125
|
+
variantAux.images = product.picturesdefault
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (withOption.checkIfStock) {
|
|
129
|
+
(variantAux && variantAux.stock > 0) ? productsUniqueVariant.push(this.productWithVariantValues(modified_product, variantAux, optionValue)) : null;
|
|
130
|
+
} else {
|
|
131
|
+
variantAux && productsUniqueVariant.push(this.productWithVariantValues(modified_product, variantAux, optionValue))
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
})
|
|
135
|
+
} else {
|
|
136
|
+
productsUniqueVariant.push(product)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
return productsUniqueVariant.length > 0 ? productsUniqueVariant : products;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
productWithVariantValues = (product: Product, variant: any, optionValue: any) => {
|
|
145
|
+
product.picturesdefault = [...variant.images]
|
|
146
|
+
product.variant_id = variant.code; //lo dejo aca hasta asegurarnos de que no se estaba usando en otra parte.
|
|
147
|
+
product.stock = variant.stock || 0; //lo dejo aca hasta asegurarnos de que no se estaba usando en otra parte.
|
|
148
|
+
product.price = variant.price.toString() || '0';
|
|
149
|
+
product.currentOption = {
|
|
150
|
+
...optionValue,
|
|
151
|
+
productCode: product.id,
|
|
152
|
+
variantCode: variant.code,
|
|
153
|
+
stock: variant.stock || 0,
|
|
154
|
+
finalPrice: variant.saleprice || variant.price || 0,
|
|
155
|
+
}
|
|
156
|
+
return product
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
private getObjectWithVariant = (): ParamsProductsWithUniqueVariant => {
|
|
160
|
+
return this._consts.getParamsProductsWithUniqueVariant()
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { afterNextRender, inject, Injectable } from '@angular/core';
|
|
2
|
+
import { RecaptchaSettings } from 'ng-recaptcha-2';
|
|
3
|
+
import { BehaviorSubject, concatMap, firstValueFrom, map, Observable } from 'rxjs';
|
|
4
|
+
import { ConnectionService } from '../api';
|
|
5
|
+
import { ParametersService } from './parameters.service';
|
|
6
|
+
import { ApiConstantsService } from '../constants';
|
|
7
|
+
|
|
8
|
+
@Injectable({
|
|
9
|
+
providedIn: 'root'
|
|
10
|
+
})
|
|
11
|
+
export class ReCaptchaService {
|
|
12
|
+
|
|
13
|
+
private _connection: ConnectionService = inject(ConnectionService);
|
|
14
|
+
private _paramsService: ParametersService = inject(ParametersService);
|
|
15
|
+
private _apiConsts: ApiConstantsService = inject(ApiConstantsService);
|
|
16
|
+
|
|
17
|
+
private _recaptchaSubject: BehaviorSubject<RecaptchaSettings> = new BehaviorSubject<RecaptchaSettings>({ siteKey: '' });
|
|
18
|
+
public recaptcha$ = this._recaptchaSubject.asObservable();
|
|
19
|
+
|
|
20
|
+
private params$ = this._paramsService.getParameters();
|
|
21
|
+
public params: any;
|
|
22
|
+
|
|
23
|
+
private urlBaseFormat: string = '';
|
|
24
|
+
private testing: string = "easycommercetech"
|
|
25
|
+
private productionEnvironment: Boolean = false;
|
|
26
|
+
|
|
27
|
+
private recaptchaSiteKeysUrl = './assets/recaptcha/recaptcha-site-keys.json';
|
|
28
|
+
private recaptchaSitesUrl = './assets/recaptcha/recaptcha-sites.json';
|
|
29
|
+
private recaptchaSitesUrlProd = './assets/recaptcha/recaptcha-sites-prod.json'
|
|
30
|
+
|
|
31
|
+
private RECAPTCHA_SITE_KEYS: any = []
|
|
32
|
+
private RECAPTCHA_SITES: any = []
|
|
33
|
+
|
|
34
|
+
constructor() {
|
|
35
|
+
this.params$.subscribe(params => this.params = params);
|
|
36
|
+
this.initializer();
|
|
37
|
+
afterNextRender(()=> {
|
|
38
|
+
this.urlBaseFormat = this.formatUrl(location.href);
|
|
39
|
+
this.productionEnvironment = this.isProd();
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Devuelve true si la url es de produccion, false en caso contrario.
|
|
44
|
+
* @returns {Boolean}
|
|
45
|
+
*/
|
|
46
|
+
private isProd(): Boolean {
|
|
47
|
+
return !this.urlBaseFormat.includes(this.testing)
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Recibe una url y se encarga de quitarle "http", "/" y las demas rutas, para devolver la url
|
|
51
|
+
* del sitio con una formato limpio. Ejemplo "https://ejemplo.com.ar/ruta1/ruta2/" a "ejemplo.com.ar"
|
|
52
|
+
* @param {string} url url que sera formateada
|
|
53
|
+
* @returns {string} url formateada
|
|
54
|
+
*/
|
|
55
|
+
private formatUrl(url: string): string {
|
|
56
|
+
return url.split("/").filter(e => e != "/").filter(e => !e.includes("http")).filter(e => e.length).slice(0,1).pop() || ''
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Path que contiene la direccion del endpoint referido al captcha
|
|
61
|
+
* @returns {string}
|
|
62
|
+
*/
|
|
63
|
+
private captchaApi():string { return `${this._apiConsts.SHOP_API_URL}channels`;}
|
|
64
|
+
/**
|
|
65
|
+
* Prioriza si existe un parametro desde el backend de nombre 'recaptcha_key_canal',
|
|
66
|
+
* de no existir este busca uno de tipo general de nombre 'recaptcha_key',
|
|
67
|
+
* y en caso de que este no exista se realiza lo siguiente:
|
|
68
|
+
* carga las variables RECAPTCHA_SITES y RECAPTCHA_SITE_KEYS, con los valores
|
|
69
|
+
* de los Json estaticos, para posteriormente obtener la "siteKey"(clave del captcha) en caso
|
|
70
|
+
* de que no venga desde el backend.
|
|
71
|
+
*/
|
|
72
|
+
private initializer(): void {
|
|
73
|
+
let paramThisChannel = this.params.find((param:any) => param.code === `recaptcha_key_${this._apiConsts.CHANNEL}`)
|
|
74
|
+
if(paramThisChannel){
|
|
75
|
+
this._recaptchaSubject.next({siteKey: paramThisChannel.value});
|
|
76
|
+
}else{
|
|
77
|
+
let paramGeneral = this.params.find((param:any) => param.code === 'recaptcha_key')
|
|
78
|
+
if(paramGeneral){
|
|
79
|
+
this._recaptchaSubject.next({siteKey: paramGeneral.value});
|
|
80
|
+
} else {
|
|
81
|
+
this.getRecaptchaSites().pipe(
|
|
82
|
+
map((res:any) => this.RECAPTCHA_SITES = res),
|
|
83
|
+
concatMap( res => this.getRecaptchaSiteKeys().pipe(
|
|
84
|
+
map(res=> this.RECAPTCHA_SITE_KEYS = res)
|
|
85
|
+
))
|
|
86
|
+
).subscribe(
|
|
87
|
+
e => this.getSiteKey()
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Obtiene los datos del archivo .json en donde se guardan las claves.
|
|
95
|
+
* @returns {Observable<any>} Datos obtenidos del archivo con las claves captcha
|
|
96
|
+
*/
|
|
97
|
+
private getRecaptchaSiteKeys(): Observable<any>{
|
|
98
|
+
return this._connection.getWithFullUrl(this.recaptchaSiteKeysUrl)
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Se obtiene los datos segun el entorno en que se ejecute
|
|
102
|
+
* @returns {Observable<any>} Datos obtenidos del archivo con las url de los sitios
|
|
103
|
+
*/
|
|
104
|
+
private getRecaptchaSites(): Observable<any>{
|
|
105
|
+
return this.productionEnvironment ?
|
|
106
|
+
this._connection.getWithFullUrl(this.recaptchaSitesUrlProd) :
|
|
107
|
+
this._connection.getWithFullUrl(this.recaptchaSitesUrl);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Genera una peticion para recibir la clave del recaptcha. En caso de no tener exito,
|
|
111
|
+
* utiliza los archivos estaticos para retornar una clave por defecto. Rellena el Observable con
|
|
112
|
+
* los datos generados.
|
|
113
|
+
*/
|
|
114
|
+
private getSiteKey(){
|
|
115
|
+
firstValueFrom(this._connection.get(this.captchaApi())).then(
|
|
116
|
+
(res: any) => {
|
|
117
|
+
this._recaptchaSubject.next( {
|
|
118
|
+
siteKey: res.siteKey ? res.siteKey : this.RECAPTCHA_SITE_KEYS[this.RECAPTCHA_SITES[this.urlBaseFormat]]
|
|
119
|
+
})
|
|
120
|
+
},
|
|
121
|
+
(err: any) => {
|
|
122
|
+
this._recaptchaSubject.next({ siteKey: this.RECAPTCHA_SITE_KEYS[this.RECAPTCHA_SITES[this.urlBaseFormat]]})
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
}
|