@infrab4a/connect-angular 4.17.3-beta.4 → 4.17.3-beta.6
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 +15 -4
- package/esm2020/services/index.mjs +1 -2
- package/fesm2015/infrab4a-connect-angular.mjs +31 -277
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +31 -278
- 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 +4 -2
- 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,
|
|
15
|
+
import { of, from, combineLatest, throwError, Subject, forkJoin } from 'rxjs';
|
|
16
16
|
import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
|
|
17
17
|
import { __awaiter, __decorate, __metadata } from 'tslib';
|
|
18
18
|
import * as i2 from '@angular/common/http';
|
|
@@ -1428,9 +1428,20 @@ class CheckoutService {
|
|
|
1428
1428
|
// )
|
|
1429
1429
|
}
|
|
1430
1430
|
validateStockProducts() {
|
|
1431
|
-
return
|
|
1431
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutValidateProductStock`, {
|
|
1432
1432
|
checkoutId: checkout.id,
|
|
1433
|
-
})))
|
|
1433
|
+
})));
|
|
1434
|
+
}
|
|
1435
|
+
getAvailableShipping() {
|
|
1436
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutValidateProductStock`, {
|
|
1437
|
+
checkoutId: checkout.id,
|
|
1438
|
+
})));
|
|
1439
|
+
}
|
|
1440
|
+
selectShipping(option) {
|
|
1441
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.http.post(`${this.checkoutUrl}/checkoutSelectShipping`, {
|
|
1442
|
+
checkoutId: checkout.id,
|
|
1443
|
+
shippingOption: option,
|
|
1444
|
+
})), concatMap(() => this.getCheckout()));
|
|
1434
1445
|
}
|
|
1435
1446
|
createCheckout(checkoutData) {
|
|
1436
1447
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1493,62 +1504,6 @@ class CartService {
|
|
|
1493
1504
|
var _a;
|
|
1494
1505
|
return (Object.assign(Object.assign({}, cart), { [item.id]: LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.id] || item)), { quantity: (((_a = cart[item.id]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })) }));
|
|
1495
1506
|
}, {})) || {};
|
|
1496
|
-
this.buildLineItem = ({ checkout, item, quantity, }) => __awaiter(this, void 0, void 0, function* () {
|
|
1497
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1498
|
-
const product = yield this.getProductData(item.id);
|
|
1499
|
-
item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.id === item.id)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
|
|
1500
|
-
if (this.checkMaxStock(product.stock.quantity, item.quantity || 0, quantity || 0))
|
|
1501
|
-
throw new Error('Desculpe! Temos apenas ' + ((_c = product.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
|
|
1502
|
-
const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
|
|
1503
|
-
const { id, name, EAN, slug, weight, sku, type } = item;
|
|
1504
|
-
const isGift = (item === null || item === void 0 ? void 0 : item.isGift) || null;
|
|
1505
|
-
const pricePaid = isGift
|
|
1506
|
-
? 0
|
|
1507
|
-
: this.getProductPrice({
|
|
1508
|
-
product: LineItem.toInstance(product),
|
|
1509
|
-
shop: checkout.shop || this.defaultShop,
|
|
1510
|
-
isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
|
|
1511
|
-
});
|
|
1512
|
-
RoundProductPricesHelper.roundProductPrices(item);
|
|
1513
|
-
RoundProductPricesHelper.roundProductPrices(product);
|
|
1514
|
-
return {
|
|
1515
|
-
checkout,
|
|
1516
|
-
lineItem: LineItem.toInstance({
|
|
1517
|
-
id,
|
|
1518
|
-
name: name !== null && name !== void 0 ? name : product.name,
|
|
1519
|
-
EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
|
|
1520
|
-
brand: product.brand,
|
|
1521
|
-
slug: slug !== null && slug !== void 0 ? slug : product.slug,
|
|
1522
|
-
sku: sku !== null && sku !== void 0 ? sku : product.sku,
|
|
1523
|
-
stock: product.stock,
|
|
1524
|
-
price: this.roundPrice(product.price),
|
|
1525
|
-
image,
|
|
1526
|
-
weight: weight !== null && weight !== void 0 ? weight : product.weight,
|
|
1527
|
-
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1528
|
-
pricePaid,
|
|
1529
|
-
discount: 0,
|
|
1530
|
-
categories: product.categories || ((_f = product.category) === null || _f === void 0 ? void 0 : _f.id) ? [(_g = product.category) === null || _g === void 0 ? void 0 : _g.id, ...product.categories] : [],
|
|
1531
|
-
category: product.category,
|
|
1532
|
-
isGift: isGift !== null && isGift !== void 0 ? isGift : null,
|
|
1533
|
-
costPrice: isGift ? 0 : (_h = product.costPrice) !== null && _h !== void 0 ? _h : 0,
|
|
1534
|
-
type,
|
|
1535
|
-
label: product.label,
|
|
1536
|
-
}),
|
|
1537
|
-
};
|
|
1538
|
-
});
|
|
1539
|
-
this.getProductPrice = ({ product, isSubscriber, }) => {
|
|
1540
|
-
const info = product.price;
|
|
1541
|
-
if (product.isGift)
|
|
1542
|
-
return 0;
|
|
1543
|
-
return isSubscriber && info.subscriberPrice > 0
|
|
1544
|
-
? Number(info.subscriberPrice.toFixed(2))
|
|
1545
|
-
: Number(info.price.toFixed(2));
|
|
1546
|
-
};
|
|
1547
|
-
this.checkMaxStock = (currentStock, currentItemQtd, quantityToAdd) => {
|
|
1548
|
-
const maxStock = currentStock || 0;
|
|
1549
|
-
const currentItemAmount = currentItemQtd || 0;
|
|
1550
|
-
return currentItemAmount + quantityToAdd > maxStock;
|
|
1551
|
-
};
|
|
1552
1507
|
// this.checkoutUrl = `https://southamerica-east1-${this.firebaseOptions.projectId}.cloudfunctions.net`
|
|
1553
1508
|
this.checkoutUrl = `http://docker.for.localhost:5001/b4astage-cb80a/southamerica-east1`;
|
|
1554
1509
|
}
|
|
@@ -1651,12 +1606,21 @@ class CartService {
|
|
|
1651
1606
|
this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
|
|
1652
1607
|
return this.cartSubject;
|
|
1653
1608
|
}
|
|
1654
|
-
/**
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
getVariantPriceDiscount(item) {
|
|
1658
|
-
|
|
1659
|
-
|
|
1609
|
+
// /**
|
|
1610
|
+
// * @deprecated The method should not be used
|
|
1611
|
+
// */
|
|
1612
|
+
// getVariantPriceDiscount(item: LineItem): Observable<number> {
|
|
1613
|
+
// return this.authService.getUser().pipe(
|
|
1614
|
+
// concatMap((user) =>
|
|
1615
|
+
// iif(
|
|
1616
|
+
// () => user.isSubscriber && !!item.price.subscriberPrice,
|
|
1617
|
+
// of(item.price.subscriberPrice),
|
|
1618
|
+
// of(item.price.price),
|
|
1619
|
+
// ),
|
|
1620
|
+
// ),
|
|
1621
|
+
// catchError(() => of(item.price.price)),
|
|
1622
|
+
// )
|
|
1623
|
+
// }
|
|
1660
1624
|
clearCart() {
|
|
1661
1625
|
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1662
1626
|
this.checkoutService.clearCheckoutFromSession();
|
|
@@ -1666,126 +1630,6 @@ class CartService {
|
|
|
1666
1630
|
buildCartFromCheckout(checkoutData) {
|
|
1667
1631
|
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
1668
1632
|
}
|
|
1669
|
-
roundPrice(productPrice) {
|
|
1670
|
-
const { price, fullPrice, subscriberPrice } = productPrice;
|
|
1671
|
-
return Object.assign(Object.assign(Object.assign({}, productPrice), { price: Number(price.toFixed(2)), fullPrice: Number(fullPrice.toFixed(2)) }), (subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }));
|
|
1672
|
-
}
|
|
1673
|
-
getProductData(productId) {
|
|
1674
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1675
|
-
let product;
|
|
1676
|
-
let variant;
|
|
1677
|
-
try {
|
|
1678
|
-
product = yield this.productRepository.get({ id: productId });
|
|
1679
|
-
}
|
|
1680
|
-
catch (error) {
|
|
1681
|
-
if (!(error instanceof NotFoundError))
|
|
1682
|
-
throw error;
|
|
1683
|
-
const { data: variants } = yield this.variantRepository.find({ filters: { id: productId } });
|
|
1684
|
-
variant = variants.shift();
|
|
1685
|
-
if (!variant)
|
|
1686
|
-
throw error;
|
|
1687
|
-
product = yield this.productRepository.get({ id: variant.productId });
|
|
1688
|
-
}
|
|
1689
|
-
return Object.assign(Object.assign({}, product.toPlain()), (variant && Object.assign({}, variant.toPlain())));
|
|
1690
|
-
});
|
|
1691
|
-
}
|
|
1692
|
-
getGifts() {
|
|
1693
|
-
return this.checkoutService.getCheckout().pipe(mergeMap((checkout) => __awaiter(this, void 0, void 0, function* () {
|
|
1694
|
-
const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
|
|
1695
|
-
if (!notGiftItems.length)
|
|
1696
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: [] });
|
|
1697
|
-
const campaigns = yield this.buy2WinRepository
|
|
1698
|
-
.find({
|
|
1699
|
-
filters: {
|
|
1700
|
-
active: { operator: Where.EQUALS, value: true },
|
|
1701
|
-
},
|
|
1702
|
-
})
|
|
1703
|
-
.then((data) => data.data.filter((campaign) => campaign.shop === Shops.ALL || campaign.shop === this.defaultShop));
|
|
1704
|
-
if (!campaigns.length)
|
|
1705
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
|
|
1706
|
-
const elegibleCampaigns = [];
|
|
1707
|
-
for (const campaign of campaigns) {
|
|
1708
|
-
const today = new Date().getTime();
|
|
1709
|
-
if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
|
|
1710
|
-
continue;
|
|
1711
|
-
if (campaign.activeCategory) {
|
|
1712
|
-
const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
|
|
1713
|
-
const categoriesCampaingFullTree = [];
|
|
1714
|
-
for (const id of categoriesCampaing) {
|
|
1715
|
-
const children = yield this.categoryRepository.getChildren(parseInt(id));
|
|
1716
|
-
categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
|
|
1717
|
-
}
|
|
1718
|
-
const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
|
|
1719
|
-
const filterProductsCategories = notGiftItems.filter((l) => {
|
|
1720
|
-
var _a;
|
|
1721
|
-
if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
1722
|
-
return true;
|
|
1723
|
-
return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
|
|
1724
|
-
});
|
|
1725
|
-
if (filterProductsCategories.length) {
|
|
1726
|
-
const cartValuelWithCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1727
|
-
const cartItensQuantityWithCategories = filterProductsCategories.reduce((a, b) => a + b.quantity, 0);
|
|
1728
|
-
const hasMinValue = campaign.cartValueMin && cartValuelWithCategories >= campaign.cartValueMin;
|
|
1729
|
-
const hasMinQuantity = campaign.cartItensQuantityMin && cartItensQuantityWithCategories >= campaign.cartItensQuantityMin;
|
|
1730
|
-
if (hasMinQuantity || hasMinValue)
|
|
1731
|
-
elegibleCampaigns.push(campaign);
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
else {
|
|
1735
|
-
const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1736
|
-
const cartItensQuantity = notGiftItems.reduce((a, b) => a + b.quantity, 0);
|
|
1737
|
-
const hasMinValue = campaign.cartValue && campaign.cartValue > 0 && campaign.cartValue <= cartTotal;
|
|
1738
|
-
const hasMinQuantity = campaign.cartItensQuantityMin && cartItensQuantity >= campaign.cartItensQuantityMin;
|
|
1739
|
-
if (hasMinQuantity || hasMinValue)
|
|
1740
|
-
elegibleCampaigns.push(campaign);
|
|
1741
|
-
}
|
|
1742
|
-
}
|
|
1743
|
-
if (!elegibleCampaigns.length)
|
|
1744
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
|
|
1745
|
-
const campaingnProducts = [];
|
|
1746
|
-
for (const campaign of elegibleCampaigns) {
|
|
1747
|
-
let elegibleProducts = [];
|
|
1748
|
-
for (const product of campaign.products) {
|
|
1749
|
-
const { data: productData } = yield this.productRepository.find({ filters: { sku: product } });
|
|
1750
|
-
if (!productData.length)
|
|
1751
|
-
continue;
|
|
1752
|
-
const gift = productData.shift();
|
|
1753
|
-
if (gift.stock.quantity < 1)
|
|
1754
|
-
continue;
|
|
1755
|
-
elegibleProducts.push(gift);
|
|
1756
|
-
}
|
|
1757
|
-
campaingnProducts.push(elegibleProducts);
|
|
1758
|
-
}
|
|
1759
|
-
if (!campaingnProducts.length)
|
|
1760
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
|
|
1761
|
-
const gifts = this.giftToLineItems([].concat(...campaingnProducts));
|
|
1762
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems.concat(gifts) });
|
|
1763
|
-
})), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1764
|
-
}
|
|
1765
|
-
giftToLineItems(items) {
|
|
1766
|
-
return items.map((item) => {
|
|
1767
|
-
var _a;
|
|
1768
|
-
const { brand, categories, category, id, name, price, sku, slug, stock, weight, EAN } = item;
|
|
1769
|
-
const image = ((_a = item === null || item === void 0 ? void 0 : item.miniatures) === null || _a === void 0 ? void 0 : _a.length) ? item.miniatures[0] : item.images[0];
|
|
1770
|
-
return LineItem.toInstance({
|
|
1771
|
-
brand,
|
|
1772
|
-
categories,
|
|
1773
|
-
category,
|
|
1774
|
-
id: id.toString(),
|
|
1775
|
-
name,
|
|
1776
|
-
price,
|
|
1777
|
-
sku,
|
|
1778
|
-
slug,
|
|
1779
|
-
stock,
|
|
1780
|
-
weight,
|
|
1781
|
-
EAN,
|
|
1782
|
-
image,
|
|
1783
|
-
pricePaid: 0,
|
|
1784
|
-
quantity: 1,
|
|
1785
|
-
isGift: true,
|
|
1786
|
-
});
|
|
1787
|
-
});
|
|
1788
|
-
}
|
|
1789
1633
|
}
|
|
1790
1634
|
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 });
|
|
1791
1635
|
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
|
|
@@ -2681,94 +2525,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2681
2525
|
}] }];
|
|
2682
2526
|
} });
|
|
2683
2527
|
|
|
2684
|
-
class ShippingService {
|
|
2685
|
-
constructor(http, apiUrl, homeService) {
|
|
2686
|
-
this.http = http;
|
|
2687
|
-
this.apiUrl = apiUrl;
|
|
2688
|
-
this.homeService = homeService;
|
|
2689
|
-
}
|
|
2690
|
-
getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
|
|
2691
|
-
return combineLatest([
|
|
2692
|
-
this.homeService.getHomeData(),
|
|
2693
|
-
this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
|
|
2694
|
-
]).pipe(map(([datas, shippingMethodsResponse]) => {
|
|
2695
|
-
let shippingMethods = shippingMethodsResponse.result;
|
|
2696
|
-
if (!shippingMethods.length)
|
|
2697
|
-
return [];
|
|
2698
|
-
shippingMethods = shippingMethods.map((shippingMethod) => {
|
|
2699
|
-
if (shippingMethod.ShippingCompanyName == 'Same Day EG')
|
|
2700
|
-
shippingMethod.ShippingCompanyName = 'Same Day';
|
|
2701
|
-
return shippingMethod;
|
|
2702
|
-
});
|
|
2703
|
-
const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
|
|
2704
|
-
if (this.isHolidays(datasSameDayNotAvaliable)) {
|
|
2705
|
-
shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
|
|
2706
|
-
}
|
|
2707
|
-
if (totalPrice >= 200) {
|
|
2708
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2709
|
-
if (s.serviceName !== 'Same Day')
|
|
2710
|
-
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
2711
|
-
else
|
|
2712
|
-
return s;
|
|
2713
|
-
});
|
|
2714
|
-
}
|
|
2715
|
-
if (shop == Shops.GLAMSHOP)
|
|
2716
|
-
return shippingMethods;
|
|
2717
|
-
if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
|
|
2718
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2719
|
-
if (s.serviceName == 'Same Day')
|
|
2720
|
-
return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
|
|
2721
|
-
else
|
|
2722
|
-
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
2723
|
-
});
|
|
2724
|
-
}
|
|
2725
|
-
if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
|
|
2726
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2727
|
-
return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
|
|
2728
|
-
});
|
|
2729
|
-
}
|
|
2730
|
-
return shippingMethods;
|
|
2731
|
-
}));
|
|
2732
|
-
}
|
|
2733
|
-
isFreeShippingBySubscription(shop, subscriptionPlan) {
|
|
2734
|
-
if (!subscriptionPlan)
|
|
2735
|
-
return false;
|
|
2736
|
-
if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
|
|
2737
|
-
return true;
|
|
2738
|
-
return false;
|
|
2739
|
-
}
|
|
2740
|
-
isHalfShippingBySubscription(shop, subscriptionPlan) {
|
|
2741
|
-
if (!subscriptionPlan)
|
|
2742
|
-
return false;
|
|
2743
|
-
if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
|
|
2744
|
-
return true;
|
|
2745
|
-
}
|
|
2746
|
-
return false;
|
|
2747
|
-
}
|
|
2748
|
-
isHolidays(datas) {
|
|
2749
|
-
const today = new Date();
|
|
2750
|
-
for (const key in datas) {
|
|
2751
|
-
let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
|
|
2752
|
-
let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
|
|
2753
|
-
if (start > end)
|
|
2754
|
-
end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
|
|
2755
|
-
if (today >= start && today <= end)
|
|
2756
|
-
return true;
|
|
2757
|
-
}
|
|
2758
|
-
return false;
|
|
2759
|
-
}
|
|
2760
|
-
}
|
|
2761
|
-
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 });
|
|
2762
|
-
ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
|
|
2763
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
|
|
2764
|
-
type: Injectable
|
|
2765
|
-
}], ctorParameters: function () {
|
|
2766
|
-
return [{ type: i2.HttpClient }, { type: undefined, decorators: [{
|
|
2767
|
-
type: Inject,
|
|
2768
|
-
args: [BACKEND_URL]
|
|
2769
|
-
}] }, { type: HomeShopService }];
|
|
2770
|
-
} });
|
|
2771
|
-
|
|
2772
2528
|
class AngularConnectModule {
|
|
2773
2529
|
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
2774
2530
|
return {
|
|
@@ -2809,7 +2565,6 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
|
|
|
2809
2565
|
CouponService,
|
|
2810
2566
|
HomeShopService,
|
|
2811
2567
|
OrderService,
|
|
2812
|
-
ShippingService,
|
|
2813
2568
|
WishlistService,
|
|
2814
2569
|
{
|
|
2815
2570
|
provide: UpdateUserImage,
|
|
@@ -2874,7 +2629,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2874
2629
|
CouponService,
|
|
2875
2630
|
HomeShopService,
|
|
2876
2631
|
OrderService,
|
|
2877
|
-
ShippingService,
|
|
2878
2632
|
WishlistService,
|
|
2879
2633
|
{
|
|
2880
2634
|
provide: UpdateUserImage,
|
|
@@ -2902,5 +2656,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2902
2656
|
* Generated bundle index. Do not edit.
|
|
2903
2657
|
*/
|
|
2904
2658
|
|
|
2905
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts,
|
|
2659
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, UtilHelper, WishlistService };
|
|
2906
2660
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|