@infrab4a/connect-angular 4.4.0 → 4.4.1-beta.0
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/angular-connect.module.d.ts +3 -1
- package/consts/index.d.ts +1 -0
- package/consts/persistence.const.d.ts +1 -0
- package/esm2020/angular-connect.module.mjs +4 -2
- package/esm2020/angular-firestore.module.mjs +12 -10
- package/esm2020/consts/index.mjs +2 -1
- package/esm2020/consts/persistence.const.mjs +2 -0
- package/esm2020/index.mjs +2 -1
- package/esm2020/persistence/cookie-data-persistence.mjs +22 -0
- package/esm2020/persistence/data-persistence.mjs +2 -0
- package/esm2020/persistence/index.mjs +3 -0
- package/esm2020/services/cart.service.mjs +3 -1
- package/esm2020/services/catalog/adapters/new-category-structure.adapter.mjs +6 -4
- package/esm2020/services/catalog/catalog.service.mjs +19 -10
- package/esm2020/services/checkout-subscription.service.mjs +18 -21
- package/esm2020/services/checkout.service.mjs +13 -16
- package/esm2020/services/coupon.service.mjs +34 -8
- package/fesm2015/infrab4a-connect-angular.mjs +107 -61
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +118 -61
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/package.json +2 -2
- package/persistence/cookie-data-persistence.d.ts +10 -0
- package/persistence/data-persistence.d.ts +6 -0
- package/persistence/index.d.ts +2 -0
- package/services/checkout-subscription.service.d.ts +5 -4
- package/services/checkout.service.d.ts +8 -4
- package/services/coupon.service.d.ts +6 -2
|
@@ -8,12 +8,12 @@ import * as i1 from '@angular/fire/auth';
|
|
|
8
8
|
import { Auth, provideAuth, getAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
9
9
|
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
|
|
10
10
|
import * as i1$1 from '@angular/fire/firestore';
|
|
11
|
-
import { Firestore, provideFirestore,
|
|
11
|
+
import { Firestore, provideFirestore, initializeFirestore, memoryLocalCache, docSnapshots, doc } from '@angular/fire/firestore';
|
|
12
12
|
import * as i2 from '@angular/fire/storage';
|
|
13
13
|
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
14
|
-
import { combineLatest, from, of, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
15
|
-
import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
|
|
16
14
|
import cookie from 'js-cookie';
|
|
15
|
+
import { of, from, combineLatest, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
16
|
+
import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
|
|
17
17
|
import { __decorate, __metadata } from 'tslib';
|
|
18
18
|
import { Type } from 'class-transformer';
|
|
19
19
|
import * as i1$3 from '@angular/common/http';
|
|
@@ -61,6 +61,8 @@ const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
|
|
|
61
61
|
|
|
62
62
|
const HASURA_OPTIONS = 'HASURA_OPTIONS';
|
|
63
63
|
|
|
64
|
+
const PERSISTENCE_PROVIDER = 'PERSISTENCE_PROVIDER';
|
|
65
|
+
|
|
64
66
|
class AngularFirebaseAuthModule {
|
|
65
67
|
static initializeApp(options, nameOrConfig) {
|
|
66
68
|
return {
|
|
@@ -414,12 +416,13 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
|
|
|
414
416
|
], imports: [AngularElasticSeachModule,
|
|
415
417
|
provideFirestore((injector) => {
|
|
416
418
|
const platformId = injector.get(PLATFORM_ID);
|
|
417
|
-
if (isPlatformServer(platformId))
|
|
418
|
-
return
|
|
419
|
-
|
|
420
|
-
|
|
419
|
+
if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
420
|
+
return initializeFirestore(injector.get(FirebaseApp), {
|
|
421
|
+
ignoreUndefinedProperties: true,
|
|
422
|
+
});
|
|
421
423
|
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
422
424
|
experimentalForceLongPolling: true,
|
|
425
|
+
ignoreUndefinedProperties: true,
|
|
423
426
|
localCache: memoryLocalCache(),
|
|
424
427
|
});
|
|
425
428
|
return firestore;
|
|
@@ -432,12 +435,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
432
435
|
AngularElasticSeachModule,
|
|
433
436
|
provideFirestore((injector) => {
|
|
434
437
|
const platformId = injector.get(PLATFORM_ID);
|
|
435
|
-
if (isPlatformServer(platformId))
|
|
436
|
-
return
|
|
437
|
-
|
|
438
|
-
|
|
438
|
+
if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
439
|
+
return initializeFirestore(injector.get(FirebaseApp), {
|
|
440
|
+
ignoreUndefinedProperties: true,
|
|
441
|
+
});
|
|
439
442
|
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
440
443
|
experimentalForceLongPolling: true,
|
|
444
|
+
ignoreUndefinedProperties: true,
|
|
441
445
|
localCache: memoryLocalCache(),
|
|
442
446
|
});
|
|
443
447
|
return firestore;
|
|
@@ -927,6 +931,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
927
931
|
}]
|
|
928
932
|
}] });
|
|
929
933
|
|
|
934
|
+
class CookieDataPersistence {
|
|
935
|
+
get(key) {
|
|
936
|
+
return of(cookie.get(key));
|
|
937
|
+
}
|
|
938
|
+
remove(key) {
|
|
939
|
+
return of(cookie.remove(key));
|
|
940
|
+
}
|
|
941
|
+
set(key, value) {
|
|
942
|
+
return from(cookie.set(key, value)).pipe(map(() => { }));
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
CookieDataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
946
|
+
CookieDataPersistence.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence });
|
|
947
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence, decorators: [{
|
|
948
|
+
type: Injectable
|
|
949
|
+
}] });
|
|
950
|
+
|
|
930
951
|
class AuthService {
|
|
931
952
|
constructor(angularFireAuth, userRepository) {
|
|
932
953
|
this.angularFireAuth = angularFireAuth;
|
|
@@ -1033,26 +1054,27 @@ class CouponService {
|
|
|
1033
1054
|
return of(discount);
|
|
1034
1055
|
}
|
|
1035
1056
|
async calcDiscountShopping(coupon, checkout) {
|
|
1036
|
-
let
|
|
1057
|
+
let discountInfo = null;
|
|
1037
1058
|
if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
|
|
1038
|
-
|
|
1059
|
+
discountInfo = await this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
|
|
1039
1060
|
}
|
|
1040
1061
|
else {
|
|
1041
|
-
|
|
1062
|
+
discountInfo = await this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
|
|
1042
1063
|
}
|
|
1043
|
-
return discount;
|
|
1064
|
+
return { discount: discountInfo.discount, lineItems: discountInfo.lineItems };
|
|
1044
1065
|
}
|
|
1045
1066
|
async calcDiscountByType(type, value, categories, checkout) {
|
|
1046
1067
|
let discount = 0;
|
|
1047
|
-
let
|
|
1048
|
-
const subTotal = this.calcCheckoutSubtotal(
|
|
1068
|
+
let lineItensElegibleForDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
|
|
1069
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensElegibleForDiscount, checkout.user, checkout.shop);
|
|
1049
1070
|
if (type == CouponTypes.ABSOLUTE) {
|
|
1050
1071
|
discount = value > subTotal ? subTotal : value;
|
|
1051
1072
|
}
|
|
1052
1073
|
else {
|
|
1053
1074
|
discount = subTotal * (value / 100);
|
|
1054
1075
|
}
|
|
1055
|
-
|
|
1076
|
+
const lineItems = this.calcLineItenDiscount(type, lineItensElegibleForDiscount, value, checkout.subTotalPrice);
|
|
1077
|
+
return { discount, lineItems };
|
|
1056
1078
|
}
|
|
1057
1079
|
async hasMinSubTotal(coupon, checkout) {
|
|
1058
1080
|
if (!coupon.minSubTotalValue)
|
|
@@ -1164,6 +1186,31 @@ class CouponService {
|
|
|
1164
1186
|
}
|
|
1165
1187
|
return couponUseLimits;
|
|
1166
1188
|
}
|
|
1189
|
+
calcLineItenDiscount(type, lineItems, couponDiscount, subTotal) {
|
|
1190
|
+
let lineItemsDiscount = [];
|
|
1191
|
+
if (type == CouponTypes.ABSOLUTE) {
|
|
1192
|
+
lineItemsDiscount = lineItems.map((item) => {
|
|
1193
|
+
const totalItemPercentage = ((item.quantity * item.pricePaid) / subTotal) * couponDiscount;
|
|
1194
|
+
const discountItem = item.pricePaid - item.pricePaid * totalItemPercentage;
|
|
1195
|
+
return {
|
|
1196
|
+
...item,
|
|
1197
|
+
discount: discountItem,
|
|
1198
|
+
pricePaid: item.pricePaid - discountItem,
|
|
1199
|
+
};
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
else {
|
|
1203
|
+
lineItemsDiscount = lineItems.map((item) => {
|
|
1204
|
+
const discountItem = item.pricePaid * (couponDiscount / 100);
|
|
1205
|
+
return {
|
|
1206
|
+
...item,
|
|
1207
|
+
discount: discountItem,
|
|
1208
|
+
pricePaid: item.pricePaid - discountItem,
|
|
1209
|
+
};
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
return lineItemsDiscount;
|
|
1213
|
+
}
|
|
1167
1214
|
}
|
|
1168
1215
|
CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1169
1216
|
CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
|
|
@@ -1187,18 +1234,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
1187
1234
|
}] }]; } });
|
|
1188
1235
|
|
|
1189
1236
|
class CheckoutService {
|
|
1190
|
-
constructor(couponService, checkoutRepository,
|
|
1237
|
+
constructor(couponService, checkoutRepository, userRepository, defaultShop, dataPersistence) {
|
|
1191
1238
|
this.couponService = couponService;
|
|
1192
1239
|
this.checkoutRepository = checkoutRepository;
|
|
1193
|
-
this.orderRepository = orderRepository;
|
|
1194
1240
|
this.userRepository = userRepository;
|
|
1195
1241
|
this.defaultShop = defaultShop;
|
|
1242
|
+
this.dataPersistence = dataPersistence;
|
|
1196
1243
|
}
|
|
1197
1244
|
getCheckout(checkoutData) {
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
return from(this.createCheckout(checkoutData));
|
|
1245
|
+
return this.dataPersistence
|
|
1246
|
+
.get('checkoutId')
|
|
1247
|
+
.pipe(concatMap((id) => (!isNil(id) ? this.checkoutRepository.get({ id }) : this.createCheckout(checkoutData))));
|
|
1202
1248
|
}
|
|
1203
1249
|
getUserByCheckout(checkoutId) {
|
|
1204
1250
|
return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => checkout?.user?.id ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id }))), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
|
|
@@ -1210,8 +1256,7 @@ class CheckoutService {
|
|
|
1210
1256
|
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1211
1257
|
}
|
|
1212
1258
|
clearCheckoutFromSession() {
|
|
1213
|
-
|
|
1214
|
-
return of();
|
|
1259
|
+
return this.dataPersistence.remove('checkoutId');
|
|
1215
1260
|
}
|
|
1216
1261
|
calcDiscount(coupon) {
|
|
1217
1262
|
return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
|
|
@@ -1225,26 +1270,26 @@ class CheckoutService {
|
|
|
1225
1270
|
...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1226
1271
|
shop: checkoutData?.shop || this.defaultShop,
|
|
1227
1272
|
});
|
|
1228
|
-
|
|
1273
|
+
await this.dataPersistence.set('checkoutId', checkout.id).toPromise();
|
|
1229
1274
|
return checkout;
|
|
1230
1275
|
}
|
|
1231
1276
|
}
|
|
1232
|
-
CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: '
|
|
1277
|
+
CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }, { token: PERSISTENCE_PROVIDER }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1233
1278
|
CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService });
|
|
1234
1279
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, decorators: [{
|
|
1235
1280
|
type: Injectable
|
|
1236
1281
|
}], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
|
|
1237
1282
|
type: Inject,
|
|
1238
1283
|
args: ['CheckoutRepository']
|
|
1239
|
-
}] }, { type: undefined, decorators: [{
|
|
1240
|
-
type: Inject,
|
|
1241
|
-
args: ['OrderRepository']
|
|
1242
1284
|
}] }, { type: undefined, decorators: [{
|
|
1243
1285
|
type: Inject,
|
|
1244
1286
|
args: ['UserRepository']
|
|
1245
1287
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
1246
1288
|
type: Inject,
|
|
1247
1289
|
args: [DEFAULT_SHOP]
|
|
1290
|
+
}] }, { type: undefined, decorators: [{
|
|
1291
|
+
type: Inject,
|
|
1292
|
+
args: [PERSISTENCE_PROVIDER]
|
|
1248
1293
|
}] }]; } });
|
|
1249
1294
|
|
|
1250
1295
|
class CartService {
|
|
@@ -1306,6 +1351,8 @@ class CartService {
|
|
|
1306
1351
|
weight: weight ?? product.weight,
|
|
1307
1352
|
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1308
1353
|
pricePaid,
|
|
1354
|
+
pricePaidOriginal: pricePaid,
|
|
1355
|
+
discount: 0,
|
|
1309
1356
|
categories: product.categories ?? [],
|
|
1310
1357
|
isGift: isGift ?? null,
|
|
1311
1358
|
costPrice: product.costPrice ?? 0,
|
|
@@ -1541,9 +1588,11 @@ class NewCategoryStructureAdapter {
|
|
|
1541
1588
|
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1542
1589
|
}
|
|
1543
1590
|
async getCategory(category) {
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1591
|
+
const collectionCategory = category.isCollection ||
|
|
1592
|
+
(isNil(category.isCollection) && !category.products?.length) ||
|
|
1593
|
+
category.isWishlist ||
|
|
1594
|
+
category.brandCategory;
|
|
1595
|
+
return collectionCategory ? this.categoryRepository.get({ id: category.id }) : category;
|
|
1547
1596
|
}
|
|
1548
1597
|
}
|
|
1549
1598
|
NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -1608,17 +1657,22 @@ class CatalogService {
|
|
|
1608
1657
|
if (!sort || sort === 'most-relevant')
|
|
1609
1658
|
return {};
|
|
1610
1659
|
if (sort === 'best-sellers')
|
|
1611
|
-
return {
|
|
1660
|
+
return {
|
|
1661
|
+
shoppingCount: 'desc',
|
|
1662
|
+
rate: 'desc',
|
|
1663
|
+
stock: 'desc',
|
|
1664
|
+
name: 'asc',
|
|
1665
|
+
};
|
|
1612
1666
|
if (sort === 'biggest-price')
|
|
1613
|
-
return { subscriberPrice: 'desc' };
|
|
1667
|
+
return { subscriberPrice: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1614
1668
|
if (sort === 'lowest-price')
|
|
1615
|
-
return { subscriberPrice: 'asc' };
|
|
1669
|
+
return { subscriberPrice: 'asc', rate: 'desc', shoppingCount: 'desc' };
|
|
1616
1670
|
if (sort === 'best-rating')
|
|
1617
|
-
return { rate: 'desc' };
|
|
1671
|
+
return { rate: 'desc', shoppingCount: 'desc', stock: 'desc', name: 'asc' };
|
|
1618
1672
|
if (sort === 'news')
|
|
1619
1673
|
return { createdAt: 'desc' };
|
|
1620
1674
|
if (sort === 'biggest-discount')
|
|
1621
|
-
return { subscriberDiscountPercentage: 'desc' };
|
|
1675
|
+
return { subscriberDiscountPercentage: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1622
1676
|
};
|
|
1623
1677
|
this.buildLimitQuery = (options) => {
|
|
1624
1678
|
const limit = options?.perPage || 20;
|
|
@@ -1658,9 +1712,13 @@ class CatalogService {
|
|
|
1658
1712
|
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1659
1713
|
}
|
|
1660
1714
|
if (this.hasCategory(options) && options.sort === 'most-relevant') {
|
|
1661
|
-
const productsIds =
|
|
1662
|
-
|
|
1663
|
-
:
|
|
1715
|
+
const productsIds = await this.productRepository
|
|
1716
|
+
.find({
|
|
1717
|
+
filters: {
|
|
1718
|
+
...(await this.buildMainFilter(options)),
|
|
1719
|
+
},
|
|
1720
|
+
})
|
|
1721
|
+
.then((products) => products.data.map((product) => product.id));
|
|
1664
1722
|
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1665
1723
|
}
|
|
1666
1724
|
const repoParams = {
|
|
@@ -1927,28 +1985,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
1927
1985
|
}] }, { type: i1$2.ProductsIndex }]; } });
|
|
1928
1986
|
|
|
1929
1987
|
class CheckoutSubscriptionService {
|
|
1930
|
-
constructor(checkoutSubscriptionRepository,
|
|
1988
|
+
constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
|
|
1931
1989
|
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
1932
|
-
this.
|
|
1990
|
+
this.dataPersistence = dataPersistence;
|
|
1933
1991
|
this.couponService = couponService;
|
|
1934
1992
|
}
|
|
1935
1993
|
getCheckoutSubscription(checkoutData) {
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
return from(this.createCheckoutSubscription(checkoutData));
|
|
1940
|
-
}
|
|
1941
|
-
async createCheckoutSubscription(checkoutData) {
|
|
1942
|
-
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
1943
|
-
createdAt: new Date(),
|
|
1944
|
-
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1945
|
-
});
|
|
1946
|
-
cookie.set('checkoutSubscriptionId', checkout.id);
|
|
1947
|
-
return checkout;
|
|
1994
|
+
return this.dataPersistence
|
|
1995
|
+
.get('checkoutSubscriptionId')
|
|
1996
|
+
.pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
|
|
1948
1997
|
}
|
|
1949
1998
|
clearCheckoutSubscriptionFromSession() {
|
|
1950
|
-
|
|
1951
|
-
return of();
|
|
1999
|
+
return this.dataPersistence.remove('checkoutSubscriptionId');
|
|
1952
2000
|
}
|
|
1953
2001
|
checkCoupon(nickname, userEmail) {
|
|
1954
2002
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
@@ -1958,8 +2006,16 @@ class CheckoutSubscriptionService {
|
|
|
1958
2006
|
calcDiscountSubscription(coupon) {
|
|
1959
2007
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
1960
2008
|
}
|
|
2009
|
+
async createCheckoutSubscription(checkoutData) {
|
|
2010
|
+
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2011
|
+
createdAt: new Date(),
|
|
2012
|
+
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2013
|
+
});
|
|
2014
|
+
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2015
|
+
return checkout;
|
|
2016
|
+
}
|
|
1961
2017
|
}
|
|
1962
|
-
CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token:
|
|
2018
|
+
CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: PERSISTENCE_PROVIDER }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1963
2019
|
CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
|
|
1964
2020
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
1965
2021
|
type: Injectable
|
|
@@ -1968,7 +2024,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
1968
2024
|
args: ['CheckoutSubscriptionRepository']
|
|
1969
2025
|
}] }, { type: undefined, decorators: [{
|
|
1970
2026
|
type: Inject,
|
|
1971
|
-
args: [
|
|
2027
|
+
args: [PERSISTENCE_PROVIDER]
|
|
1972
2028
|
}] }, { type: CouponService }]; } });
|
|
1973
2029
|
|
|
1974
2030
|
class UtilHelper {
|
|
@@ -2226,6 +2282,7 @@ class AngularConnectModule {
|
|
|
2226
2282
|
? OldCategoryStructureAdapter
|
|
2227
2283
|
: NewCategoryStructureAdapter,
|
|
2228
2284
|
},
|
|
2285
|
+
{ provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
|
|
2229
2286
|
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2230
2287
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
|
|
2231
2288
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
@@ -2319,5 +2376,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2319
2376
|
* Generated bundle index. Do not edit.
|
|
2320
2377
|
*/
|
|
2321
2378
|
|
|
2322
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
|
|
2379
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
|
|
2323
2380
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|