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,46 @@
|
|
|
1
|
+
import { DOCUMENT } from '@angular/common';
|
|
2
|
+
import { inject, Injectable, Renderer2, RendererFactory2 } from '@angular/core';
|
|
3
|
+
/**
|
|
4
|
+
* Servicio encargado de manejar el analytics de Metricool Pixel
|
|
5
|
+
*/
|
|
6
|
+
@Injectable({
|
|
7
|
+
providedIn: 'root'
|
|
8
|
+
})
|
|
9
|
+
export class MetricoolPixelService {
|
|
10
|
+
/**
|
|
11
|
+
* Indica si se esta cargando el Servicio.
|
|
12
|
+
*/
|
|
13
|
+
private isLoaded = false;
|
|
14
|
+
|
|
15
|
+
private rendererFactory: RendererFactory2 = inject(RendererFactory2)
|
|
16
|
+
private document: any = inject(DOCUMENT)
|
|
17
|
+
/**
|
|
18
|
+
* Se encarga de crear el elemento HTML con las configuraciones para
|
|
19
|
+
* que se pueda ejecutar el servicio.
|
|
20
|
+
*/
|
|
21
|
+
private renderer: Renderer2;
|
|
22
|
+
|
|
23
|
+
constructor() {
|
|
24
|
+
this.renderer = this.rendererFactory.createRenderer(null, null);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Inicializa el Servicio de analytics con sus configuraciones.
|
|
28
|
+
* @param pixel_hash hash provisto por Metricool Pixel.
|
|
29
|
+
*/
|
|
30
|
+
initialize = (pixel_hash:any) => {
|
|
31
|
+
let new_analityc_script = this.renderer.createElement('script');
|
|
32
|
+
new_analityc_script.type = 'text/javascript';
|
|
33
|
+
new_analityc_script.text = `
|
|
34
|
+
function loadScript(a) {
|
|
35
|
+
var b = document.getElementsByTagName("head")[0], c = document.createElement("script");
|
|
36
|
+
c.type = "text/javascript",
|
|
37
|
+
c.src = "https://tracker.metricool.com/resources/be.js",
|
|
38
|
+
c.onreadystatechange = a,
|
|
39
|
+
c.onload = a, b.appendChild(c)
|
|
40
|
+
} loadScript(function () {
|
|
41
|
+
beTracker.t({ hash: "${pixel_hash}" })
|
|
42
|
+
});
|
|
43
|
+
`;
|
|
44
|
+
this.renderer.appendChild(this.document.body, new_analityc_script);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import { inject, Injectable, signal } from '@angular/core';
|
|
2
|
+
import { UserRoleType } from '../interfaces';
|
|
3
|
+
import { BehaviorSubject, catchError, map, Observable, of } from 'rxjs';
|
|
4
|
+
import { ConnectionService } from '../api';
|
|
5
|
+
import { User } from '../classes';
|
|
6
|
+
import moment from 'moment';
|
|
7
|
+
import { ChannelService } from './channel.service';
|
|
8
|
+
import { ApiConstantsService, CoreConstantsService } from '../constants';
|
|
9
|
+
import { LocalStorageService } from './local-storage.service';
|
|
10
|
+
import { AuthStorageService } from './auth.storage.service';
|
|
11
|
+
import { CartService } from './cart.service';
|
|
12
|
+
/**
|
|
13
|
+
* Servicio de autentificación del usuario en la plataforma.
|
|
14
|
+
*/
|
|
15
|
+
@Injectable({
|
|
16
|
+
providedIn: 'root'
|
|
17
|
+
})
|
|
18
|
+
export class AuthService {
|
|
19
|
+
private _localStorage: LocalStorageService = inject(LocalStorageService)
|
|
20
|
+
private _connection: ConnectionService = inject(ConnectionService);
|
|
21
|
+
private _channelService: ChannelService = inject(ChannelService);
|
|
22
|
+
private _constants: CoreConstantsService = inject(CoreConstantsService);
|
|
23
|
+
private _apiConsts: ApiConstantsService = inject(ApiConstantsService);
|
|
24
|
+
private _authStorage: AuthStorageService = inject(AuthStorageService);
|
|
25
|
+
|
|
26
|
+
// Contantes para el storage.
|
|
27
|
+
private readonly JWT_TOKEN = 'JWT_TOKEN'
|
|
28
|
+
private readonly REFRESH_TOKEN = 'REFRESH_TOKEN'
|
|
29
|
+
private readonly EXPIRATES_IN = 'EXPIRATES_IN'
|
|
30
|
+
private readonly USER = 'USER'
|
|
31
|
+
private readonly MAIL = 'mail'
|
|
32
|
+
private readonly LOCALE = 'LOCALE'
|
|
33
|
+
private readonly CHANNEL = 'CHANNEL'
|
|
34
|
+
private readonly CUSTOMER = 'CUSTOMER'
|
|
35
|
+
private readonly CHANNELSELLER = 'CHANNELSELLER'
|
|
36
|
+
|
|
37
|
+
private channelsUserSubject = new BehaviorSubject<any[]>([])
|
|
38
|
+
public channels$ = this.channelsUserSubject.asObservable()
|
|
39
|
+
private _channel$ = this._channelService.getChannel()
|
|
40
|
+
private _userInSubject = new BehaviorSubject<User | null>(null)
|
|
41
|
+
private _loggedInSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
|
42
|
+
public loggedIn$: Observable<boolean> = this._loggedInSubject.asObservable();
|
|
43
|
+
private _loggingInSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
|
44
|
+
public loggingIn$: Observable<boolean> = this._loggingInSubject.asObservable();
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Para indicar si un canal cambio.
|
|
48
|
+
*/
|
|
49
|
+
private _activeChannelChange: boolean = false;
|
|
50
|
+
/**
|
|
51
|
+
* Guarda los datos del usuario
|
|
52
|
+
*/
|
|
53
|
+
private _user: User | null = null;
|
|
54
|
+
private _customer = null;
|
|
55
|
+
/**
|
|
56
|
+
* Guarda los datos del canal
|
|
57
|
+
*/
|
|
58
|
+
public channel: any = []
|
|
59
|
+
public channels: any[] = []
|
|
60
|
+
/**
|
|
61
|
+
* Utilizado para resolver hacia donde se tiene que redireccionar
|
|
62
|
+
* la pagina tras un evento.
|
|
63
|
+
*/
|
|
64
|
+
private _homeResolver: any;
|
|
65
|
+
/**
|
|
66
|
+
* Signal para guardar el token de usuario una vez logueado
|
|
67
|
+
*/
|
|
68
|
+
private _tokenSignal = signal<string | null>(null);
|
|
69
|
+
/**
|
|
70
|
+
* Signal para guardar el usuario
|
|
71
|
+
*/
|
|
72
|
+
private _userSignal = signal<User | null>(null);
|
|
73
|
+
//APIs
|
|
74
|
+
private shopApi: string = this._apiConsts.SHOP_API_URL
|
|
75
|
+
private channelApi: string = this._apiConsts.CHANNEL
|
|
76
|
+
private tokenApi() { return this.shopApi + 'login_check' }
|
|
77
|
+
private recoverPasswordApi() { return `${this.shopApi}${this.channelApi}/request-password-reset` }
|
|
78
|
+
private confirmAccountApi(token: string) { return `${this.shopApi}${this.channelApi}/verify-account?token=${token}` }
|
|
79
|
+
private registerApi() { return `${this.shopApi}${this.channelApi}/register` }
|
|
80
|
+
private registerWholesalerApi() { return `${this.shopApi}${this.channelApi}/register-wholesaler`}
|
|
81
|
+
|
|
82
|
+
constructor() {
|
|
83
|
+
this.loadTokenFromStorage();
|
|
84
|
+
this.isAuthenticated() && this._loggedInSubject.next(true);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Loguea al usuario en la aplicación.
|
|
88
|
+
* @param user datos del usuario
|
|
89
|
+
* @param withRoles roles del usuario
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
login(user: { username: string, password: string }, withRoles: UserRoleType[] = []): Observable<any> {
|
|
93
|
+
this._channel$.subscribe(ch => this.channel = ch);
|
|
94
|
+
this.channels$.subscribe(ch => this.channels = ch);
|
|
95
|
+
this._loggingInSubject.next(true);
|
|
96
|
+
user = {...user, ...this.loginExtraData() }
|
|
97
|
+
return this._connection.post(this.tokenApi(), user).pipe(
|
|
98
|
+
map((res: any) => {
|
|
99
|
+
if (this.channelAccessPermission({ ...user, ...res }) && this.isAllowedRole(withRoles, res.type)) {
|
|
100
|
+
this.doLoginUser({ ...user, ...res });
|
|
101
|
+
return 'ok';
|
|
102
|
+
}
|
|
103
|
+
return 'error';
|
|
104
|
+
}),
|
|
105
|
+
catchError((error: any) => {
|
|
106
|
+
this._loggingInSubject.next(false);
|
|
107
|
+
return of(error.toString());
|
|
108
|
+
})
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Controla que el usuario logueado tenga permisos
|
|
113
|
+
* para el canal actual de la aplicación.
|
|
114
|
+
* @param res
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
private channelAccessPermission(res: any) {
|
|
118
|
+
//console.log('channelAccess', res);
|
|
119
|
+
this.channelsUserSubject.next([]);
|
|
120
|
+
|
|
121
|
+
/* No authorized channels */
|
|
122
|
+
if (res.channels?.length == 0) {
|
|
123
|
+
return false
|
|
124
|
+
}
|
|
125
|
+
/* Some authorized channel(s) including current channel */
|
|
126
|
+
if (res.channels.find((userchannel: any) => userchannel.code === this.channel.code)) {
|
|
127
|
+
/* Multiple authorized channels including current channel */
|
|
128
|
+
if (res.channels?.length > 1 && this._activeChannelChange)
|
|
129
|
+
this.channelsUserSubject.next(res.channels)
|
|
130
|
+
return true
|
|
131
|
+
}
|
|
132
|
+
/* One authorized channel not including current channel */
|
|
133
|
+
if (res.channels?.length == 1 && this._activeChannelChange) {
|
|
134
|
+
delete res.password
|
|
135
|
+
this.channelAccess(res.channels[0], res)
|
|
136
|
+
return true
|
|
137
|
+
}
|
|
138
|
+
/* Multiple authorized channels not including current channel */
|
|
139
|
+
if (this._activeChannelChange) {
|
|
140
|
+
this.channelsUserSubject.next(res.channels)
|
|
141
|
+
return true
|
|
142
|
+
}
|
|
143
|
+
return false
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Controla el acceso al canal, de ser otro nuevo cambia los valores.
|
|
147
|
+
* @param channel
|
|
148
|
+
* @param user
|
|
149
|
+
*/
|
|
150
|
+
channelAccess(channel: any, user = null) {
|
|
151
|
+
if (window.location.hostname != channel.hostname) {
|
|
152
|
+
let encoded = btoa(JSON.stringify(user != null ? user : this._user))
|
|
153
|
+
window.location.replace(`${window.location.protocol}//${channel.hostname}/auth/redirect/${encoded}`)
|
|
154
|
+
} else {
|
|
155
|
+
this._constants.modifyChannelConfig(channel)
|
|
156
|
+
window.location.reload()
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Controla que el rol del usuario sea un rol permitido por la aplicación.
|
|
161
|
+
* @param allowedRoles roles que permite la aplicación.
|
|
162
|
+
* @param role rol del usuarios
|
|
163
|
+
* @returns
|
|
164
|
+
*/
|
|
165
|
+
private isAllowedRole(allowedRoles: UserRoleType[], role: string) {
|
|
166
|
+
return allowedRoles.length
|
|
167
|
+
? allowedRoles.includes(role as UserRoleType)
|
|
168
|
+
: true
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Tras un logueo exitoso, guarda los datos necesarios en el storage y demás
|
|
172
|
+
* configuraciones necesarias.
|
|
173
|
+
* @param tokens
|
|
174
|
+
*/
|
|
175
|
+
private doLoginUser(tokens: any) {
|
|
176
|
+
this._user = new User()
|
|
177
|
+
this._user.initilized(tokens)
|
|
178
|
+
|
|
179
|
+
this.forceChannelsForSeller(tokens)
|
|
180
|
+
//Channel
|
|
181
|
+
const userJsonify = this._user.jsonify()
|
|
182
|
+
this._localStorage.setItem(this.USER, JSON.stringify(userJsonify))
|
|
183
|
+
this._localStorage.setItem(this.EXPIRATES_IN, moment(tokens.expire_in).add(1, 'h').format());
|
|
184
|
+
this._localStorage.setItem(this.REFRESH_TOKEN, moment(tokens.expire_in).add(1, 'h').format());
|
|
185
|
+
this._localStorage.setItem(this.JWT_TOKEN, tokens.token);
|
|
186
|
+
this._authStorage.setAuthToken(tokens.token)
|
|
187
|
+
this._tokenSignal.set(tokens.token);
|
|
188
|
+
this._localStorage.setItem(this.MAIL, tokens.username);
|
|
189
|
+
//Observables
|
|
190
|
+
this._userInSubject.next(this._user);
|
|
191
|
+
this._loggedInSubject.next(true);
|
|
192
|
+
this._loggingInSubject.next(false);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Cambia la funcion que se encarga de resolver hacia donde se redirige el frontend
|
|
196
|
+
* tras una acción
|
|
197
|
+
* @param resolverFunction
|
|
198
|
+
*/
|
|
199
|
+
public setHomeResolver(resolverFunction: any) { this._homeResolver = resolverFunction }
|
|
200
|
+
/**
|
|
201
|
+
* Obtiene la funcion que se encarga de resolver hacia donde se redirige el frontend.
|
|
202
|
+
* @returns
|
|
203
|
+
*/
|
|
204
|
+
public getHomeResolver() { return this._homeResolver }
|
|
205
|
+
/**
|
|
206
|
+
* Obtiene el token del storage y lo guarda en la signal.
|
|
207
|
+
*/
|
|
208
|
+
public loadTokenFromStorage() {
|
|
209
|
+
const token = this._localStorage.getItem(this.JWT_TOKEN);
|
|
210
|
+
if (token) {
|
|
211
|
+
this._tokenSignal.set(token);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Desloguea al usuario.
|
|
216
|
+
*/
|
|
217
|
+
public logout() {
|
|
218
|
+
this.doLogoutUser();
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Retorna si hay un usuario logueado o no.
|
|
222
|
+
* @returns
|
|
223
|
+
*/
|
|
224
|
+
public isAuthenticated(): boolean {
|
|
225
|
+
//console.log("isAuthenticated",this.isTokenExpired(), this._tokenSignal() );
|
|
226
|
+
if (this.isTokenExpired()) {
|
|
227
|
+
this.doLogoutUser()
|
|
228
|
+
}
|
|
229
|
+
this.getCurrentUserAsUser()
|
|
230
|
+
this._userInSubject.next(this._user);
|
|
231
|
+
//console.log(this.getToken(), !this.isTokenExpired() , this._user != null);
|
|
232
|
+
return this.getToken() && !this.isTokenExpired() && this._user != null;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Retorna el token de usuario
|
|
236
|
+
* @returns
|
|
237
|
+
*/
|
|
238
|
+
public getToken(): any {
|
|
239
|
+
return this._tokenSignal();
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Limpia el storage y las configuraciones internas
|
|
243
|
+
*/
|
|
244
|
+
public doLogoutUser() {
|
|
245
|
+
this._user = null
|
|
246
|
+
this._localStorage.removeItem(this.USER);
|
|
247
|
+
this._localStorage.removeItem(this.EXPIRATES_IN);
|
|
248
|
+
this._localStorage.removeItem(this.JWT_TOKEN);
|
|
249
|
+
this._authStorage.setAuthToken(null);
|
|
250
|
+
this._localStorage.removeItem(this.REFRESH_TOKEN);
|
|
251
|
+
this._localStorage.removeItem('cart_token');
|
|
252
|
+
this._localStorage.removeItem(this.MAIL);
|
|
253
|
+
this._localStorage.removeItem(this.CHANNEL);
|
|
254
|
+
this._localStorage.removeItem(this.CHANNELSELLER);
|
|
255
|
+
this._localStorage.removeItem(this.LOCALE);
|
|
256
|
+
this._localStorage.removeItem(this.CUSTOMER);
|
|
257
|
+
this._localStorage.removeItem('MASTER_CHANNEL');
|
|
258
|
+
this._loggedInSubject.next(false);
|
|
259
|
+
this._userInSubject.next(this._user);
|
|
260
|
+
this.channelsUserSubject.next([])
|
|
261
|
+
this._tokenSignal.set(null)
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Devuelve `true`si el token expiro, `false` caso contrario.
|
|
265
|
+
* @returns
|
|
266
|
+
*/
|
|
267
|
+
private isTokenExpired() {
|
|
268
|
+
const fecha_expiracion = this.getExpiratesAt();
|
|
269
|
+
const result = moment() >= moment(fecha_expiracion);
|
|
270
|
+
return result;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Obtiene la fecha de expiración del token.
|
|
274
|
+
* @returns
|
|
275
|
+
*/
|
|
276
|
+
private getExpiratesAt() {
|
|
277
|
+
return this._localStorage.getItem(this.EXPIRATES_IN);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Obtiene al usuario actual y lo convierte en una instancia de `User`
|
|
281
|
+
* @returns
|
|
282
|
+
*/
|
|
283
|
+
private getCurrentUserAsUser(): User | null {
|
|
284
|
+
this._user = new User();
|
|
285
|
+
if (!this.loadUserFromStorage()) {
|
|
286
|
+
this._user = null
|
|
287
|
+
}
|
|
288
|
+
else if (this._user?.channels.find((userchannel: any) => userchannel?.code === this._apiConsts.CHANNEL)) {
|
|
289
|
+
return this._user;
|
|
290
|
+
} else {
|
|
291
|
+
this.logout()
|
|
292
|
+
}
|
|
293
|
+
return this._user;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Obtiene el usuario del storage.
|
|
297
|
+
* @param key
|
|
298
|
+
* @returns
|
|
299
|
+
*/
|
|
300
|
+
private loadUserFromStorage(key = this.USER) {
|
|
301
|
+
if (this._localStorage.getItem(key)) {
|
|
302
|
+
this._user = JSON.parse(this._localStorage.getItem(key));
|
|
303
|
+
return true
|
|
304
|
+
}
|
|
305
|
+
return false
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Envia la solicitud para cambiar la contraseña.
|
|
309
|
+
* @param email email del solicitante.
|
|
310
|
+
* @returns
|
|
311
|
+
*/
|
|
312
|
+
recoverPassword(email: string) {
|
|
313
|
+
return this._connection.put(this.recoverPasswordApi(), { email });
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Para confirmar el registro de usuario.
|
|
317
|
+
* @param token
|
|
318
|
+
* @returns
|
|
319
|
+
*/
|
|
320
|
+
confirmAccount(token: string) {
|
|
321
|
+
return this._connection.get(this.confirmAccountApi(token));
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Para registrar a un usuario común
|
|
325
|
+
* @param data
|
|
326
|
+
* @returns
|
|
327
|
+
*/
|
|
328
|
+
singUp(data: any) {
|
|
329
|
+
return this._connection.post(this.registerApi(), data);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Para registrar a un usuario mayorista.
|
|
333
|
+
* @param data
|
|
334
|
+
* @returns
|
|
335
|
+
*/
|
|
336
|
+
signUpWholesaler(data: any) {
|
|
337
|
+
return this._connection.post(this.registerWholesalerApi(),data);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Chequea si un usuario esta habilitado a comprar o no.
|
|
341
|
+
* @returns
|
|
342
|
+
*/
|
|
343
|
+
isAbleToBuy():boolean {
|
|
344
|
+
const currentUser = this.getUserProfileAsUser() as User;
|
|
345
|
+
const isSeller = currentUser.typeUser && currentUser.typeUser == 'seller' || false
|
|
346
|
+
return !isSeller || !this.getCustomer();
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Retorna un usuario de tipo cliente.
|
|
350
|
+
* @returns
|
|
351
|
+
*/
|
|
352
|
+
getCustomer() {
|
|
353
|
+
return this._customer || JSON.parse(this._localStorage.getItem(this.CUSTOMER))
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Devuelve el usuario actual logueado.
|
|
357
|
+
* @returns
|
|
358
|
+
*/
|
|
359
|
+
getUserProfileAsUser(): User {
|
|
360
|
+
return this._user! as User || this.getCurrentUserAsUser();
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Agrega data extra al objecto de Usuario.
|
|
364
|
+
* @returns
|
|
365
|
+
*/
|
|
366
|
+
loginExtraData = () => {
|
|
367
|
+
return {
|
|
368
|
+
client_id: 'demo_client',
|
|
369
|
+
client_secret: 'secret_demo_client',
|
|
370
|
+
grant_type: 'password'
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
/* Please remove this ASAP - Needs *channels* array in user object ALWAYS */
|
|
374
|
+
private forceChannelsForSeller(tokens:any){
|
|
375
|
+
if (UserRoleType.SELLER == tokens.type as UserRoleType)
|
|
376
|
+
this.channels?.length
|
|
377
|
+
? this._user!.setChannels(...this.channels)
|
|
378
|
+
: this._user!.setChannels(this.channel)
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Carga el cliente con el que se realizaran pedidos. Si recibe el valor null
|
|
383
|
+
* se vuelve a cargar el vendedor para su uso.
|
|
384
|
+
* @param customer
|
|
385
|
+
*/
|
|
386
|
+
public setCustomer(customer:any){
|
|
387
|
+
let refreshPage = false
|
|
388
|
+
this._customer = customer
|
|
389
|
+
this._localStorage.setItem(this.CUSTOMER, JSON.stringify(customer))
|
|
390
|
+
|
|
391
|
+
let sameChannel = customer ? this.sameChannel(customer.channels[0].code, customer.channels[0].locales.code) : null
|
|
392
|
+
|
|
393
|
+
if (customer) {
|
|
394
|
+
if(!sameChannel){
|
|
395
|
+
!localStorage.getItem(this.CHANNELSELLER) ?
|
|
396
|
+
localStorage.setItem(this.CHANNELSELLER, JSON.stringify({
|
|
397
|
+
channel: this._apiConsts.CHANNEL,
|
|
398
|
+
locale: this._apiConsts.LOCALE
|
|
399
|
+
})) : null;
|
|
400
|
+
this.changeChannel({
|
|
401
|
+
channel: customer.channels[0].code,
|
|
402
|
+
locale: customer.channels[0].locales.code
|
|
403
|
+
})
|
|
404
|
+
refreshPage = true
|
|
405
|
+
}
|
|
406
|
+
} else {
|
|
407
|
+
let res = JSON.parse(this._localStorage.getItem(this.CHANNELSELLER))
|
|
408
|
+
if(res){
|
|
409
|
+
if(!this.sameChannel(res.channel, res.locale)){
|
|
410
|
+
this.changeChannel(res)
|
|
411
|
+
refreshPage = true
|
|
412
|
+
}
|
|
413
|
+
localStorage.removeItem(this.CHANNELSELLER);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
//this._cartService.clearAndResetCustomerCart()
|
|
417
|
+
refreshPage ? location.href = location.href : null
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Comprueba si los valores del canal actual son iguales a los ingresado por parametros.
|
|
422
|
+
* @param {string} channel Nombre del canal
|
|
423
|
+
* @param {string} locale Locale del canal
|
|
424
|
+
* @returns {boolean} True si es el mismo canal, False caso contrario.
|
|
425
|
+
*/
|
|
426
|
+
private sameChannel = (channel:string, locale:string):boolean => (channel == this._apiConsts.CHANNEL) && (locale == this._apiConsts.LOCALE)
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Cambia de canal
|
|
430
|
+
* @param channelConfig debe ser un objeto que contenga al menos las keys channel y locale.
|
|
431
|
+
*/
|
|
432
|
+
private changeChannel = (channelConfig:any) => {
|
|
433
|
+
this._constants.modifyChannelConfig({
|
|
434
|
+
channel: channelConfig.channel,
|
|
435
|
+
locale: channelConfig.locale
|
|
436
|
+
})
|
|
437
|
+
}
|
|
438
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { inject, Injectable } from '@angular/core';
|
|
2
|
+
import { BehaviorSubject, map } from 'rxjs';
|
|
3
|
+
import { NgxLocalStorageService } from './ngx-local-storage.service';
|
|
4
|
+
import { LocalStorageService } from './local-storage.service';
|
|
5
|
+
import moment from 'moment';
|
|
6
|
+
|
|
7
|
+
@Injectable({
|
|
8
|
+
providedIn: 'root'
|
|
9
|
+
})
|
|
10
|
+
export class AuthStorageService {
|
|
11
|
+
private _localStorage = inject(LocalStorageService);
|
|
12
|
+
|
|
13
|
+
private _authTokenSubject = new BehaviorSubject<string | null>(null)
|
|
14
|
+
|
|
15
|
+
// Contantes para el storage.
|
|
16
|
+
private readonly JWT_TOKEN = 'JWT_TOKEN'
|
|
17
|
+
private readonly REFRESH_TOKEN = 'REFRESH_TOKEN'
|
|
18
|
+
private readonly EXPIRATES_IN = 'EXPIRATES_IN'
|
|
19
|
+
constructor() { }
|
|
20
|
+
|
|
21
|
+
setAuthToken(token: string | null): void {
|
|
22
|
+
this._authTokenSubject.next(token);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getAuthToken$() {
|
|
26
|
+
return this._authTokenSubject.asObservable();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getAuthToken(): string | null {
|
|
30
|
+
if(!this._authTokenSubject.value){
|
|
31
|
+
const res = this._localStorage.getItem(this.JWT_TOKEN)
|
|
32
|
+
return res ? res : null;
|
|
33
|
+
} else {
|
|
34
|
+
return this._authTokenSubject.value;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Devuelve `true`si el token expiro, `false` caso contrario.
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
private isTokenExpired() {
|
|
43
|
+
const fecha_expiracion = this.getExpiratesAt();
|
|
44
|
+
const result = moment() >= moment(fecha_expiracion);
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Obtiene la fecha de expiración del token.
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
private getExpiratesAt() {
|
|
52
|
+
return this._localStorage.getItem(this.EXPIRATES_IN);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { inject, Injectable } from '@angular/core';
|
|
2
|
+
import { ApiConstantsService } from '../constants';
|
|
3
|
+
import { BehaviorSubject, map, Observable, shareReplay } from 'rxjs';
|
|
4
|
+
import { IBlock, IBlockInfo } from '../interfaces';
|
|
5
|
+
import { ConnectionService } from '../api';
|
|
6
|
+
/**
|
|
7
|
+
* Servicio que maneja los bloques como repositorio.
|
|
8
|
+
* @class BlocksRepositoryService
|
|
9
|
+
*/
|
|
10
|
+
@Injectable({
|
|
11
|
+
providedIn: 'root'
|
|
12
|
+
})
|
|
13
|
+
export class BlocksRepositoryService {
|
|
14
|
+
/**
|
|
15
|
+
* Constantes de la API
|
|
16
|
+
*/
|
|
17
|
+
private apiConstants = inject(ApiConstantsService);
|
|
18
|
+
/**
|
|
19
|
+
* Menaja las conexiones con la API
|
|
20
|
+
*/
|
|
21
|
+
private connection = inject(ConnectionService)
|
|
22
|
+
/**
|
|
23
|
+
* Subject para manejar los bloques recibidos.
|
|
24
|
+
*/
|
|
25
|
+
private blocksSubject = new BehaviorSubject<IBlock[]>([])
|
|
26
|
+
/**
|
|
27
|
+
* Observable de bloques.
|
|
28
|
+
*/
|
|
29
|
+
private blocks$: Observable<IBlock[]> = this.blocksSubject.asObservable();
|
|
30
|
+
|
|
31
|
+
//API URLS
|
|
32
|
+
/**
|
|
33
|
+
* Devuelve la url para obtener los bloques segun la sección.
|
|
34
|
+
* @param section
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
blocksAPI(section: string) { return `${this.apiConstants.CMS_URL}${this.apiConstants.CHANNEL}/blocks/section/${section}?locale=${this.apiConstants.LOCALE}` }
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Obtiene los bloques segun la seccion del Backend.
|
|
41
|
+
* @param section
|
|
42
|
+
* @returns Un observable de los bloques.
|
|
43
|
+
*/
|
|
44
|
+
public getBlocks(section: string): Observable<IBlock[]> {
|
|
45
|
+
//if(this.blocksSubject.getValue() != null){
|
|
46
|
+
this.connection.get(this.blocksAPI(section)).pipe(
|
|
47
|
+
shareReplay(1),
|
|
48
|
+
map((response: any) => {
|
|
49
|
+
//console.log(response)
|
|
50
|
+
this.blocksSubject.next(response.items)
|
|
51
|
+
return response
|
|
52
|
+
})
|
|
53
|
+
).subscribe()
|
|
54
|
+
//}
|
|
55
|
+
return this.blocks$
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* private hasSectionBlocks = (section: string) => {
|
|
59
|
+
|
|
60
|
+
} */
|
|
61
|
+
|
|
62
|
+
private appendBlock = (blocks: IBlock[], section: string) => {
|
|
63
|
+
const new_block: IBlockInfo = { section, blocks };
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { inject, Injectable } from '@angular/core';
|
|
2
|
+
import { BehaviorSubject, Observable } from 'rxjs';
|
|
3
|
+
import { ApiConstantsService } from '../constants';
|
|
4
|
+
import { BlocksRepositoryService } from './blocks-repository.service';
|
|
5
|
+
import { IBlock } from '../interfaces';
|
|
6
|
+
/**
|
|
7
|
+
* Servicio de tipo adapter para manejar los bloques.
|
|
8
|
+
* @class BlocksService
|
|
9
|
+
*/
|
|
10
|
+
@Injectable({
|
|
11
|
+
providedIn: 'root'
|
|
12
|
+
})
|
|
13
|
+
export class BlocksService {
|
|
14
|
+
/**
|
|
15
|
+
* Constantes de la API
|
|
16
|
+
*/
|
|
17
|
+
private apiConstants = inject(ApiConstantsService);
|
|
18
|
+
/**
|
|
19
|
+
* Servicio de BlocksRepository.
|
|
20
|
+
*/
|
|
21
|
+
private blocksRepositoryService = inject(BlocksRepositoryService);
|
|
22
|
+
/**
|
|
23
|
+
* Subject para manejar los bloques recibidos.
|
|
24
|
+
*/
|
|
25
|
+
private blocksSubject = new BehaviorSubject<any[]>([]);
|
|
26
|
+
/**
|
|
27
|
+
* Observable de bloques.
|
|
28
|
+
*/
|
|
29
|
+
public blocks$: Observable<any[]> = this.blocksSubject.asObservable();
|
|
30
|
+
|
|
31
|
+
//API URLS
|
|
32
|
+
/**
|
|
33
|
+
* Devuelve la url para interactuar con el bloque de contacto.
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
contactFormResponseAPI() { return `${this.apiConstants.CMS_URL}${this.apiConstants.LOCALE}/contact-form/response` }
|
|
37
|
+
|
|
38
|
+
//METHODS
|
|
39
|
+
/**
|
|
40
|
+
* Obtiene los bloques de una sección en especifico.
|
|
41
|
+
* @param section
|
|
42
|
+
* @returns Observable de los bloques.
|
|
43
|
+
*/
|
|
44
|
+
public getBlocks(section: string): Observable<any> {
|
|
45
|
+
return this.blocksRepositoryService.getBlocks(section)
|
|
46
|
+
}
|
|
47
|
+
constructor() { }
|
|
48
|
+
}
|