@infrab4a/connect-angular 4.17.3-beta.5 → 4.17.3-beta.7
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/esm2020/angular-connect.module.mjs +2 -4
- package/esm2020/services/cart.service.mjs +19 -189
- package/esm2020/services/checkout.service.mjs +19 -1
- package/esm2020/services/index.mjs +1 -2
- package/fesm2015/infrab4a-connect-angular.mjs +36 -275
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +36 -276
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
- package/services/cart.service.d.ts +0 -11
- package/services/checkout.service.d.ts +11 -1
- package/services/index.d.ts +0 -1
- package/esm2020/services/shipping.service.mjs +0 -96
- package/esm2020/services/types/shipping-methods.type.mjs +0 -2
- package/services/shipping.service.d.ts +0 -19
- package/services/types/shipping-methods.type.d.ts +0 -12
|
@@ -5,14 +5,14 @@ import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular
|
|
|
5
5
|
import * as i2$1 from '@angular/fire/storage';
|
|
6
6
|
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
7
7
|
import * as i1$2 from '@infrab4a/connect';
|
|
8
|
-
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, OrderBlockedFirestoreRepository, LogFirestoreRepository, SequenceFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, isNil, NotFoundError, Checkout, pick, LineItem,
|
|
8
|
+
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, OrderBlockedFirestoreRepository, LogFirestoreRepository, SequenceFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, isNil, NotFoundError, Checkout, pick, LineItem, set, InvalidArgumentError, RoundProductPricesHelper, isEmpty, Category, PersonTypes, WishlistLogType, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
|
|
9
9
|
import * as i1 from '@angular/fire/auth';
|
|
10
10
|
import { Auth, provideAuth, getAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
11
11
|
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
|
|
12
12
|
import * as i1$1 from '@angular/fire/firestore';
|
|
13
13
|
import { Firestore, provideFirestore, initializeFirestore, memoryLocalCache, docSnapshots, doc } from '@angular/fire/firestore';
|
|
14
14
|
import cookie from 'js-cookie';
|
|
15
|
-
import { of, from, combineLatest, throwError, Subject,
|
|
15
|
+
import { of, from, combineLatest, throwError, Subject, forkJoin } from 'rxjs';
|
|
16
16
|
import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
|
|
17
17
|
import * as i2 from '@angular/common/http';
|
|
18
18
|
import { __decorate, __metadata } from 'tslib';
|
|
@@ -1407,6 +1407,24 @@ class CheckoutService {
|
|
|
1407
1407
|
checkoutId: checkout.id,
|
|
1408
1408
|
})));
|
|
1409
1409
|
}
|
|
1410
|
+
getShippingProduct(shippingProduct) {
|
|
1411
|
+
return this.http.post(`${this.checkoutUrl}/checkoutGetAvailableShipping`, {
|
|
1412
|
+
checkoutId: null,
|
|
1413
|
+
shippingProduct,
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
getAvailableShipping(productShipping) {
|
|
1417
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutGetAvailableShipping`, {
|
|
1418
|
+
checkoutId: checkout.id,
|
|
1419
|
+
productShipping,
|
|
1420
|
+
})));
|
|
1421
|
+
}
|
|
1422
|
+
selectShipping(option) {
|
|
1423
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutSelectShipping`, {
|
|
1424
|
+
checkoutId: checkout.id,
|
|
1425
|
+
shippingOption: option,
|
|
1426
|
+
})), concatMap(() => this.getCheckout()));
|
|
1427
|
+
}
|
|
1410
1428
|
async createCheckout(checkoutData) {
|
|
1411
1429
|
const checkout = await this.checkoutRepository.create({
|
|
1412
1430
|
createdAt: new Date(),
|
|
@@ -1470,61 +1488,6 @@ class CartService {
|
|
|
1470
1488
|
quantity: (cart[item.id]?.quantity || 0) + (item.quantity ? item.quantity : 1),
|
|
1471
1489
|
}),
|
|
1472
1490
|
}), {}) || {};
|
|
1473
|
-
this.buildLineItem = async ({ checkout, item, quantity, }) => {
|
|
1474
|
-
const product = await this.getProductData(item.id);
|
|
1475
|
-
item.quantity = item?.quantity || checkout?.lineItems?.find((lineItem) => lineItem.id === item.id)?.quantity || 0;
|
|
1476
|
-
if (this.checkMaxStock(product.stock.quantity, item.quantity || 0, quantity || 0))
|
|
1477
|
-
throw new Error('Desculpe! Temos apenas ' + product.stock?.quantity + ' em estoque.');
|
|
1478
|
-
const image = item.image || item.images?.shift();
|
|
1479
|
-
const { id, name, EAN, slug, weight, sku, type } = item;
|
|
1480
|
-
const isGift = item?.isGift || null;
|
|
1481
|
-
const pricePaid = isGift
|
|
1482
|
-
? 0
|
|
1483
|
-
: this.getProductPrice({
|
|
1484
|
-
product: LineItem.toInstance(product),
|
|
1485
|
-
shop: checkout.shop || this.defaultShop,
|
|
1486
|
-
isSubscriber: checkout.user?.isSubscriber,
|
|
1487
|
-
});
|
|
1488
|
-
RoundProductPricesHelper.roundProductPrices(item);
|
|
1489
|
-
RoundProductPricesHelper.roundProductPrices(product);
|
|
1490
|
-
return {
|
|
1491
|
-
checkout,
|
|
1492
|
-
lineItem: LineItem.toInstance({
|
|
1493
|
-
id,
|
|
1494
|
-
name: name ?? product.name,
|
|
1495
|
-
EAN: EAN ?? product.EAN,
|
|
1496
|
-
brand: product.brand,
|
|
1497
|
-
slug: slug ?? product.slug,
|
|
1498
|
-
sku: sku ?? product.sku,
|
|
1499
|
-
stock: product.stock,
|
|
1500
|
-
price: this.roundPrice(product.price),
|
|
1501
|
-
image,
|
|
1502
|
-
weight: weight ?? product.weight,
|
|
1503
|
-
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1504
|
-
pricePaid,
|
|
1505
|
-
discount: 0,
|
|
1506
|
-
categories: product.categories || product.category?.id ? [product.category?.id, ...product.categories] : [],
|
|
1507
|
-
category: product.category,
|
|
1508
|
-
isGift: isGift ?? null,
|
|
1509
|
-
costPrice: isGift ? 0 : product.costPrice ?? 0,
|
|
1510
|
-
type,
|
|
1511
|
-
label: product.label,
|
|
1512
|
-
}),
|
|
1513
|
-
};
|
|
1514
|
-
};
|
|
1515
|
-
this.getProductPrice = ({ product, isSubscriber, }) => {
|
|
1516
|
-
const info = product.price;
|
|
1517
|
-
if (product.isGift)
|
|
1518
|
-
return 0;
|
|
1519
|
-
return isSubscriber && info.subscriberPrice > 0
|
|
1520
|
-
? Number(info.subscriberPrice.toFixed(2))
|
|
1521
|
-
: Number(info.price.toFixed(2));
|
|
1522
|
-
};
|
|
1523
|
-
this.checkMaxStock = (currentStock, currentItemQtd, quantityToAdd) => {
|
|
1524
|
-
const maxStock = currentStock || 0;
|
|
1525
|
-
const currentItemAmount = currentItemQtd || 0;
|
|
1526
|
-
return currentItemAmount + quantityToAdd > maxStock;
|
|
1527
|
-
};
|
|
1528
1491
|
// this.checkoutUrl = `https://southamerica-east1-${this.firebaseOptions.projectId}.cloudfunctions.net`
|
|
1529
1492
|
this.checkoutUrl = `http://docker.for.localhost:5001/b4astage-cb80a/southamerica-east1`;
|
|
1530
1493
|
}
|
|
@@ -1627,12 +1590,21 @@ class CartService {
|
|
|
1627
1590
|
this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
|
|
1628
1591
|
return this.cartSubject;
|
|
1629
1592
|
}
|
|
1630
|
-
/**
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
getVariantPriceDiscount(item) {
|
|
1634
|
-
|
|
1635
|
-
|
|
1593
|
+
// /**
|
|
1594
|
+
// * @deprecated The method should not be used
|
|
1595
|
+
// */
|
|
1596
|
+
// getVariantPriceDiscount(item: LineItem): Observable<number> {
|
|
1597
|
+
// return this.authService.getUser().pipe(
|
|
1598
|
+
// concatMap((user) =>
|
|
1599
|
+
// iif(
|
|
1600
|
+
// () => user.isSubscriber && !!item.price.subscriberPrice,
|
|
1601
|
+
// of(item.price.subscriberPrice),
|
|
1602
|
+
// of(item.price.price),
|
|
1603
|
+
// ),
|
|
1604
|
+
// ),
|
|
1605
|
+
// catchError(() => of(item.price.price)),
|
|
1606
|
+
// )
|
|
1607
|
+
// }
|
|
1636
1608
|
clearCart() {
|
|
1637
1609
|
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1638
1610
|
this.checkoutService.clearCheckoutFromSession();
|
|
@@ -1642,130 +1614,6 @@ class CartService {
|
|
|
1642
1614
|
buildCartFromCheckout(checkoutData) {
|
|
1643
1615
|
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
1644
1616
|
}
|
|
1645
|
-
roundPrice(productPrice) {
|
|
1646
|
-
const { price, fullPrice, subscriberPrice } = productPrice;
|
|
1647
|
-
return {
|
|
1648
|
-
...productPrice,
|
|
1649
|
-
price: Number(price.toFixed(2)),
|
|
1650
|
-
fullPrice: Number(fullPrice.toFixed(2)),
|
|
1651
|
-
...(subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }),
|
|
1652
|
-
};
|
|
1653
|
-
}
|
|
1654
|
-
async getProductData(productId) {
|
|
1655
|
-
let product;
|
|
1656
|
-
let variant;
|
|
1657
|
-
try {
|
|
1658
|
-
product = await this.productRepository.get({ id: productId });
|
|
1659
|
-
}
|
|
1660
|
-
catch (error) {
|
|
1661
|
-
if (!(error instanceof NotFoundError))
|
|
1662
|
-
throw error;
|
|
1663
|
-
const { data: variants } = await this.variantRepository.find({ filters: { id: productId } });
|
|
1664
|
-
variant = variants.shift();
|
|
1665
|
-
if (!variant)
|
|
1666
|
-
throw error;
|
|
1667
|
-
product = await this.productRepository.get({ id: variant.productId });
|
|
1668
|
-
}
|
|
1669
|
-
return {
|
|
1670
|
-
...product.toPlain(),
|
|
1671
|
-
...(variant && { ...variant.toPlain() }),
|
|
1672
|
-
};
|
|
1673
|
-
}
|
|
1674
|
-
getGifts() {
|
|
1675
|
-
return this.checkoutService.getCheckout().pipe(mergeMap(async (checkout) => {
|
|
1676
|
-
const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
|
|
1677
|
-
if (!notGiftItems.length)
|
|
1678
|
-
return { ...checkout, lineItems: [] };
|
|
1679
|
-
const campaigns = await this.buy2WinRepository
|
|
1680
|
-
.find({
|
|
1681
|
-
filters: {
|
|
1682
|
-
active: { operator: Where.EQUALS, value: true },
|
|
1683
|
-
},
|
|
1684
|
-
})
|
|
1685
|
-
.then((data) => data.data.filter((campaign) => campaign.shop === Shops.ALL || campaign.shop === this.defaultShop));
|
|
1686
|
-
if (!campaigns.length)
|
|
1687
|
-
return { ...checkout, lineItems: notGiftItems };
|
|
1688
|
-
const elegibleCampaigns = [];
|
|
1689
|
-
for (const campaign of campaigns) {
|
|
1690
|
-
const today = new Date().getTime();
|
|
1691
|
-
if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
|
|
1692
|
-
continue;
|
|
1693
|
-
if (campaign.activeCategory) {
|
|
1694
|
-
const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
|
|
1695
|
-
const categoriesCampaingFullTree = [];
|
|
1696
|
-
for (const id of categoriesCampaing) {
|
|
1697
|
-
const children = await this.categoryRepository.getChildren(parseInt(id));
|
|
1698
|
-
categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
|
|
1699
|
-
}
|
|
1700
|
-
const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
|
|
1701
|
-
const filterProductsCategories = notGiftItems.filter((l) => {
|
|
1702
|
-
if (!l.categories || !l.categories?.length)
|
|
1703
|
-
return true;
|
|
1704
|
-
return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
|
|
1705
|
-
});
|
|
1706
|
-
if (filterProductsCategories.length) {
|
|
1707
|
-
const cartValuelWithCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1708
|
-
const cartItensQuantityWithCategories = filterProductsCategories.reduce((a, b) => a + b.quantity, 0);
|
|
1709
|
-
const hasMinValue = campaign.cartValueMin && cartValuelWithCategories >= campaign.cartValueMin;
|
|
1710
|
-
const hasMinQuantity = campaign.cartItensQuantityMin && cartItensQuantityWithCategories >= campaign.cartItensQuantityMin;
|
|
1711
|
-
if (hasMinQuantity || hasMinValue)
|
|
1712
|
-
elegibleCampaigns.push(campaign);
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
else {
|
|
1716
|
-
const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1717
|
-
const cartItensQuantity = notGiftItems.reduce((a, b) => a + b.quantity, 0);
|
|
1718
|
-
const hasMinValue = campaign.cartValue && campaign.cartValue > 0 && campaign.cartValue <= cartTotal;
|
|
1719
|
-
const hasMinQuantity = campaign.cartItensQuantityMin && cartItensQuantity >= campaign.cartItensQuantityMin;
|
|
1720
|
-
if (hasMinQuantity || hasMinValue)
|
|
1721
|
-
elegibleCampaigns.push(campaign);
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
if (!elegibleCampaigns.length)
|
|
1725
|
-
return { ...checkout, lineItems: notGiftItems };
|
|
1726
|
-
const campaingnProducts = [];
|
|
1727
|
-
for (const campaign of elegibleCampaigns) {
|
|
1728
|
-
let elegibleProducts = [];
|
|
1729
|
-
for (const product of campaign.products) {
|
|
1730
|
-
const { data: productData } = await this.productRepository.find({ filters: { sku: product } });
|
|
1731
|
-
if (!productData.length)
|
|
1732
|
-
continue;
|
|
1733
|
-
const gift = productData.shift();
|
|
1734
|
-
if (gift.stock.quantity < 1)
|
|
1735
|
-
continue;
|
|
1736
|
-
elegibleProducts.push(gift);
|
|
1737
|
-
}
|
|
1738
|
-
campaingnProducts.push(elegibleProducts);
|
|
1739
|
-
}
|
|
1740
|
-
if (!campaingnProducts.length)
|
|
1741
|
-
return { ...checkout, lineItems: notGiftItems };
|
|
1742
|
-
const gifts = this.giftToLineItems([].concat(...campaingnProducts));
|
|
1743
|
-
return { ...checkout, lineItems: notGiftItems.concat(gifts) };
|
|
1744
|
-
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1745
|
-
}
|
|
1746
|
-
giftToLineItems(items) {
|
|
1747
|
-
return items.map((item) => {
|
|
1748
|
-
const { brand, categories, category, id, name, price, sku, slug, stock, weight, EAN } = item;
|
|
1749
|
-
const image = item?.miniatures?.length ? item.miniatures[0] : item.images[0];
|
|
1750
|
-
return LineItem.toInstance({
|
|
1751
|
-
brand,
|
|
1752
|
-
categories,
|
|
1753
|
-
category,
|
|
1754
|
-
id: id.toString(),
|
|
1755
|
-
name,
|
|
1756
|
-
price,
|
|
1757
|
-
sku,
|
|
1758
|
-
slug,
|
|
1759
|
-
stock,
|
|
1760
|
-
weight,
|
|
1761
|
-
EAN,
|
|
1762
|
-
image,
|
|
1763
|
-
pricePaid: 0,
|
|
1764
|
-
quantity: 1,
|
|
1765
|
-
isGift: true,
|
|
1766
|
-
});
|
|
1767
|
-
});
|
|
1768
|
-
}
|
|
1769
1617
|
}
|
|
1770
1618
|
CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: FIREBASE_OPTIONS }, { token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }, { token: i2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1771
1619
|
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
|
|
@@ -2633,92 +2481,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2633
2481
|
args: ['OrderRepository']
|
|
2634
2482
|
}] }]; } });
|
|
2635
2483
|
|
|
2636
|
-
class ShippingService {
|
|
2637
|
-
constructor(http, apiUrl, homeService) {
|
|
2638
|
-
this.http = http;
|
|
2639
|
-
this.apiUrl = apiUrl;
|
|
2640
|
-
this.homeService = homeService;
|
|
2641
|
-
}
|
|
2642
|
-
getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
|
|
2643
|
-
return combineLatest([
|
|
2644
|
-
this.homeService.getHomeData(),
|
|
2645
|
-
this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
|
|
2646
|
-
]).pipe(map(([datas, shippingMethodsResponse]) => {
|
|
2647
|
-
let shippingMethods = shippingMethodsResponse.result;
|
|
2648
|
-
if (!shippingMethods.length)
|
|
2649
|
-
return [];
|
|
2650
|
-
shippingMethods = shippingMethods.map((shippingMethod) => {
|
|
2651
|
-
if (shippingMethod.ShippingCompanyName == 'Same Day EG')
|
|
2652
|
-
shippingMethod.ShippingCompanyName = 'Same Day';
|
|
2653
|
-
return shippingMethod;
|
|
2654
|
-
});
|
|
2655
|
-
const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
|
|
2656
|
-
if (this.isHolidays(datasSameDayNotAvaliable)) {
|
|
2657
|
-
shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
|
|
2658
|
-
}
|
|
2659
|
-
if (totalPrice >= 200) {
|
|
2660
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2661
|
-
if (s.serviceName !== 'Same Day')
|
|
2662
|
-
return { ...s, totalPrice: 0 };
|
|
2663
|
-
else
|
|
2664
|
-
return s;
|
|
2665
|
-
});
|
|
2666
|
-
}
|
|
2667
|
-
if (shop == Shops.GLAMSHOP)
|
|
2668
|
-
return shippingMethods;
|
|
2669
|
-
if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
|
|
2670
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2671
|
-
if (s.serviceName == 'Same Day')
|
|
2672
|
-
return { ...s, totalPrice: s.totalPrice / 2 };
|
|
2673
|
-
else
|
|
2674
|
-
return { ...s, totalPrice: 0 };
|
|
2675
|
-
});
|
|
2676
|
-
}
|
|
2677
|
-
if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
|
|
2678
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2679
|
-
return { ...s, totalPrice: s.totalPrice / 2 };
|
|
2680
|
-
});
|
|
2681
|
-
}
|
|
2682
|
-
return shippingMethods;
|
|
2683
|
-
}));
|
|
2684
|
-
}
|
|
2685
|
-
isFreeShippingBySubscription(shop, subscriptionPlan) {
|
|
2686
|
-
if (!subscriptionPlan)
|
|
2687
|
-
return false;
|
|
2688
|
-
if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
|
|
2689
|
-
return true;
|
|
2690
|
-
return false;
|
|
2691
|
-
}
|
|
2692
|
-
isHalfShippingBySubscription(shop, subscriptionPlan) {
|
|
2693
|
-
if (!subscriptionPlan)
|
|
2694
|
-
return false;
|
|
2695
|
-
if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
|
|
2696
|
-
return true;
|
|
2697
|
-
}
|
|
2698
|
-
return false;
|
|
2699
|
-
}
|
|
2700
|
-
isHolidays(datas) {
|
|
2701
|
-
const today = new Date();
|
|
2702
|
-
for (const key in datas) {
|
|
2703
|
-
let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
|
|
2704
|
-
let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
|
|
2705
|
-
if (start > end)
|
|
2706
|
-
end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
|
|
2707
|
-
if (today >= start && today <= end)
|
|
2708
|
-
return true;
|
|
2709
|
-
}
|
|
2710
|
-
return false;
|
|
2711
|
-
}
|
|
2712
|
-
}
|
|
2713
|
-
ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, deps: [{ token: i2.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2714
|
-
ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
|
|
2715
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
|
|
2716
|
-
type: Injectable
|
|
2717
|
-
}], ctorParameters: function () { return [{ type: i2.HttpClient }, { type: undefined, decorators: [{
|
|
2718
|
-
type: Inject,
|
|
2719
|
-
args: [BACKEND_URL]
|
|
2720
|
-
}] }, { type: HomeShopService }]; } });
|
|
2721
|
-
|
|
2722
2484
|
class AngularConnectModule {
|
|
2723
2485
|
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
2724
2486
|
return {
|
|
@@ -2759,7 +2521,6 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
|
|
|
2759
2521
|
CouponService,
|
|
2760
2522
|
HomeShopService,
|
|
2761
2523
|
OrderService,
|
|
2762
|
-
ShippingService,
|
|
2763
2524
|
WishlistService,
|
|
2764
2525
|
{
|
|
2765
2526
|
provide: UpdateUserImage,
|
|
@@ -2824,7 +2585,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2824
2585
|
CouponService,
|
|
2825
2586
|
HomeShopService,
|
|
2826
2587
|
OrderService,
|
|
2827
|
-
ShippingService,
|
|
2828
2588
|
WishlistService,
|
|
2829
2589
|
{
|
|
2830
2590
|
provide: UpdateUserImage,
|
|
@@ -2852,5 +2612,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2852
2612
|
* Generated bundle index. Do not edit.
|
|
2853
2613
|
*/
|
|
2854
2614
|
|
|
2855
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts,
|
|
2615
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, UtilHelper, WishlistService };
|
|
2856
2616
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|