@infrab4a/connect-angular 3.7.6-beta.1 → 3.7.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/angular-connect.module.d.ts +19 -19
- package/angular-elastic-search.module.d.ts +9 -9
- package/angular-firebase-auth.module.d.ts +10 -10
- package/angular-firestore.module.d.ts +15 -15
- package/angular-hasura-graphql.module.d.ts +16 -16
- package/bundles/infrab4a-connect-angular.umd.js +2144 -1990
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/consts/backend-url.const.d.ts +1 -1
- package/consts/default-shop.const.d.ts +1 -1
- package/consts/es-config.const.d.ts +1 -1
- package/consts/hasura-options.const.d.ts +1 -1
- package/consts/index.d.ts +4 -4
- package/esm2015/angular-connect.module.js +52 -52
- package/esm2015/angular-elastic-search.module.js +38 -38
- package/esm2015/angular-firebase-auth.module.js +113 -113
- package/esm2015/angular-firestore.module.js +394 -394
- package/esm2015/angular-hasura-graphql.module.js +156 -156
- package/esm2015/consts/backend-url.const.js +1 -1
- package/esm2015/consts/default-shop.const.js +2 -2
- package/esm2015/consts/es-config.const.js +2 -2
- package/esm2015/consts/hasura-options.const.js +2 -2
- package/esm2015/consts/index.js +5 -5
- package/esm2015/index.js +6 -6
- package/esm2015/infrab4a-connect-angular.js +4 -4
- package/esm2015/services/auth.service.js +42 -42
- package/esm2015/services/cart.service.js +258 -172
- package/esm2015/services/checkout-subscription.service.js +53 -53
- package/esm2015/services/checkout.service.js +75 -75
- package/esm2015/services/coupon.service.js +249 -249
- package/esm2015/services/errors/group-invalid-coupon.error.js +8 -8
- package/esm2015/services/errors/index.js +3 -3
- package/esm2015/services/errors/invalid-coupon.error.js +8 -8
- package/esm2015/services/home-shop.service.js +116 -116
- package/esm2015/services/index.js +9 -9
- package/esm2015/services/order.service.js +32 -32
- package/esm2015/services/shipping.service.js +98 -98
- package/esm2015/services/types/index.js +3 -3
- package/esm2015/services/types/required-checkout-data.type.js +2 -2
- package/esm2015/services/types/required-checkout-subscription-data.type.js +2 -2
- package/esm2015/services/types/shipping-methods.type.js +2 -2
- package/fesm2015/infrab4a-connect-angular.js +1565 -1479
- package/fesm2015/infrab4a-connect-angular.js.map +1 -1
- package/index.d.ts +5 -5
- package/infrab4a-connect-angular.d.ts +5 -5
- package/package.json +1 -1
- package/services/auth.service.d.ts +19 -19
- package/services/cart.service.d.ts +40 -37
- package/services/checkout-subscription.service.d.ts +18 -18
- package/services/checkout.service.d.ts +23 -23
- package/services/coupon.service.d.ts +25 -25
- package/services/errors/group-invalid-coupon.error.d.ts +6 -6
- package/services/errors/index.d.ts +2 -2
- package/services/errors/invalid-coupon.error.d.ts +5 -5
- package/services/home-shop.service.d.ts +25 -25
- package/services/index.d.ts +8 -8
- package/services/order.service.d.ts +13 -13
- package/services/shipping.service.d.ts +19 -19
- package/services/types/index.d.ts +2 -2
- package/services/types/required-checkout-data.type.d.ts +2 -2
- package/services/types/required-checkout-subscription-data.type.d.ts +2 -2
- package/services/types/shipping-methods.type.d.ts +12 -12
|
@@ -5,49 +5,49 @@ import { AngularFireAuth } from '@angular/fire/auth';
|
|
|
5
5
|
import { of, combineLatest, from, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
6
6
|
import { catchError, map, mergeMap, concatMap, tap } from 'rxjs/operators';
|
|
7
7
|
import { __awaiter } from 'tslib';
|
|
8
|
-
import * as
|
|
8
|
+
import * as i3 from '@infrab4a/connect';
|
|
9
9
|
import { Coupon, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, CheckoutSubscription, Category, Product, RequiredArgumentError, add, Order, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository } from '@infrab4a/connect';
|
|
10
10
|
import cookie from 'js-cookie';
|
|
11
11
|
import { CustomError } from 'ts-custom-error';
|
|
12
|
-
import * as i1$
|
|
12
|
+
import * as i1$1 from '@angular/fire/firestore';
|
|
13
13
|
import { AngularFirestore } from '@angular/fire/firestore';
|
|
14
|
-
import * as i1$
|
|
14
|
+
import * as i1$2 from '@angular/common/http';
|
|
15
15
|
import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, AngularFireModule } from '@angular/fire';
|
|
16
16
|
|
|
17
|
-
class AuthService {
|
|
18
|
-
constructor(angularFireAuth, userRepository) {
|
|
19
|
-
this.angularFireAuth = angularFireAuth;
|
|
20
|
-
this.userRepository = userRepository;
|
|
21
|
-
}
|
|
22
|
-
getAuthstate() {
|
|
23
|
-
const observables = [
|
|
24
|
-
this.angularFireAuth.authState.pipe(catchError(() => of(null))),
|
|
25
|
-
this.getUser().pipe(catchError(() => of(null))),
|
|
26
|
-
];
|
|
27
|
-
return combineLatest(observables).pipe(map(([fireUser, user]) => {
|
|
28
|
-
return {
|
|
29
|
-
user,
|
|
30
|
-
isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
|
|
31
|
-
};
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
34
|
-
getUser() {
|
|
35
|
-
return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? this.userRepository.get({ id }) : of(null))));
|
|
36
|
-
}
|
|
37
|
-
getTokenId() {
|
|
38
|
-
return this.angularFireAuth.idToken;
|
|
39
|
-
}
|
|
40
|
-
getFireUser() {
|
|
41
|
-
return this.angularFireAuth.user.pipe(catchError(() => of(null)));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, deps: [{ token: i1.AngularFireAuth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
45
|
-
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService });
|
|
46
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, decorators: [{
|
|
47
|
-
type: Injectable
|
|
48
|
-
}], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
|
|
49
|
-
type: Inject,
|
|
50
|
-
args: ['UserRepository']
|
|
17
|
+
class AuthService {
|
|
18
|
+
constructor(angularFireAuth, userRepository) {
|
|
19
|
+
this.angularFireAuth = angularFireAuth;
|
|
20
|
+
this.userRepository = userRepository;
|
|
21
|
+
}
|
|
22
|
+
getAuthstate() {
|
|
23
|
+
const observables = [
|
|
24
|
+
this.angularFireAuth.authState.pipe(catchError(() => of(null))),
|
|
25
|
+
this.getUser().pipe(catchError(() => of(null))),
|
|
26
|
+
];
|
|
27
|
+
return combineLatest(observables).pipe(map(([fireUser, user]) => {
|
|
28
|
+
return {
|
|
29
|
+
user,
|
|
30
|
+
isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
|
|
31
|
+
};
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
getUser() {
|
|
35
|
+
return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? this.userRepository.get({ id }) : of(null))));
|
|
36
|
+
}
|
|
37
|
+
getTokenId() {
|
|
38
|
+
return this.angularFireAuth.idToken;
|
|
39
|
+
}
|
|
40
|
+
getFireUser() {
|
|
41
|
+
return this.angularFireAuth.user.pipe(catchError(() => of(null)));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, deps: [{ token: i1.AngularFireAuth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
45
|
+
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService });
|
|
46
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, decorators: [{
|
|
47
|
+
type: Injectable
|
|
48
|
+
}], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
|
|
49
|
+
type: Inject,
|
|
50
|
+
args: ['UserRepository']
|
|
51
51
|
}] }]; } });
|
|
52
52
|
|
|
53
53
|
const BACKEND_URL = 'BACKEND_URL';
|
|
@@ -58,1476 +58,1562 @@ const ES_CONFIG = 'ES_CONFIG';
|
|
|
58
58
|
|
|
59
59
|
const HASURA_OPTIONS = 'HASURA_OPTIONS';
|
|
60
60
|
|
|
61
|
-
class InvalidCouponError extends CustomError {
|
|
62
|
-
constructor(message) {
|
|
63
|
-
super(message);
|
|
64
|
-
this.message = message;
|
|
65
|
-
}
|
|
61
|
+
class InvalidCouponError extends CustomError {
|
|
62
|
+
constructor(message) {
|
|
63
|
+
super(message);
|
|
64
|
+
this.message = message;
|
|
65
|
+
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
class GroupInvalidCouponError extends CustomError {
|
|
69
|
-
constructor(errors) {
|
|
70
|
-
super('Many coupon errors throw');
|
|
71
|
-
this.errors = errors;
|
|
72
|
-
}
|
|
68
|
+
class GroupInvalidCouponError extends CustomError {
|
|
69
|
+
constructor(errors) {
|
|
70
|
+
super('Many coupon errors throw');
|
|
71
|
+
this.errors = errors;
|
|
72
|
+
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
class CouponService {
|
|
76
|
-
constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
|
|
77
|
-
this.couponRepository = couponRepository;
|
|
78
|
-
this.defaultShop = defaultShop;
|
|
79
|
-
this.orderRepository = orderRepository;
|
|
80
|
-
this.categoryRepository = categoryRepository;
|
|
81
|
-
this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
|
|
82
|
-
this.separateValidCoupons = (coupons, userEmail) => coupons
|
|
83
|
-
.map((coupon) => {
|
|
84
|
-
try {
|
|
85
|
-
if (!(coupon instanceof Coupon))
|
|
86
|
-
throw new InvalidCouponError('Cupom inválido.');
|
|
87
|
-
if (this.isValidCoupon(coupon, userEmail))
|
|
88
|
-
return coupon;
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
return error;
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
.reduce((current, coupon) => (Object.assign(Object.assign({}, current), (coupon instanceof Coupon
|
|
95
|
-
? { valids: [...current.valids, coupon] }
|
|
96
|
-
: { invalids: [...current.invalids, coupon] }))), {
|
|
97
|
-
valids: [],
|
|
98
|
-
invalids: [],
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
checkCoupon(nickname, userEmail, checkoutType, plan, checkout, isSubscription) {
|
|
102
|
-
return from(this.couponRepository.find({
|
|
103
|
-
filters: {
|
|
104
|
-
nickname: { operator: Where.EQUALS, value: nickname },
|
|
105
|
-
active: { operator: Where.EQUALS, value: true },
|
|
106
|
-
},
|
|
107
|
-
})).pipe(concatMap((coupons) => this.checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription)), concatMap((coupon) => this.checkCouponUseAndLimit(coupon, userEmail, checkout)), map((coupon) => this.isValidCoupon(coupon, userEmail)), map((coupon) => coupon));
|
|
108
|
-
}
|
|
109
|
-
checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription) {
|
|
110
|
-
// Caso não ache nenhum cupom, retorna erro
|
|
111
|
-
if (coupons.count < 1) {
|
|
112
|
-
return throwError('Cupom inválido.');
|
|
113
|
-
}
|
|
114
|
-
// Get Primeiro Cupom (o find do repository retorna um array)
|
|
115
|
-
const coupon = coupons.data.shift();
|
|
116
|
-
// Verifica se o cupom é aplicavel na loja
|
|
117
|
-
const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
|
|
118
|
-
// Cupon não aplicavel a loja retorna erro
|
|
119
|
-
if (!isInShop)
|
|
120
|
-
return throwError('Cupom inválido para loja.');
|
|
121
|
-
// Verifica se o coupon é aplicado no checkout que está sendo realizado
|
|
122
|
-
const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
|
|
123
|
-
// Cupon não aplicavel ao checkout retorna erro
|
|
124
|
-
if (!isCheckoutType)
|
|
125
|
-
return throwError('Cupom inválido. Erro de checkout.');
|
|
126
|
-
// Verifica se o cupom é ou pode ser aplicado para subscription
|
|
127
|
-
if (checkoutType === CheckoutTypes.ALL || checkoutType === CheckoutTypes.SUBSCRIPTION) {
|
|
128
|
-
// Se o cupom tiver um plano associado, verifica se é o mesmo plano do checkout da assinatura
|
|
129
|
-
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
|
|
130
|
-
return throwError('Cupom inválido para sua assinatura.');
|
|
131
|
-
}
|
|
132
|
-
if (isSubscription)
|
|
133
|
-
return of(coupon);
|
|
134
|
-
// Verifica se possui o valor minimo de compra para utilização do cupom
|
|
135
|
-
const hasMinSubTotal = this.hasMinSubTotal(coupon, checkout);
|
|
136
|
-
// Se não tem valor mínimo atingido, retorna erro
|
|
137
|
-
if (!hasMinSubTotal)
|
|
138
|
-
return throwError(`Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`);
|
|
139
|
-
return of(coupon);
|
|
140
|
-
}
|
|
141
|
-
isValidCoupon(coupon, userEmail) {
|
|
142
|
-
// Verifica a data de inicio de validade do cupom
|
|
143
|
-
if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) > new Date())
|
|
144
|
-
throw new InvalidCouponError('Cupom ainda não liberado.');
|
|
145
|
-
// Verifica a data de validade do cupom
|
|
146
|
-
if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
|
|
147
|
-
throw new InvalidCouponError('Cupom expirado.');
|
|
148
|
-
return coupon;
|
|
149
|
-
}
|
|
150
|
-
checkCouponUseAndLimit(coupon, userEmail, checkout) {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
const orders = yield this.orderRepository.find({
|
|
153
|
-
filters: {
|
|
154
|
-
coupon: { id: coupon.id },
|
|
155
|
-
payment: { status: 'paid' },
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
// orders que usuario ja fez com o cupom
|
|
159
|
-
const ordersUserCoupon = orders.data.filter((o) => o.user.email == userEmail);
|
|
160
|
-
// Verifica o limite de uso de cupom por usuario
|
|
161
|
-
if (coupon.useLimitPerUser && ordersUserCoupon.length)
|
|
162
|
-
throw new InvalidCouponError('Limite de uso por usuário atingido.');
|
|
163
|
-
// Verifica o limite de uso geral por usuario
|
|
164
|
-
if (coupon.useLimit && orders.data.length >= coupon.useLimit)
|
|
165
|
-
throw new InvalidCouponError('Limite de uso atingido.');
|
|
166
|
-
const validUser = this.userValidationAndSubscriptionStatus(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
|
|
167
|
-
if (!validUser)
|
|
168
|
-
throw new InvalidCouponError('Usuário não elegível.');
|
|
169
|
-
const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
|
|
170
|
-
if (!hasProductCategories)
|
|
171
|
-
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
172
|
-
return coupon;
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
calcDiscountSubscription(coupon, checkout) {
|
|
176
|
-
//
|
|
177
|
-
let discount = 0;
|
|
178
|
-
if (coupon.type === CouponTypes.ABSOLUTE)
|
|
179
|
-
discount = coupon.discount;
|
|
180
|
-
else if (coupon.type === CouponTypes.PERCENTAGE)
|
|
181
|
-
discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount / 100);
|
|
182
|
-
return of(discount);
|
|
183
|
-
}
|
|
184
|
-
calcDiscountShopping(coupon, checkout) {
|
|
185
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
-
let discount = 0;
|
|
187
|
-
switch (coupon.type) {
|
|
188
|
-
case CouponTypes.ABSOLUTE: {
|
|
189
|
-
discount = coupon.discount;
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
case CouponTypes.PERCENTAGE: {
|
|
193
|
-
discount = yield this.calcShoppingPercentageDiscount(coupon, checkout);
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
return discount;
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
calcShoppingPercentageDiscount(coupon, checkout) {
|
|
201
|
-
var _a;
|
|
202
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
-
let discount = 0;
|
|
204
|
-
const shop = checkout.shop;
|
|
205
|
-
let lineItensDiscount = [];
|
|
206
|
-
const couponCategories = yield this.getCouponCategoriesId(coupon);
|
|
207
|
-
if (coupon.productsCategories && coupon.productsCategories.length) {
|
|
208
|
-
lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
|
|
209
|
-
var _a;
|
|
210
|
-
if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
|
|
211
|
-
return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
|
|
212
|
-
}
|
|
213
|
-
return true;
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
lineItensDiscount = checkout.lineItems;
|
|
218
|
-
}
|
|
219
|
-
const subTotal = lineItensDiscount.reduce((acc, curr) => {
|
|
220
|
-
var _a, _b, _c;
|
|
221
|
-
return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
|
|
222
|
-
? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
|
|
223
|
-
: acc + curr.pricePaid * curr.quantity;
|
|
224
|
-
}, 0) || 0;
|
|
225
|
-
discount = subTotal * (coupon.discount / 100);
|
|
226
|
-
return discount;
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
hasMinSubTotal(coupon, checkout) {
|
|
230
|
-
var _a;
|
|
231
|
-
if (!coupon.minSubTotalValue)
|
|
232
|
-
return true;
|
|
233
|
-
const shop = checkout.shop;
|
|
234
|
-
let subTotal = ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.reduce((acc, curr) => {
|
|
235
|
-
var _a, _b, _c;
|
|
236
|
-
return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
|
|
237
|
-
? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
|
|
238
|
-
: acc + curr.pricePaid * curr.quantity;
|
|
239
|
-
}, 0)) || 0;
|
|
240
|
-
if (coupon.minSubTotalValue <= subTotal)
|
|
241
|
-
return true;
|
|
242
|
-
return false;
|
|
243
|
-
}
|
|
244
|
-
hasProductCategories(coupon, checkout) {
|
|
245
|
-
var _a;
|
|
246
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
247
|
-
if (!coupon.productsCategories || !coupon.productsCategories.length) {
|
|
248
|
-
return true;
|
|
249
|
-
}
|
|
250
|
-
const couponCategories = yield this.getCouponCategoriesId(coupon);
|
|
251
|
-
const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
|
|
252
|
-
var _a;
|
|
253
|
-
if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
254
|
-
return true;
|
|
255
|
-
return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
|
|
256
|
-
});
|
|
257
|
-
return hasCategories.length ? true : false;
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
userValidationAndSubscriptionStatus(coupon, user) {
|
|
261
|
-
if (coupon.exclusivityType === Exclusivities.ALL_USERS)
|
|
262
|
-
return true;
|
|
263
|
-
if (!user)
|
|
264
|
-
return true;
|
|
265
|
-
// Verifica se o email do usuário é coorporativo
|
|
266
|
-
if (!this.emailIsFromCollaborator(user.email) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
|
|
267
|
-
throw new InvalidCouponError('Você não é colaborador.');
|
|
268
|
-
// Verifica se o email do usuário é associado ao cupom de uso por usuario
|
|
269
|
-
if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== user.email)
|
|
270
|
-
throw new InvalidCouponError('Cupom não é válido para este usuário.');
|
|
271
|
-
switch (coupon.exclusivityType) {
|
|
272
|
-
case Exclusivities.ACTIVE_SUBSCRIBER:
|
|
273
|
-
return user.isSubscriber ? true : false;
|
|
274
|
-
case Exclusivities.INACTIVE_SUBSCRIBER:
|
|
275
|
-
return user.isSubscriber ? false : true;
|
|
276
|
-
case Exclusivities.NON_SUBSCRIBER:
|
|
277
|
-
return user.isSubscriber ? false : true;
|
|
278
|
-
}
|
|
279
|
-
return true;
|
|
280
|
-
}
|
|
281
|
-
getCouponCategoriesId(coupon) {
|
|
282
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
-
let couponCategories = [];
|
|
284
|
-
for (let index = 0; index < coupon.productsCategories.length; index++) {
|
|
285
|
-
let c = yield this.categoryRepository.get({
|
|
286
|
-
id: coupon.productsCategories[index],
|
|
287
|
-
});
|
|
288
|
-
couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
|
|
289
|
-
}
|
|
290
|
-
return couponCategories;
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
295
|
-
CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
|
|
296
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
|
|
297
|
-
type: Injectable,
|
|
298
|
-
args: [{
|
|
299
|
-
providedIn: 'root',
|
|
300
|
-
}]
|
|
301
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
302
|
-
type: Inject,
|
|
303
|
-
args: ['CouponRepository']
|
|
304
|
-
}] }, { type:
|
|
305
|
-
type: Inject,
|
|
306
|
-
args: [DEFAULT_SHOP]
|
|
307
|
-
}] }, { type: undefined, decorators: [{
|
|
308
|
-
type: Inject,
|
|
309
|
-
args: ['OrderRepository']
|
|
310
|
-
}] }, { type: undefined, decorators: [{
|
|
311
|
-
type: Inject,
|
|
312
|
-
args: ['CategoryRepository']
|
|
75
|
+
class CouponService {
|
|
76
|
+
constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
|
|
77
|
+
this.couponRepository = couponRepository;
|
|
78
|
+
this.defaultShop = defaultShop;
|
|
79
|
+
this.orderRepository = orderRepository;
|
|
80
|
+
this.categoryRepository = categoryRepository;
|
|
81
|
+
this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
|
|
82
|
+
this.separateValidCoupons = (coupons, userEmail) => coupons
|
|
83
|
+
.map((coupon) => {
|
|
84
|
+
try {
|
|
85
|
+
if (!(coupon instanceof Coupon))
|
|
86
|
+
throw new InvalidCouponError('Cupom inválido.');
|
|
87
|
+
if (this.isValidCoupon(coupon, userEmail))
|
|
88
|
+
return coupon;
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
return error;
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
.reduce((current, coupon) => (Object.assign(Object.assign({}, current), (coupon instanceof Coupon
|
|
95
|
+
? { valids: [...current.valids, coupon] }
|
|
96
|
+
: { invalids: [...current.invalids, coupon] }))), {
|
|
97
|
+
valids: [],
|
|
98
|
+
invalids: [],
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
checkCoupon(nickname, userEmail, checkoutType, plan, checkout, isSubscription) {
|
|
102
|
+
return from(this.couponRepository.find({
|
|
103
|
+
filters: {
|
|
104
|
+
nickname: { operator: Where.EQUALS, value: nickname },
|
|
105
|
+
active: { operator: Where.EQUALS, value: true },
|
|
106
|
+
},
|
|
107
|
+
})).pipe(concatMap((coupons) => this.checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription)), concatMap((coupon) => this.checkCouponUseAndLimit(coupon, userEmail, checkout)), map((coupon) => this.isValidCoupon(coupon, userEmail)), map((coupon) => coupon));
|
|
108
|
+
}
|
|
109
|
+
checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription) {
|
|
110
|
+
// Caso não ache nenhum cupom, retorna erro
|
|
111
|
+
if (coupons.count < 1) {
|
|
112
|
+
return throwError('Cupom inválido.');
|
|
113
|
+
}
|
|
114
|
+
// Get Primeiro Cupom (o find do repository retorna um array)
|
|
115
|
+
const coupon = coupons.data.shift();
|
|
116
|
+
// Verifica se o cupom é aplicavel na loja
|
|
117
|
+
const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
|
|
118
|
+
// Cupon não aplicavel a loja retorna erro
|
|
119
|
+
if (!isInShop)
|
|
120
|
+
return throwError('Cupom inválido para loja.');
|
|
121
|
+
// Verifica se o coupon é aplicado no checkout que está sendo realizado
|
|
122
|
+
const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
|
|
123
|
+
// Cupon não aplicavel ao checkout retorna erro
|
|
124
|
+
if (!isCheckoutType)
|
|
125
|
+
return throwError('Cupom inválido. Erro de checkout.');
|
|
126
|
+
// Verifica se o cupom é ou pode ser aplicado para subscription
|
|
127
|
+
if (checkoutType === CheckoutTypes.ALL || checkoutType === CheckoutTypes.SUBSCRIPTION) {
|
|
128
|
+
// Se o cupom tiver um plano associado, verifica se é o mesmo plano do checkout da assinatura
|
|
129
|
+
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
|
|
130
|
+
return throwError('Cupom inválido para sua assinatura.');
|
|
131
|
+
}
|
|
132
|
+
if (isSubscription)
|
|
133
|
+
return of(coupon);
|
|
134
|
+
// Verifica se possui o valor minimo de compra para utilização do cupom
|
|
135
|
+
const hasMinSubTotal = this.hasMinSubTotal(coupon, checkout);
|
|
136
|
+
// Se não tem valor mínimo atingido, retorna erro
|
|
137
|
+
if (!hasMinSubTotal)
|
|
138
|
+
return throwError(`Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`);
|
|
139
|
+
return of(coupon);
|
|
140
|
+
}
|
|
141
|
+
isValidCoupon(coupon, userEmail) {
|
|
142
|
+
// Verifica a data de inicio de validade do cupom
|
|
143
|
+
if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) > new Date())
|
|
144
|
+
throw new InvalidCouponError('Cupom ainda não liberado.');
|
|
145
|
+
// Verifica a data de validade do cupom
|
|
146
|
+
if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
|
|
147
|
+
throw new InvalidCouponError('Cupom expirado.');
|
|
148
|
+
return coupon;
|
|
149
|
+
}
|
|
150
|
+
checkCouponUseAndLimit(coupon, userEmail, checkout) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
const orders = yield this.orderRepository.find({
|
|
153
|
+
filters: {
|
|
154
|
+
coupon: { id: coupon.id },
|
|
155
|
+
payment: { status: 'paid' },
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
// orders que usuario ja fez com o cupom
|
|
159
|
+
const ordersUserCoupon = orders.data.filter((o) => o.user.email == userEmail);
|
|
160
|
+
// Verifica o limite de uso de cupom por usuario
|
|
161
|
+
if (coupon.useLimitPerUser && ordersUserCoupon.length)
|
|
162
|
+
throw new InvalidCouponError('Limite de uso por usuário atingido.');
|
|
163
|
+
// Verifica o limite de uso geral por usuario
|
|
164
|
+
if (coupon.useLimit && orders.data.length >= coupon.useLimit)
|
|
165
|
+
throw new InvalidCouponError('Limite de uso atingido.');
|
|
166
|
+
const validUser = this.userValidationAndSubscriptionStatus(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
|
|
167
|
+
if (!validUser)
|
|
168
|
+
throw new InvalidCouponError('Usuário não elegível.');
|
|
169
|
+
const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
|
|
170
|
+
if (!hasProductCategories)
|
|
171
|
+
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
172
|
+
return coupon;
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
calcDiscountSubscription(coupon, checkout) {
|
|
176
|
+
//
|
|
177
|
+
let discount = 0;
|
|
178
|
+
if (coupon.type === CouponTypes.ABSOLUTE)
|
|
179
|
+
discount = coupon.discount;
|
|
180
|
+
else if (coupon.type === CouponTypes.PERCENTAGE)
|
|
181
|
+
discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount / 100);
|
|
182
|
+
return of(discount);
|
|
183
|
+
}
|
|
184
|
+
calcDiscountShopping(coupon, checkout) {
|
|
185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
+
let discount = 0;
|
|
187
|
+
switch (coupon.type) {
|
|
188
|
+
case CouponTypes.ABSOLUTE: {
|
|
189
|
+
discount = coupon.discount;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
case CouponTypes.PERCENTAGE: {
|
|
193
|
+
discount = yield this.calcShoppingPercentageDiscount(coupon, checkout);
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return discount;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
calcShoppingPercentageDiscount(coupon, checkout) {
|
|
201
|
+
var _a;
|
|
202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
let discount = 0;
|
|
204
|
+
const shop = checkout.shop;
|
|
205
|
+
let lineItensDiscount = [];
|
|
206
|
+
const couponCategories = yield this.getCouponCategoriesId(coupon);
|
|
207
|
+
if (coupon.productsCategories && coupon.productsCategories.length) {
|
|
208
|
+
lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
|
|
209
|
+
var _a;
|
|
210
|
+
if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
|
|
211
|
+
return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
|
|
212
|
+
}
|
|
213
|
+
return true;
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
lineItensDiscount = checkout.lineItems;
|
|
218
|
+
}
|
|
219
|
+
const subTotal = lineItensDiscount.reduce((acc, curr) => {
|
|
220
|
+
var _a, _b, _c;
|
|
221
|
+
return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
|
|
222
|
+
? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
|
|
223
|
+
: acc + curr.pricePaid * curr.quantity;
|
|
224
|
+
}, 0) || 0;
|
|
225
|
+
discount = subTotal * (coupon.discount / 100);
|
|
226
|
+
return discount;
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
hasMinSubTotal(coupon, checkout) {
|
|
230
|
+
var _a;
|
|
231
|
+
if (!coupon.minSubTotalValue)
|
|
232
|
+
return true;
|
|
233
|
+
const shop = checkout.shop;
|
|
234
|
+
let subTotal = ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.reduce((acc, curr) => {
|
|
235
|
+
var _a, _b, _c;
|
|
236
|
+
return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
|
|
237
|
+
? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
|
|
238
|
+
: acc + curr.pricePaid * curr.quantity;
|
|
239
|
+
}, 0)) || 0;
|
|
240
|
+
if (coupon.minSubTotalValue <= subTotal)
|
|
241
|
+
return true;
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
hasProductCategories(coupon, checkout) {
|
|
245
|
+
var _a;
|
|
246
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
247
|
+
if (!coupon.productsCategories || !coupon.productsCategories.length) {
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
const couponCategories = yield this.getCouponCategoriesId(coupon);
|
|
251
|
+
const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
|
|
252
|
+
var _a;
|
|
253
|
+
if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
254
|
+
return true;
|
|
255
|
+
return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
|
|
256
|
+
});
|
|
257
|
+
return hasCategories.length ? true : false;
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
userValidationAndSubscriptionStatus(coupon, user) {
|
|
261
|
+
if (coupon.exclusivityType === Exclusivities.ALL_USERS)
|
|
262
|
+
return true;
|
|
263
|
+
if (!user)
|
|
264
|
+
return true;
|
|
265
|
+
// Verifica se o email do usuário é coorporativo
|
|
266
|
+
if (!this.emailIsFromCollaborator(user.email) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
|
|
267
|
+
throw new InvalidCouponError('Você não é colaborador.');
|
|
268
|
+
// Verifica se o email do usuário é associado ao cupom de uso por usuario
|
|
269
|
+
if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== user.email)
|
|
270
|
+
throw new InvalidCouponError('Cupom não é válido para este usuário.');
|
|
271
|
+
switch (coupon.exclusivityType) {
|
|
272
|
+
case Exclusivities.ACTIVE_SUBSCRIBER:
|
|
273
|
+
return user.isSubscriber ? true : false;
|
|
274
|
+
case Exclusivities.INACTIVE_SUBSCRIBER:
|
|
275
|
+
return user.isSubscriber ? false : true;
|
|
276
|
+
case Exclusivities.NON_SUBSCRIBER:
|
|
277
|
+
return user.isSubscriber ? false : true;
|
|
278
|
+
}
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
getCouponCategoriesId(coupon) {
|
|
282
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
+
let couponCategories = [];
|
|
284
|
+
for (let index = 0; index < coupon.productsCategories.length; index++) {
|
|
285
|
+
let c = yield this.categoryRepository.get({
|
|
286
|
+
id: coupon.productsCategories[index],
|
|
287
|
+
});
|
|
288
|
+
couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
|
|
289
|
+
}
|
|
290
|
+
return couponCategories;
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
295
|
+
CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
|
|
296
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
|
|
297
|
+
type: Injectable,
|
|
298
|
+
args: [{
|
|
299
|
+
providedIn: 'root',
|
|
300
|
+
}]
|
|
301
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
302
|
+
type: Inject,
|
|
303
|
+
args: ['CouponRepository']
|
|
304
|
+
}] }, { type: i3.Shops, decorators: [{
|
|
305
|
+
type: Inject,
|
|
306
|
+
args: [DEFAULT_SHOP]
|
|
307
|
+
}] }, { type: undefined, decorators: [{
|
|
308
|
+
type: Inject,
|
|
309
|
+
args: ['OrderRepository']
|
|
310
|
+
}] }, { type: undefined, decorators: [{
|
|
311
|
+
type: Inject,
|
|
312
|
+
args: ['CategoryRepository']
|
|
313
313
|
}] }]; } });
|
|
314
314
|
|
|
315
|
-
class CheckoutService {
|
|
316
|
-
constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
|
|
317
|
-
this.couponService = couponService;
|
|
318
|
-
this.checkoutRepository = checkoutRepository;
|
|
319
|
-
this.orderRepository = orderRepository;
|
|
320
|
-
this.userRepository = userRepository;
|
|
321
|
-
this.defaultShop = defaultShop;
|
|
322
|
-
}
|
|
323
|
-
getCheckout(checkoutData) {
|
|
324
|
-
const checkoutId = cookie.get('checkoutId');
|
|
325
|
-
if (!isNil(checkoutId))
|
|
326
|
-
return from(this.checkoutRepository.get({ id: checkoutId }));
|
|
327
|
-
return from(this.createCheckout(checkoutData));
|
|
328
|
-
}
|
|
329
|
-
getUserByCheckout(checkoutId) {
|
|
330
|
-
return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id })); }), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
|
|
331
|
-
}
|
|
332
|
-
updateCheckoutLineItems(checkout) {
|
|
333
|
-
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
|
|
334
|
-
}
|
|
335
|
-
updateCheckoutUser(checkout) {
|
|
336
|
-
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
337
|
-
}
|
|
338
|
-
clearCheckoutFromSession() {
|
|
339
|
-
cookie.remove('checkoutId');
|
|
340
|
-
return of();
|
|
341
|
-
}
|
|
342
|
-
calcDiscount(coupon) {
|
|
343
|
-
return this.getCheckout().pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.couponService.calcDiscountShopping(coupon, checkout); })));
|
|
344
|
-
}
|
|
345
|
-
checkCoupon(nickname, checkoutType) {
|
|
346
|
-
return this.getCheckout().pipe(concatMap((checkout) => {
|
|
347
|
-
var _a;
|
|
348
|
-
return this.couponService
|
|
349
|
-
.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, CheckoutTypes.ECOMMERCE, checkout.user.subscriptionPlan, checkout, false)
|
|
350
|
-
.pipe();
|
|
351
|
-
}));
|
|
352
|
-
}
|
|
353
|
-
createCheckout(checkoutData) {
|
|
354
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
355
|
-
const checkout = yield this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }));
|
|
356
|
-
cookie.set('checkoutId', checkout.id);
|
|
357
|
-
return checkout;
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
362
|
-
CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService });
|
|
363
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, decorators: [{
|
|
364
|
-
type: Injectable
|
|
365
|
-
}], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
|
|
366
|
-
type: Inject,
|
|
367
|
-
args: ['CheckoutRepository']
|
|
368
|
-
}] }, { type: undefined, decorators: [{
|
|
369
|
-
type: Inject,
|
|
370
|
-
args: ['OrderRepository']
|
|
371
|
-
}] }, { type: undefined, decorators: [{
|
|
372
|
-
type: Inject,
|
|
373
|
-
args: ['UserRepository']
|
|
374
|
-
}] }, { type:
|
|
375
|
-
type: Inject,
|
|
376
|
-
args: [DEFAULT_SHOP]
|
|
315
|
+
class CheckoutService {
|
|
316
|
+
constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
|
|
317
|
+
this.couponService = couponService;
|
|
318
|
+
this.checkoutRepository = checkoutRepository;
|
|
319
|
+
this.orderRepository = orderRepository;
|
|
320
|
+
this.userRepository = userRepository;
|
|
321
|
+
this.defaultShop = defaultShop;
|
|
322
|
+
}
|
|
323
|
+
getCheckout(checkoutData) {
|
|
324
|
+
const checkoutId = cookie.get('checkoutId');
|
|
325
|
+
if (!isNil(checkoutId))
|
|
326
|
+
return from(this.checkoutRepository.get({ id: checkoutId }));
|
|
327
|
+
return from(this.createCheckout(checkoutData));
|
|
328
|
+
}
|
|
329
|
+
getUserByCheckout(checkoutId) {
|
|
330
|
+
return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id })); }), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
|
|
331
|
+
}
|
|
332
|
+
updateCheckoutLineItems(checkout) {
|
|
333
|
+
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
|
|
334
|
+
}
|
|
335
|
+
updateCheckoutUser(checkout) {
|
|
336
|
+
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
337
|
+
}
|
|
338
|
+
clearCheckoutFromSession() {
|
|
339
|
+
cookie.remove('checkoutId');
|
|
340
|
+
return of();
|
|
341
|
+
}
|
|
342
|
+
calcDiscount(coupon) {
|
|
343
|
+
return this.getCheckout().pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.couponService.calcDiscountShopping(coupon, checkout); })));
|
|
344
|
+
}
|
|
345
|
+
checkCoupon(nickname, checkoutType) {
|
|
346
|
+
return this.getCheckout().pipe(concatMap((checkout) => {
|
|
347
|
+
var _a;
|
|
348
|
+
return this.couponService
|
|
349
|
+
.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, CheckoutTypes.ECOMMERCE, checkout.user.subscriptionPlan, checkout, false)
|
|
350
|
+
.pipe();
|
|
351
|
+
}));
|
|
352
|
+
}
|
|
353
|
+
createCheckout(checkoutData) {
|
|
354
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
355
|
+
const checkout = yield this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }));
|
|
356
|
+
cookie.set('checkoutId', checkout.id);
|
|
357
|
+
return checkout;
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
362
|
+
CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService });
|
|
363
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, decorators: [{
|
|
364
|
+
type: Injectable
|
|
365
|
+
}], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
|
|
366
|
+
type: Inject,
|
|
367
|
+
args: ['CheckoutRepository']
|
|
368
|
+
}] }, { type: undefined, decorators: [{
|
|
369
|
+
type: Inject,
|
|
370
|
+
args: ['OrderRepository']
|
|
371
|
+
}] }, { type: undefined, decorators: [{
|
|
372
|
+
type: Inject,
|
|
373
|
+
args: ['UserRepository']
|
|
374
|
+
}] }, { type: i3.Shops, decorators: [{
|
|
375
|
+
type: Inject,
|
|
376
|
+
args: [DEFAULT_SHOP]
|
|
377
377
|
}] }]; } });
|
|
378
378
|
|
|
379
|
-
class CartService {
|
|
380
|
-
constructor(authService, checkoutService, defaultShop, productRepository, variantRepository) {
|
|
381
|
-
this.authService = authService;
|
|
382
|
-
this.checkoutService = checkoutService;
|
|
383
|
-
this.defaultShop = defaultShop;
|
|
384
|
-
this.productRepository = productRepository;
|
|
385
|
-
this.variantRepository = variantRepository;
|
|
386
|
-
this.
|
|
387
|
-
this.
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
checkoutLoaded.lineItems[index].
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
.
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
const
|
|
417
|
-
const
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
const
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
:
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
let
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
379
|
+
class CartService {
|
|
380
|
+
constructor(authService, checkoutService, defaultShop, productRepository, variantRepository, buy2WinRepository) {
|
|
381
|
+
this.authService = authService;
|
|
382
|
+
this.checkoutService = checkoutService;
|
|
383
|
+
this.defaultShop = defaultShop;
|
|
384
|
+
this.productRepository = productRepository;
|
|
385
|
+
this.variantRepository = variantRepository;
|
|
386
|
+
this.buy2WinRepository = buy2WinRepository;
|
|
387
|
+
this.cartSubject = new Subject();
|
|
388
|
+
this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
|
|
389
|
+
var _a;
|
|
390
|
+
const items = [];
|
|
391
|
+
const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
|
|
392
|
+
if (index > -1) {
|
|
393
|
+
checkoutLoaded.lineItems[index].quantity += quantity;
|
|
394
|
+
checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
|
|
395
|
+
}
|
|
396
|
+
else
|
|
397
|
+
checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
|
|
398
|
+
return this.checkoutService
|
|
399
|
+
.updateCheckoutLineItems(checkoutLoaded)
|
|
400
|
+
.pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
|
|
401
|
+
}));
|
|
402
|
+
this.generateCartObject = (items) => {
|
|
403
|
+
const cart = {};
|
|
404
|
+
items === null || items === void 0 ? void 0 : items.forEach((item) => {
|
|
405
|
+
var _a;
|
|
406
|
+
return (cart[item.sku] = LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.sku] || item)), { quantity: (((_a = cart[item.sku]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })));
|
|
407
|
+
});
|
|
408
|
+
return cart;
|
|
409
|
+
};
|
|
410
|
+
this.buildLineItem = ({ checkout, item, quantity, }) => __awaiter(this, void 0, void 0, function* () {
|
|
411
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
412
|
+
const product = yield this.getProductData(item.id);
|
|
413
|
+
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.sku === item.sku)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
|
|
414
|
+
if (this.checkMaxStock(item, quantity || 0))
|
|
415
|
+
throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
|
|
416
|
+
const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
|
|
417
|
+
const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
|
|
418
|
+
const isGift = item.isGift || null;
|
|
419
|
+
const pricePaid = this.getProductPrice({
|
|
420
|
+
product: item,
|
|
421
|
+
shop: checkout.shop || this.defaultShop,
|
|
422
|
+
isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
|
|
423
|
+
});
|
|
424
|
+
return {
|
|
425
|
+
checkout,
|
|
426
|
+
lineItem: LineItem.toInstance({
|
|
427
|
+
id,
|
|
428
|
+
name: name !== null && name !== void 0 ? name : product.name,
|
|
429
|
+
EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
|
|
430
|
+
brand: product.brand,
|
|
431
|
+
slug: slug !== null && slug !== void 0 ? slug : product.slug,
|
|
432
|
+
sku: sku !== null && sku !== void 0 ? sku : product.sku,
|
|
433
|
+
stock,
|
|
434
|
+
price,
|
|
435
|
+
image,
|
|
436
|
+
weight: weight !== null && weight !== void 0 ? weight : product.weight,
|
|
437
|
+
quantity: (item.quantity || 0) + (quantity || 0),
|
|
438
|
+
pricePaid,
|
|
439
|
+
categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
|
|
440
|
+
isGift: isGift !== null && isGift !== void 0 ? isGift : null,
|
|
441
|
+
costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
|
|
442
|
+
type,
|
|
443
|
+
}),
|
|
444
|
+
};
|
|
445
|
+
});
|
|
446
|
+
this.getProductPrice = ({ product, isSubscriber, }) => {
|
|
447
|
+
const info = product.price;
|
|
448
|
+
if (product.isGift)
|
|
449
|
+
return 0;
|
|
450
|
+
return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
|
|
451
|
+
};
|
|
452
|
+
this.checkMaxStock = (item, quantity) => {
|
|
453
|
+
var _a;
|
|
454
|
+
const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
|
|
455
|
+
const currentItemAmount = item.quantity || 0;
|
|
456
|
+
return currentItemAmount + quantity > maxStock;
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
addItem(item, quantity = 1) {
|
|
460
|
+
return from(this.checkoutService.getCheckout()).pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.buildLineItem({ checkout, item, quantity: quantity || 1 }); })), mergeMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
|
|
461
|
+
}
|
|
462
|
+
decreaseItem(item) {
|
|
463
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
464
|
+
var _a;
|
|
465
|
+
const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
|
|
466
|
+
if (!isNil(checkoutItem))
|
|
467
|
+
checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
|
|
468
|
+
return checkout;
|
|
469
|
+
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
470
|
+
}
|
|
471
|
+
getCart(checkout) {
|
|
472
|
+
this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
|
|
473
|
+
return this.cartSubject;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* @deprecated The method should not be used
|
|
477
|
+
*/
|
|
478
|
+
getVariantPriceDiscount(item) {
|
|
479
|
+
return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.price.subscriberPrice, of(item.price.subscriberPrice), of(item.price.price))), catchError(() => of(item.price.price)));
|
|
480
|
+
}
|
|
481
|
+
removeItem(item) {
|
|
482
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
483
|
+
const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
|
|
484
|
+
if (index >= 0)
|
|
485
|
+
checkout.lineItems.splice(index, 1);
|
|
486
|
+
return checkout;
|
|
487
|
+
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
488
|
+
}
|
|
489
|
+
updateUserCart(user) {
|
|
490
|
+
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => __awaiter(this, void 0, void 0, function* () {
|
|
491
|
+
var _a, _b;
|
|
492
|
+
return this.checkoutService
|
|
493
|
+
.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)
|
|
494
|
+
? yield Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map((item) => __awaiter(this, void 0, void 0, function* () { return (yield this.buildLineItem({ checkout, item })).lineItem; })))
|
|
495
|
+
: [] })))
|
|
496
|
+
.toPromise();
|
|
497
|
+
})), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
498
|
+
}
|
|
499
|
+
clearCart() {
|
|
500
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
501
|
+
this.checkoutService.clearCheckoutFromSession();
|
|
502
|
+
return checkout;
|
|
503
|
+
}), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
|
|
504
|
+
}
|
|
505
|
+
buildCartFromCheckout(checkoutData) {
|
|
506
|
+
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
507
|
+
}
|
|
508
|
+
getProductData(productId) {
|
|
509
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
510
|
+
let product;
|
|
511
|
+
let variant;
|
|
512
|
+
try {
|
|
513
|
+
product = yield this.productRepository.get({ id: productId });
|
|
514
|
+
}
|
|
515
|
+
catch (error) {
|
|
516
|
+
if (!(error instanceof NotFoundError))
|
|
517
|
+
throw error;
|
|
518
|
+
variant = yield this.variantRepository.get({ id: productId });
|
|
519
|
+
product = yield this.productRepository.get({ id: variant.productId });
|
|
520
|
+
}
|
|
521
|
+
return Object.assign(Object.assign({}, product.toPlain()), (variant && Object.assign({}, variant.toPlain())));
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
getGifts() {
|
|
525
|
+
return this.checkoutService.getCheckout().pipe(mergeMap((checkout) => __awaiter(this, void 0, void 0, function* () {
|
|
526
|
+
const campaigns = yield this.buy2WinRepository
|
|
527
|
+
.find({
|
|
528
|
+
filters: {
|
|
529
|
+
active: { operator: Where.EQUALS, value: true },
|
|
530
|
+
shop: { operator: Where.EQUALS, value: this.defaultShop },
|
|
531
|
+
},
|
|
532
|
+
})
|
|
533
|
+
.then((data) => data.data);
|
|
534
|
+
const notGiftItems = checkout.lineItems.filter((item) => !item.isGift);
|
|
535
|
+
if (!campaigns.length)
|
|
536
|
+
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
|
|
537
|
+
const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
538
|
+
const elegibleCampaigns = [];
|
|
539
|
+
for (const campaign of campaigns) {
|
|
540
|
+
const today = new Date();
|
|
541
|
+
if (!(campaign.startDate <= today) && !(campaign.endDate >= today))
|
|
542
|
+
continue;
|
|
543
|
+
if (campaign.activeCategory) {
|
|
544
|
+
const categoriesCampaing = campaign.categories.map((c) => c.id);
|
|
545
|
+
const filterProductsCategories = checkout.lineItems.filter((l) => {
|
|
546
|
+
var _a;
|
|
547
|
+
if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
548
|
+
return true;
|
|
549
|
+
return l.categories.some((c) => categoriesCampaing.some((cat) => cat == c));
|
|
550
|
+
});
|
|
551
|
+
if (filterProductsCategories.length) {
|
|
552
|
+
const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
553
|
+
if (cartTotalCategories >= campaign.cartValueMin)
|
|
554
|
+
elegibleCampaigns.push(campaign);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
if (campaign.cartValue && campaign.cartValue > 0) {
|
|
559
|
+
if (campaign.cartValue <= cartTotal)
|
|
560
|
+
elegibleCampaigns.push(campaign);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
if (!elegibleCampaigns.length)
|
|
565
|
+
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
|
|
566
|
+
const campaingnProducts = [];
|
|
567
|
+
for (const campaign of elegibleCampaigns) {
|
|
568
|
+
let elegibleProducts = [];
|
|
569
|
+
for (const product of campaign.products) {
|
|
570
|
+
const productData = yield this.productRepository.get({ sku: product });
|
|
571
|
+
if (!productData)
|
|
572
|
+
continue;
|
|
573
|
+
elegibleProducts.push(productData);
|
|
574
|
+
}
|
|
575
|
+
campaingnProducts.push(elegibleProducts);
|
|
576
|
+
}
|
|
577
|
+
if (!campaingnProducts.length)
|
|
578
|
+
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
|
|
579
|
+
const gifts = this.giftToLineItems([].concat(...campaingnProducts));
|
|
580
|
+
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems.concat(gifts) });
|
|
581
|
+
})), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
582
|
+
}
|
|
583
|
+
giftToLineItems(items) {
|
|
584
|
+
return items.map((item) => {
|
|
585
|
+
var _a;
|
|
586
|
+
const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
|
|
587
|
+
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];
|
|
588
|
+
return LineItem.toInstance({
|
|
589
|
+
brand,
|
|
590
|
+
categories,
|
|
591
|
+
id: id.toString(),
|
|
592
|
+
name,
|
|
593
|
+
price,
|
|
594
|
+
sku,
|
|
595
|
+
slug,
|
|
596
|
+
stock,
|
|
597
|
+
weight,
|
|
598
|
+
EAN,
|
|
599
|
+
image,
|
|
600
|
+
pricePaid: 0,
|
|
601
|
+
quantity: 1,
|
|
602
|
+
isGift: true,
|
|
603
|
+
});
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
608
|
+
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
|
|
609
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
|
|
610
|
+
type: Injectable
|
|
611
|
+
}], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i3.Shops, decorators: [{
|
|
612
|
+
type: Inject,
|
|
613
|
+
args: [DEFAULT_SHOP]
|
|
614
|
+
}] }, { type: undefined, decorators: [{
|
|
615
|
+
type: Inject,
|
|
616
|
+
args: ['ProductRepository']
|
|
617
|
+
}] }, { type: undefined, decorators: [{
|
|
618
|
+
type: Inject,
|
|
619
|
+
args: ['VariantRepository']
|
|
620
|
+
}] }, { type: i3.Buy2WinFirestoreRepository, decorators: [{
|
|
621
|
+
type: Inject,
|
|
622
|
+
args: ['Buy2WinRepository']
|
|
537
623
|
}] }]; } });
|
|
538
624
|
|
|
539
|
-
class CheckoutSubscriptionService {
|
|
540
|
-
constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
541
|
-
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
542
|
-
this.subscriptionRepository = subscriptionRepository;
|
|
543
|
-
this.couponService = couponService;
|
|
544
|
-
}
|
|
545
|
-
getCheckoutSubscription(checkoutData) {
|
|
546
|
-
const checkoutId = cookie.get('checkoutSubscriptionId');
|
|
547
|
-
if (!isNil(checkoutId))
|
|
548
|
-
return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
|
|
549
|
-
return from(this.createCheckoutSubscription(checkoutData));
|
|
550
|
-
}
|
|
551
|
-
createCheckoutSubscription(checkoutData) {
|
|
552
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
553
|
-
const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
|
|
554
|
-
cookie.set('checkoutSubscriptionId', checkout.id);
|
|
555
|
-
return checkout;
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
clearCheckoutSubscriptionFromSession() {
|
|
559
|
-
cookie.remove('checkoutSubscriptionId');
|
|
560
|
-
return of();
|
|
561
|
-
}
|
|
562
|
-
checkCoupon(nickname, userEmail) {
|
|
563
|
-
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
564
|
-
.checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, checkout, true)
|
|
565
|
-
.pipe()));
|
|
566
|
-
}
|
|
567
|
-
calcDiscountSubscription(coupon) {
|
|
568
|
-
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
572
|
-
CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService });
|
|
573
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
574
|
-
type: Injectable
|
|
575
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
576
|
-
type: Inject,
|
|
577
|
-
args: ['CheckoutSubscriptionRepository']
|
|
578
|
-
}] }, { type: undefined, decorators: [{
|
|
579
|
-
type: Inject,
|
|
580
|
-
args: ['SubscriptionRepository']
|
|
625
|
+
class CheckoutSubscriptionService {
|
|
626
|
+
constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
627
|
+
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
628
|
+
this.subscriptionRepository = subscriptionRepository;
|
|
629
|
+
this.couponService = couponService;
|
|
630
|
+
}
|
|
631
|
+
getCheckoutSubscription(checkoutData) {
|
|
632
|
+
const checkoutId = cookie.get('checkoutSubscriptionId');
|
|
633
|
+
if (!isNil(checkoutId))
|
|
634
|
+
return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
|
|
635
|
+
return from(this.createCheckoutSubscription(checkoutData));
|
|
636
|
+
}
|
|
637
|
+
createCheckoutSubscription(checkoutData) {
|
|
638
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
639
|
+
const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
|
|
640
|
+
cookie.set('checkoutSubscriptionId', checkout.id);
|
|
641
|
+
return checkout;
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
clearCheckoutSubscriptionFromSession() {
|
|
645
|
+
cookie.remove('checkoutSubscriptionId');
|
|
646
|
+
return of();
|
|
647
|
+
}
|
|
648
|
+
checkCoupon(nickname, userEmail) {
|
|
649
|
+
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
650
|
+
.checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, checkout, true)
|
|
651
|
+
.pipe()));
|
|
652
|
+
}
|
|
653
|
+
calcDiscountSubscription(coupon) {
|
|
654
|
+
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
658
|
+
CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService });
|
|
659
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
660
|
+
type: Injectable
|
|
661
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
662
|
+
type: Inject,
|
|
663
|
+
args: ['CheckoutSubscriptionRepository']
|
|
664
|
+
}] }, { type: undefined, decorators: [{
|
|
665
|
+
type: Inject,
|
|
666
|
+
args: ['SubscriptionRepository']
|
|
581
667
|
}] }, { type: CouponService }]; } });
|
|
582
668
|
|
|
583
|
-
class HomeShopService {
|
|
584
|
-
constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
585
|
-
this.categoryRepository = categoryRepository;
|
|
586
|
-
this.homeRepository = homeRepository;
|
|
587
|
-
this.productRepository = productRepository;
|
|
588
|
-
this.defaultShop = defaultShop;
|
|
589
|
-
this.buildCategoryGroupWithRequiredData = (group) => {
|
|
590
|
-
var _a, _b;
|
|
591
|
-
return ({
|
|
592
|
-
category: Category.toInstance(pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
|
|
593
|
-
products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map((product) => Product.toInstance(pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
|
|
594
|
-
'id',
|
|
595
|
-
'price',
|
|
596
|
-
'reviews',
|
|
597
|
-
'hasVariants',
|
|
598
|
-
'slug',
|
|
599
|
-
'sku',
|
|
600
|
-
'stock',
|
|
601
|
-
'costPrice',
|
|
602
|
-
'images',
|
|
603
|
-
'miniatures',
|
|
604
|
-
'name',
|
|
605
|
-
'weight',
|
|
606
|
-
'rate',
|
|
607
|
-
'type',
|
|
608
|
-
])))) || [],
|
|
609
|
-
});
|
|
610
|
-
};
|
|
611
|
-
}
|
|
612
|
-
get homeId() {
|
|
613
|
-
if (this.defaultShop === Shops.GLAMSHOP)
|
|
614
|
-
return 'glamshop';
|
|
615
|
-
if (this.defaultShop === Shops.MENSMARKET)
|
|
616
|
-
return 'mens_market';
|
|
617
|
-
return null;
|
|
618
|
-
}
|
|
619
|
-
getHomeData() {
|
|
620
|
-
return this.getHomeConfiguration().pipe(map((home) => { var _a; return (((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt) > new Date() ? home : null); }), concatMap((home) => home
|
|
621
|
-
? of(home)
|
|
622
|
-
: forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
|
|
623
|
-
discoverProducts,
|
|
624
|
-
featuredProducts,
|
|
625
|
-
verticalProducts,
|
|
626
|
-
})), concatMap((data) => this.saveHomeData(data)))));
|
|
627
|
-
}
|
|
628
|
-
getBanners(type) {
|
|
629
|
-
return this.getHomeConfiguration().pipe(map((home) => {
|
|
630
|
-
if (type === 'brand')
|
|
631
|
-
return home.brandsCarousel;
|
|
632
|
-
if (type === 'buyToWin')
|
|
633
|
-
return [home.buyToWinBanner];
|
|
634
|
-
if (type === 'block')
|
|
635
|
-
return home.blockBanners;
|
|
636
|
-
if (type === 'blog')
|
|
637
|
-
return [home.blogBanner];
|
|
638
|
-
}));
|
|
639
|
-
}
|
|
640
|
-
getMinValueForFreeShipping() {
|
|
641
|
-
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
642
|
-
}
|
|
643
|
-
getDiscoverProducts() {
|
|
644
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
645
|
-
}
|
|
646
|
-
getFeaturedProducts() {
|
|
647
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
648
|
-
}
|
|
649
|
-
getVerticalProducts() {
|
|
650
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => from(this.categoryRepository.get({ id })).pipe(concatMap((category) => from(this.productRepository.find({
|
|
651
|
-
filters: { categories: { operator: Where.IN, value: [category.id] } },
|
|
652
|
-
limits: { limit: 12 },
|
|
653
|
-
})).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
|
|
654
|
-
}
|
|
655
|
-
getHomeConfiguration() {
|
|
656
|
-
return of(this.homeConfiguration).pipe(concatMap((home) => home
|
|
657
|
-
? of(home)
|
|
658
|
-
: !this.homeId
|
|
659
|
-
? throwError(new RequiredArgumentError(['homeId']))
|
|
660
|
-
: from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
|
|
661
|
-
}
|
|
662
|
-
saveHomeData(homeData) {
|
|
663
|
-
const data = {
|
|
664
|
-
createdAt: new Date(),
|
|
665
|
-
expiresAt: add(new Date(), { hours: 1 }),
|
|
666
|
-
data: homeData,
|
|
667
|
-
};
|
|
668
|
-
return from(this.homeRepository.update({
|
|
669
|
-
id: this.homeId,
|
|
670
|
-
data,
|
|
671
|
-
})).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
675
|
-
HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService });
|
|
676
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, decorators: [{
|
|
677
|
-
type: Injectable
|
|
678
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
679
|
-
type: Inject,
|
|
680
|
-
args: ['CategoryRepository']
|
|
681
|
-
}] }, { type: undefined, decorators: [{
|
|
682
|
-
type: Inject,
|
|
683
|
-
args: ['HomeRepository']
|
|
684
|
-
}] }, { type: undefined, decorators: [{
|
|
685
|
-
type: Inject,
|
|
686
|
-
args: ['ProductRepository']
|
|
687
|
-
}] }, { type:
|
|
688
|
-
type: Inject,
|
|
689
|
-
args: [DEFAULT_SHOP]
|
|
669
|
+
class HomeShopService {
|
|
670
|
+
constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
671
|
+
this.categoryRepository = categoryRepository;
|
|
672
|
+
this.homeRepository = homeRepository;
|
|
673
|
+
this.productRepository = productRepository;
|
|
674
|
+
this.defaultShop = defaultShop;
|
|
675
|
+
this.buildCategoryGroupWithRequiredData = (group) => {
|
|
676
|
+
var _a, _b;
|
|
677
|
+
return ({
|
|
678
|
+
category: Category.toInstance(pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
|
|
679
|
+
products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map((product) => Product.toInstance(pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
|
|
680
|
+
'id',
|
|
681
|
+
'price',
|
|
682
|
+
'reviews',
|
|
683
|
+
'hasVariants',
|
|
684
|
+
'slug',
|
|
685
|
+
'sku',
|
|
686
|
+
'stock',
|
|
687
|
+
'costPrice',
|
|
688
|
+
'images',
|
|
689
|
+
'miniatures',
|
|
690
|
+
'name',
|
|
691
|
+
'weight',
|
|
692
|
+
'rate',
|
|
693
|
+
'type',
|
|
694
|
+
])))) || [],
|
|
695
|
+
});
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
get homeId() {
|
|
699
|
+
if (this.defaultShop === Shops.GLAMSHOP)
|
|
700
|
+
return 'glamshop';
|
|
701
|
+
if (this.defaultShop === Shops.MENSMARKET)
|
|
702
|
+
return 'mens_market';
|
|
703
|
+
return null;
|
|
704
|
+
}
|
|
705
|
+
getHomeData() {
|
|
706
|
+
return this.getHomeConfiguration().pipe(map((home) => { var _a; return (((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt) > new Date() ? home : null); }), concatMap((home) => home
|
|
707
|
+
? of(home)
|
|
708
|
+
: forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
|
|
709
|
+
discoverProducts,
|
|
710
|
+
featuredProducts,
|
|
711
|
+
verticalProducts,
|
|
712
|
+
})), concatMap((data) => this.saveHomeData(data)))));
|
|
713
|
+
}
|
|
714
|
+
getBanners(type) {
|
|
715
|
+
return this.getHomeConfiguration().pipe(map((home) => {
|
|
716
|
+
if (type === 'brand')
|
|
717
|
+
return home.brandsCarousel;
|
|
718
|
+
if (type === 'buyToWin')
|
|
719
|
+
return [home.buyToWinBanner];
|
|
720
|
+
if (type === 'block')
|
|
721
|
+
return home.blockBanners;
|
|
722
|
+
if (type === 'blog')
|
|
723
|
+
return [home.blogBanner];
|
|
724
|
+
}));
|
|
725
|
+
}
|
|
726
|
+
getMinValueForFreeShipping() {
|
|
727
|
+
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
728
|
+
}
|
|
729
|
+
getDiscoverProducts() {
|
|
730
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
731
|
+
}
|
|
732
|
+
getFeaturedProducts() {
|
|
733
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
734
|
+
}
|
|
735
|
+
getVerticalProducts() {
|
|
736
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => from(this.categoryRepository.get({ id })).pipe(concatMap((category) => from(this.productRepository.find({
|
|
737
|
+
filters: { categories: { operator: Where.IN, value: [category.id] } },
|
|
738
|
+
limits: { limit: 12 },
|
|
739
|
+
})).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
|
|
740
|
+
}
|
|
741
|
+
getHomeConfiguration() {
|
|
742
|
+
return of(this.homeConfiguration).pipe(concatMap((home) => home
|
|
743
|
+
? of(home)
|
|
744
|
+
: !this.homeId
|
|
745
|
+
? throwError(new RequiredArgumentError(['homeId']))
|
|
746
|
+
: from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
|
|
747
|
+
}
|
|
748
|
+
saveHomeData(homeData) {
|
|
749
|
+
const data = {
|
|
750
|
+
createdAt: new Date(),
|
|
751
|
+
expiresAt: add(new Date(), { hours: 1 }),
|
|
752
|
+
data: homeData,
|
|
753
|
+
};
|
|
754
|
+
return from(this.homeRepository.update({
|
|
755
|
+
id: this.homeId,
|
|
756
|
+
data,
|
|
757
|
+
})).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
761
|
+
HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService });
|
|
762
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, decorators: [{
|
|
763
|
+
type: Injectable
|
|
764
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
765
|
+
type: Inject,
|
|
766
|
+
args: ['CategoryRepository']
|
|
767
|
+
}] }, { type: undefined, decorators: [{
|
|
768
|
+
type: Inject,
|
|
769
|
+
args: ['HomeRepository']
|
|
770
|
+
}] }, { type: undefined, decorators: [{
|
|
771
|
+
type: Inject,
|
|
772
|
+
args: ['ProductRepository']
|
|
773
|
+
}] }, { type: i3.Shops, decorators: [{
|
|
774
|
+
type: Inject,
|
|
775
|
+
args: [DEFAULT_SHOP]
|
|
690
776
|
}] }]; } });
|
|
691
777
|
|
|
692
|
-
class OrderService {
|
|
693
|
-
constructor(angularFirestore, orderRepository) {
|
|
694
|
-
this.angularFirestore = angularFirestore;
|
|
695
|
-
this.orderRepository = orderRepository;
|
|
696
|
-
this.orderSubject = new Subject();
|
|
697
|
-
}
|
|
698
|
-
getOrder(id) {
|
|
699
|
-
this.angularFirestore
|
|
700
|
-
.doc(`${this.orderRepository.collectionName}/${id}`)
|
|
701
|
-
.valueChanges()
|
|
702
|
-
.pipe(map((doc) => Order.toInstance(doc)))
|
|
703
|
-
.subscribe((doc) => this.orderSubject.next(doc));
|
|
704
|
-
return this.orderSubject;
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$
|
|
708
|
-
OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
|
|
709
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
|
|
710
|
-
type: Injectable
|
|
711
|
-
}], ctorParameters: function () { return [{ type: i1$
|
|
712
|
-
type: Inject,
|
|
713
|
-
args: ['OrderRepository']
|
|
778
|
+
class OrderService {
|
|
779
|
+
constructor(angularFirestore, orderRepository) {
|
|
780
|
+
this.angularFirestore = angularFirestore;
|
|
781
|
+
this.orderRepository = orderRepository;
|
|
782
|
+
this.orderSubject = new Subject();
|
|
783
|
+
}
|
|
784
|
+
getOrder(id) {
|
|
785
|
+
this.angularFirestore
|
|
786
|
+
.doc(`${this.orderRepository.collectionName}/${id}`)
|
|
787
|
+
.valueChanges()
|
|
788
|
+
.pipe(map((doc) => Order.toInstance(doc)))
|
|
789
|
+
.subscribe((doc) => this.orderSubject.next(doc));
|
|
790
|
+
return this.orderSubject;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$1.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
794
|
+
OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
|
|
795
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
|
|
796
|
+
type: Injectable
|
|
797
|
+
}], ctorParameters: function () { return [{ type: i1$1.AngularFirestore }, { type: i3.OrderFirestoreRepository, decorators: [{
|
|
798
|
+
type: Inject,
|
|
799
|
+
args: ['OrderRepository']
|
|
714
800
|
}] }]; } });
|
|
715
801
|
|
|
716
|
-
class ShippingService {
|
|
717
|
-
constructor(http, apiUrl, homeService) {
|
|
718
|
-
this.http = http;
|
|
719
|
-
this.apiUrl = apiUrl;
|
|
720
|
-
this.homeService = homeService;
|
|
721
|
-
}
|
|
722
|
-
getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
|
|
723
|
-
return combineLatest([
|
|
724
|
-
this.homeService.getHomeData(),
|
|
725
|
-
this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
|
|
726
|
-
]).pipe(map(([datas, shippingMethodsResponse]) => {
|
|
727
|
-
let shippingMethods = shippingMethodsResponse.result;
|
|
728
|
-
if (!shippingMethods.length)
|
|
729
|
-
return [];
|
|
730
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
731
|
-
if (s.ShippingCompanyName == 'Same Day EG')
|
|
732
|
-
s.ShippingCompanyName = 'Same Day';
|
|
733
|
-
else
|
|
734
|
-
return s;
|
|
735
|
-
});
|
|
736
|
-
const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
|
|
737
|
-
if (this.isHolidays(datasSameDayNotAvaliable)) {
|
|
738
|
-
shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
|
|
739
|
-
}
|
|
740
|
-
if (totalPrice >= 200) {
|
|
741
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
742
|
-
if (s.serviceName !== 'Same Day')
|
|
743
|
-
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
744
|
-
else
|
|
745
|
-
return s;
|
|
746
|
-
});
|
|
747
|
-
}
|
|
748
|
-
if (shop == Shops.GLAMSHOP)
|
|
749
|
-
return shippingMethods;
|
|
750
|
-
if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
|
|
751
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
752
|
-
if (s.serviceName == 'Same Day')
|
|
753
|
-
return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
|
|
754
|
-
else
|
|
755
|
-
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
756
|
-
});
|
|
757
|
-
}
|
|
758
|
-
if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
|
|
759
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
760
|
-
return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
|
|
761
|
-
});
|
|
762
|
-
}
|
|
763
|
-
return shippingMethods;
|
|
764
|
-
}));
|
|
765
|
-
}
|
|
766
|
-
isFreeShippingBySubscription(shop, subscriptionPlan) {
|
|
767
|
-
if (!subscriptionPlan)
|
|
768
|
-
return false;
|
|
769
|
-
if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
|
|
770
|
-
return true;
|
|
771
|
-
}
|
|
772
|
-
return false;
|
|
773
|
-
}
|
|
774
|
-
isHalfShippingBySubscription(shop, subscriptionPlan) {
|
|
775
|
-
if (!subscriptionPlan)
|
|
776
|
-
return false;
|
|
777
|
-
if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
|
|
778
|
-
return true;
|
|
779
|
-
}
|
|
780
|
-
return false;
|
|
781
|
-
}
|
|
782
|
-
isHolidays(datas) {
|
|
783
|
-
const today = new Date();
|
|
784
|
-
for (const key in datas) {
|
|
785
|
-
let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
|
|
786
|
-
let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
|
|
787
|
-
if (start > end)
|
|
788
|
-
end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
|
|
789
|
-
if (today >= start && today <= end)
|
|
790
|
-
return true;
|
|
791
|
-
}
|
|
792
|
-
return false;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, deps: [{ token: i1$
|
|
796
|
-
ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService });
|
|
797
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, decorators: [{
|
|
798
|
-
type: Injectable
|
|
799
|
-
}], ctorParameters: function () { return [{ type: i1$
|
|
800
|
-
type: Inject,
|
|
801
|
-
args: [BACKEND_URL]
|
|
802
|
+
class ShippingService {
|
|
803
|
+
constructor(http, apiUrl, homeService) {
|
|
804
|
+
this.http = http;
|
|
805
|
+
this.apiUrl = apiUrl;
|
|
806
|
+
this.homeService = homeService;
|
|
807
|
+
}
|
|
808
|
+
getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
|
|
809
|
+
return combineLatest([
|
|
810
|
+
this.homeService.getHomeData(),
|
|
811
|
+
this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
|
|
812
|
+
]).pipe(map(([datas, shippingMethodsResponse]) => {
|
|
813
|
+
let shippingMethods = shippingMethodsResponse.result;
|
|
814
|
+
if (!shippingMethods.length)
|
|
815
|
+
return [];
|
|
816
|
+
shippingMethods = shippingMethods.map((s) => {
|
|
817
|
+
if (s.ShippingCompanyName == 'Same Day EG')
|
|
818
|
+
s.ShippingCompanyName = 'Same Day';
|
|
819
|
+
else
|
|
820
|
+
return s;
|
|
821
|
+
});
|
|
822
|
+
const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
|
|
823
|
+
if (this.isHolidays(datasSameDayNotAvaliable)) {
|
|
824
|
+
shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
|
|
825
|
+
}
|
|
826
|
+
if (totalPrice >= 200) {
|
|
827
|
+
shippingMethods = shippingMethods.map((s) => {
|
|
828
|
+
if (s.serviceName !== 'Same Day')
|
|
829
|
+
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
830
|
+
else
|
|
831
|
+
return s;
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
if (shop == Shops.GLAMSHOP)
|
|
835
|
+
return shippingMethods;
|
|
836
|
+
if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
|
|
837
|
+
shippingMethods = shippingMethods.map((s) => {
|
|
838
|
+
if (s.serviceName == 'Same Day')
|
|
839
|
+
return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
|
|
840
|
+
else
|
|
841
|
+
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
|
|
845
|
+
shippingMethods = shippingMethods.map((s) => {
|
|
846
|
+
return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
return shippingMethods;
|
|
850
|
+
}));
|
|
851
|
+
}
|
|
852
|
+
isFreeShippingBySubscription(shop, subscriptionPlan) {
|
|
853
|
+
if (!subscriptionPlan)
|
|
854
|
+
return false;
|
|
855
|
+
if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
|
|
856
|
+
return true;
|
|
857
|
+
}
|
|
858
|
+
return false;
|
|
859
|
+
}
|
|
860
|
+
isHalfShippingBySubscription(shop, subscriptionPlan) {
|
|
861
|
+
if (!subscriptionPlan)
|
|
862
|
+
return false;
|
|
863
|
+
if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
|
|
864
|
+
return true;
|
|
865
|
+
}
|
|
866
|
+
return false;
|
|
867
|
+
}
|
|
868
|
+
isHolidays(datas) {
|
|
869
|
+
const today = new Date();
|
|
870
|
+
for (const key in datas) {
|
|
871
|
+
let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
|
|
872
|
+
let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
|
|
873
|
+
if (start > end)
|
|
874
|
+
end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
|
|
875
|
+
if (today >= start && today <= end)
|
|
876
|
+
return true;
|
|
877
|
+
}
|
|
878
|
+
return false;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, deps: [{ token: i1$2.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
882
|
+
ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService });
|
|
883
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, decorators: [{
|
|
884
|
+
type: Injectable
|
|
885
|
+
}], ctorParameters: function () { return [{ type: i1$2.HttpClient }, { type: undefined, decorators: [{
|
|
886
|
+
type: Inject,
|
|
887
|
+
args: [BACKEND_URL]
|
|
802
888
|
}] }, { type: HomeShopService }]; } });
|
|
803
889
|
|
|
804
|
-
class AngularFirebaseAuthModule {
|
|
805
|
-
static initializeApp(options, nameOrConfig) {
|
|
806
|
-
return {
|
|
807
|
-
ngModule: AngularFirebaseAuthModule,
|
|
808
|
-
providers: [
|
|
809
|
-
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
810
|
-
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
811
|
-
],
|
|
812
|
-
};
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
816
|
-
AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
|
|
817
|
-
AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
|
|
818
|
-
{
|
|
819
|
-
provide: 'Authentication',
|
|
820
|
-
useFactory: (authenticationService, userRepository) => {
|
|
821
|
-
return new Authentication(authenticationService, userRepository);
|
|
822
|
-
},
|
|
823
|
-
deps: ['AuthenticationService', 'UserRepository'],
|
|
824
|
-
},
|
|
825
|
-
{
|
|
826
|
-
provide: 'AuthenticationService',
|
|
827
|
-
useFactory: (angularFireAuth) => {
|
|
828
|
-
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
829
|
-
},
|
|
830
|
-
deps: [AngularFireAuth],
|
|
831
|
-
},
|
|
832
|
-
{
|
|
833
|
-
provide: 'Register',
|
|
834
|
-
useFactory: (registerService, userRepository) => {
|
|
835
|
-
return new Register(registerService, userRepository);
|
|
836
|
-
},
|
|
837
|
-
deps: ['RegisterService', 'UserRepository'],
|
|
838
|
-
},
|
|
839
|
-
{
|
|
840
|
-
provide: 'RegisterService',
|
|
841
|
-
useFactory: (angularFireAuth) => {
|
|
842
|
-
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
843
|
-
},
|
|
844
|
-
deps: [AngularFireAuth],
|
|
845
|
-
},
|
|
846
|
-
{
|
|
847
|
-
provide: 'SignOut',
|
|
848
|
-
useFactory: (authenticationService) => {
|
|
849
|
-
return new SignOut(authenticationService);
|
|
850
|
-
},
|
|
851
|
-
deps: ['AuthenticationService'],
|
|
852
|
-
},
|
|
853
|
-
{
|
|
854
|
-
provide: 'RecoveryPassword',
|
|
855
|
-
useFactory: (authenticationService) => {
|
|
856
|
-
return new RecoveryPassword(authenticationService);
|
|
857
|
-
},
|
|
858
|
-
deps: ['AuthenticationService'],
|
|
859
|
-
},
|
|
860
|
-
], imports: [[AngularFireModule]] });
|
|
861
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
|
|
862
|
-
type: NgModule,
|
|
863
|
-
args: [{
|
|
864
|
-
imports: [AngularFireModule],
|
|
865
|
-
providers: [
|
|
866
|
-
{
|
|
867
|
-
provide: 'Authentication',
|
|
868
|
-
useFactory: (authenticationService, userRepository) => {
|
|
869
|
-
return new Authentication(authenticationService, userRepository);
|
|
870
|
-
},
|
|
871
|
-
deps: ['AuthenticationService', 'UserRepository'],
|
|
872
|
-
},
|
|
873
|
-
{
|
|
874
|
-
provide: 'AuthenticationService',
|
|
875
|
-
useFactory: (angularFireAuth) => {
|
|
876
|
-
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
877
|
-
},
|
|
878
|
-
deps: [AngularFireAuth],
|
|
879
|
-
},
|
|
880
|
-
{
|
|
881
|
-
provide: 'Register',
|
|
882
|
-
useFactory: (registerService, userRepository) => {
|
|
883
|
-
return new Register(registerService, userRepository);
|
|
884
|
-
},
|
|
885
|
-
deps: ['RegisterService', 'UserRepository'],
|
|
886
|
-
},
|
|
887
|
-
{
|
|
888
|
-
provide: 'RegisterService',
|
|
889
|
-
useFactory: (angularFireAuth) => {
|
|
890
|
-
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
891
|
-
},
|
|
892
|
-
deps: [AngularFireAuth],
|
|
893
|
-
},
|
|
894
|
-
{
|
|
895
|
-
provide: 'SignOut',
|
|
896
|
-
useFactory: (authenticationService) => {
|
|
897
|
-
return new SignOut(authenticationService);
|
|
898
|
-
},
|
|
899
|
-
deps: ['AuthenticationService'],
|
|
900
|
-
},
|
|
901
|
-
{
|
|
902
|
-
provide: 'RecoveryPassword',
|
|
903
|
-
useFactory: (authenticationService) => {
|
|
904
|
-
return new RecoveryPassword(authenticationService);
|
|
905
|
-
},
|
|
906
|
-
deps: ['AuthenticationService'],
|
|
907
|
-
},
|
|
908
|
-
],
|
|
909
|
-
}]
|
|
890
|
+
class AngularFirebaseAuthModule {
|
|
891
|
+
static initializeApp(options, nameOrConfig) {
|
|
892
|
+
return {
|
|
893
|
+
ngModule: AngularFirebaseAuthModule,
|
|
894
|
+
providers: [
|
|
895
|
+
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
896
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
897
|
+
],
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
902
|
+
AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
|
|
903
|
+
AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
|
|
904
|
+
{
|
|
905
|
+
provide: 'Authentication',
|
|
906
|
+
useFactory: (authenticationService, userRepository) => {
|
|
907
|
+
return new Authentication(authenticationService, userRepository);
|
|
908
|
+
},
|
|
909
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
provide: 'AuthenticationService',
|
|
913
|
+
useFactory: (angularFireAuth) => {
|
|
914
|
+
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
915
|
+
},
|
|
916
|
+
deps: [AngularFireAuth],
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
provide: 'Register',
|
|
920
|
+
useFactory: (registerService, userRepository) => {
|
|
921
|
+
return new Register(registerService, userRepository);
|
|
922
|
+
},
|
|
923
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
provide: 'RegisterService',
|
|
927
|
+
useFactory: (angularFireAuth) => {
|
|
928
|
+
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
929
|
+
},
|
|
930
|
+
deps: [AngularFireAuth],
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
provide: 'SignOut',
|
|
934
|
+
useFactory: (authenticationService) => {
|
|
935
|
+
return new SignOut(authenticationService);
|
|
936
|
+
},
|
|
937
|
+
deps: ['AuthenticationService'],
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
provide: 'RecoveryPassword',
|
|
941
|
+
useFactory: (authenticationService) => {
|
|
942
|
+
return new RecoveryPassword(authenticationService);
|
|
943
|
+
},
|
|
944
|
+
deps: ['AuthenticationService'],
|
|
945
|
+
},
|
|
946
|
+
], imports: [[AngularFireModule]] });
|
|
947
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
|
|
948
|
+
type: NgModule,
|
|
949
|
+
args: [{
|
|
950
|
+
imports: [AngularFireModule],
|
|
951
|
+
providers: [
|
|
952
|
+
{
|
|
953
|
+
provide: 'Authentication',
|
|
954
|
+
useFactory: (authenticationService, userRepository) => {
|
|
955
|
+
return new Authentication(authenticationService, userRepository);
|
|
956
|
+
},
|
|
957
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
958
|
+
},
|
|
959
|
+
{
|
|
960
|
+
provide: 'AuthenticationService',
|
|
961
|
+
useFactory: (angularFireAuth) => {
|
|
962
|
+
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
963
|
+
},
|
|
964
|
+
deps: [AngularFireAuth],
|
|
965
|
+
},
|
|
966
|
+
{
|
|
967
|
+
provide: 'Register',
|
|
968
|
+
useFactory: (registerService, userRepository) => {
|
|
969
|
+
return new Register(registerService, userRepository);
|
|
970
|
+
},
|
|
971
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
provide: 'RegisterService',
|
|
975
|
+
useFactory: (angularFireAuth) => {
|
|
976
|
+
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
977
|
+
},
|
|
978
|
+
deps: [AngularFireAuth],
|
|
979
|
+
},
|
|
980
|
+
{
|
|
981
|
+
provide: 'SignOut',
|
|
982
|
+
useFactory: (authenticationService) => {
|
|
983
|
+
return new SignOut(authenticationService);
|
|
984
|
+
},
|
|
985
|
+
deps: ['AuthenticationService'],
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
provide: 'RecoveryPassword',
|
|
989
|
+
useFactory: (authenticationService) => {
|
|
990
|
+
return new RecoveryPassword(authenticationService);
|
|
991
|
+
},
|
|
992
|
+
deps: ['AuthenticationService'],
|
|
993
|
+
},
|
|
994
|
+
],
|
|
995
|
+
}]
|
|
910
996
|
}] });
|
|
911
997
|
|
|
912
|
-
class AngularElasticSeachModule {
|
|
913
|
-
static initializeApp(options) {
|
|
914
|
-
return {
|
|
915
|
-
ngModule: AngularElasticSeachModule,
|
|
916
|
-
providers: [{ provide: ES_CONFIG, useValue: options }],
|
|
917
|
-
};
|
|
918
|
-
}
|
|
919
|
-
}
|
|
920
|
-
AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
921
|
-
AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule });
|
|
922
|
-
AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, providers: [
|
|
923
|
-
{
|
|
924
|
-
provide: ProductsIndex,
|
|
925
|
-
useFactory: (configuration) => {
|
|
926
|
-
return new ProductsIndex(new AxiosAdapter(configuration));
|
|
927
|
-
},
|
|
928
|
-
deps: [ES_CONFIG],
|
|
929
|
-
},
|
|
930
|
-
] });
|
|
931
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
|
|
932
|
-
type: NgModule,
|
|
933
|
-
args: [{
|
|
934
|
-
providers: [
|
|
935
|
-
{
|
|
936
|
-
provide: ProductsIndex,
|
|
937
|
-
useFactory: (configuration) => {
|
|
938
|
-
return new ProductsIndex(new AxiosAdapter(configuration));
|
|
939
|
-
},
|
|
940
|
-
deps: [ES_CONFIG],
|
|
941
|
-
},
|
|
942
|
-
],
|
|
943
|
-
}]
|
|
998
|
+
class AngularElasticSeachModule {
|
|
999
|
+
static initializeApp(options) {
|
|
1000
|
+
return {
|
|
1001
|
+
ngModule: AngularElasticSeachModule,
|
|
1002
|
+
providers: [{ provide: ES_CONFIG, useValue: options }],
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1007
|
+
AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule });
|
|
1008
|
+
AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, providers: [
|
|
1009
|
+
{
|
|
1010
|
+
provide: ProductsIndex,
|
|
1011
|
+
useFactory: (configuration) => {
|
|
1012
|
+
return new ProductsIndex(new AxiosAdapter(configuration));
|
|
1013
|
+
},
|
|
1014
|
+
deps: [ES_CONFIG],
|
|
1015
|
+
},
|
|
1016
|
+
] });
|
|
1017
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
|
|
1018
|
+
type: NgModule,
|
|
1019
|
+
args: [{
|
|
1020
|
+
providers: [
|
|
1021
|
+
{
|
|
1022
|
+
provide: ProductsIndex,
|
|
1023
|
+
useFactory: (configuration) => {
|
|
1024
|
+
return new ProductsIndex(new AxiosAdapter(configuration));
|
|
1025
|
+
},
|
|
1026
|
+
deps: [ES_CONFIG],
|
|
1027
|
+
},
|
|
1028
|
+
],
|
|
1029
|
+
}]
|
|
944
1030
|
}] });
|
|
945
1031
|
|
|
946
|
-
class AngularFirestoreModule {
|
|
947
|
-
static initializeApp(options, nameOrConfig) {
|
|
948
|
-
return {
|
|
949
|
-
ngModule: AngularFirestoreModule,
|
|
950
|
-
providers: [
|
|
951
|
-
{ provide: FIREBASE_OPTIONS, useValue: options.firebase },
|
|
952
|
-
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
953
|
-
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
954
|
-
],
|
|
955
|
-
};
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
959
|
-
AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule, AngularElasticSeachModule] });
|
|
960
|
-
AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
|
|
961
|
-
{
|
|
962
|
-
provide: 'BeautyProfileRepository',
|
|
963
|
-
useFactory: (firestore, userRepository) => {
|
|
964
|
-
return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
965
|
-
},
|
|
966
|
-
deps: [AngularFirestore, 'UserRepository'],
|
|
967
|
-
},
|
|
968
|
-
{
|
|
969
|
-
provide: 'Buy2WinRepository',
|
|
970
|
-
useFactory: (firestore) => {
|
|
971
|
-
return new Buy2WinFirestoreRepository(firestore.firestore);
|
|
972
|
-
},
|
|
973
|
-
deps: [AngularFirestore],
|
|
974
|
-
},
|
|
975
|
-
{
|
|
976
|
-
provide: CategoryFirestoreRepository,
|
|
977
|
-
useFactory: (firestore) => {
|
|
978
|
-
return new CategoryFirestoreRepository(firestore.firestore);
|
|
979
|
-
},
|
|
980
|
-
deps: [AngularFirestore],
|
|
981
|
-
},
|
|
982
|
-
{
|
|
983
|
-
provide: 'CheckoutRepository',
|
|
984
|
-
useFactory: (firestore) => {
|
|
985
|
-
return new CheckoutFirestoreRepository(firestore.firestore);
|
|
986
|
-
},
|
|
987
|
-
deps: [AngularFirestore],
|
|
988
|
-
},
|
|
989
|
-
{
|
|
990
|
-
provide: 'CheckoutSubscriptionRepository',
|
|
991
|
-
useFactory: (firestore) => {
|
|
992
|
-
return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
993
|
-
},
|
|
994
|
-
deps: [AngularFirestore],
|
|
995
|
-
},
|
|
996
|
-
{
|
|
997
|
-
provide: 'CouponRepository',
|
|
998
|
-
useFactory: (firestore) => {
|
|
999
|
-
return new CouponFirestoreRepository(firestore.firestore);
|
|
1000
|
-
},
|
|
1001
|
-
deps: [AngularFirestore],
|
|
1002
|
-
},
|
|
1003
|
-
{
|
|
1004
|
-
provide: 'CampaignHashtagRepository',
|
|
1005
|
-
useFactory: (firestore) => {
|
|
1006
|
-
return new CampaignHashtagFirestoreRepository(firestore.firestore);
|
|
1007
|
-
},
|
|
1008
|
-
deps: [AngularFirestore],
|
|
1009
|
-
},
|
|
1010
|
-
{
|
|
1011
|
-
provide: 'CampaignDashboardRepository',
|
|
1012
|
-
useFactory: (firestore) => {
|
|
1013
|
-
return new CampaignDashboardFirestoreRepository(firestore.firestore);
|
|
1014
|
-
},
|
|
1015
|
-
deps: [AngularFirestore],
|
|
1016
|
-
},
|
|
1017
|
-
{
|
|
1018
|
-
provide: 'EditionRepository',
|
|
1019
|
-
useFactory: (firestore, subscriptionRepository) => {
|
|
1020
|
-
return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
1021
|
-
},
|
|
1022
|
-
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
1023
|
-
},
|
|
1024
|
-
{
|
|
1025
|
-
provide: 'HomeRepository',
|
|
1026
|
-
useFactory: (firestore) => {
|
|
1027
|
-
return new HomeFirestoreRepository(firestore.firestore);
|
|
1028
|
-
},
|
|
1029
|
-
deps: [AngularFirestore],
|
|
1030
|
-
},
|
|
1031
|
-
{
|
|
1032
|
-
provide: 'LeadRepository',
|
|
1033
|
-
useFactory: (firestore) => {
|
|
1034
|
-
return new LeadFirestoreRepository(firestore.firestore);
|
|
1035
|
-
},
|
|
1036
|
-
deps: [AngularFirestore],
|
|
1037
|
-
},
|
|
1038
|
-
{
|
|
1039
|
-
provide: 'LegacyOrderRepository',
|
|
1040
|
-
useFactory: (firestore) => {
|
|
1041
|
-
return new LegacyOrderFirestoreRepository(firestore.firestore);
|
|
1042
|
-
},
|
|
1043
|
-
deps: [AngularFirestore],
|
|
1044
|
-
},
|
|
1045
|
-
{
|
|
1046
|
-
provide: 'ShopMenuRepository',
|
|
1047
|
-
useFactory: (firestore) => {
|
|
1048
|
-
return new ShopMenuFirestoreRepository(firestore.firestore);
|
|
1049
|
-
},
|
|
1050
|
-
deps: [AngularFirestore],
|
|
1051
|
-
},
|
|
1052
|
-
{
|
|
1053
|
-
provide: 'OrderRepository',
|
|
1054
|
-
useFactory: (firestore) => {
|
|
1055
|
-
return new OrderFirestoreRepository(firestore.firestore);
|
|
1056
|
-
},
|
|
1057
|
-
deps: [AngularFirestore],
|
|
1058
|
-
},
|
|
1059
|
-
{
|
|
1060
|
-
provide: 'PaymentRepository',
|
|
1061
|
-
useFactory: (firestore) => {
|
|
1062
|
-
return new PaymentFirestoreRepository(firestore.firestore);
|
|
1063
|
-
},
|
|
1064
|
-
deps: [AngularFirestore],
|
|
1065
|
-
},
|
|
1066
|
-
{
|
|
1067
|
-
provide: ProductFirestoreRepository,
|
|
1068
|
-
useFactory: (firestore) => {
|
|
1069
|
-
return new ProductFirestoreRepository(firestore.firestore);
|
|
1070
|
-
},
|
|
1071
|
-
deps: [AngularFirestore],
|
|
1072
|
-
},
|
|
1073
|
-
{
|
|
1074
|
-
provide: 'ShopSettingsRepository',
|
|
1075
|
-
useFactory: (firestore) => {
|
|
1076
|
-
return new ShopSettingsFirestoreRepository(firestore.firestore);
|
|
1077
|
-
},
|
|
1078
|
-
deps: [AngularFirestore],
|
|
1079
|
-
},
|
|
1080
|
-
{
|
|
1081
|
-
provide: 'SubscriptionPaymentRepository',
|
|
1082
|
-
useFactory: (firestore, subscriptionRepository) => {
|
|
1083
|
-
return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
1084
|
-
},
|
|
1085
|
-
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
1086
|
-
},
|
|
1087
|
-
{
|
|
1088
|
-
provide: 'SubscriptionPlanRepository',
|
|
1089
|
-
useFactory: (firestore) => {
|
|
1090
|
-
return new SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
1091
|
-
},
|
|
1092
|
-
deps: [AngularFirestore],
|
|
1093
|
-
},
|
|
1094
|
-
{
|
|
1095
|
-
provide: 'SubscriptionProductRepository',
|
|
1096
|
-
useFactory: (firestore) => {
|
|
1097
|
-
return new SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
1098
|
-
},
|
|
1099
|
-
deps: [AngularFirestore],
|
|
1100
|
-
},
|
|
1101
|
-
{
|
|
1102
|
-
provide: 'SubscriptionRepository',
|
|
1103
|
-
useFactory: (firestore) => {
|
|
1104
|
-
return new SubscriptionFirestoreRepository(firestore.firestore);
|
|
1105
|
-
},
|
|
1106
|
-
deps: [AngularFirestore],
|
|
1107
|
-
},
|
|
1108
|
-
{
|
|
1109
|
-
provide: 'UserRepository',
|
|
1110
|
-
useFactory: (firestore) => {
|
|
1111
|
-
return new UserFirestoreRepository(firestore.firestore);
|
|
1112
|
-
},
|
|
1113
|
-
deps: [AngularFirestore],
|
|
1114
|
-
},
|
|
1115
|
-
{
|
|
1116
|
-
provide: 'UserAddressRepository',
|
|
1117
|
-
useFactory: (firestore, userRepository) => {
|
|
1118
|
-
return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
1119
|
-
},
|
|
1120
|
-
deps: [AngularFirestore, 'UserRepository'],
|
|
1121
|
-
},
|
|
1122
|
-
{
|
|
1123
|
-
provide: 'UserPaymentMethodRepository',
|
|
1124
|
-
useFactory: (firestore, userRepository) => {
|
|
1125
|
-
return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
1126
|
-
},
|
|
1127
|
-
deps: [AngularFirestore, 'UserRepository'],
|
|
1128
|
-
},
|
|
1129
|
-
{
|
|
1130
|
-
provide: ProductVariantFirestoreRepository,
|
|
1131
|
-
useFactory: (firestore, productRepository) => {
|
|
1132
|
-
return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
1133
|
-
},
|
|
1134
|
-
deps: [AngularFirestore, ProductFirestoreRepository],
|
|
1135
|
-
},
|
|
1136
|
-
{
|
|
1137
|
-
provide: APP_INITIALIZER,
|
|
1138
|
-
useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
|
|
1139
|
-
deps: [AngularFirestore],
|
|
1140
|
-
multi: true,
|
|
1141
|
-
},
|
|
1142
|
-
], imports: [[AngularFireModule, AngularElasticSeachModule]] });
|
|
1143
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
1144
|
-
type: NgModule,
|
|
1145
|
-
args: [{
|
|
1146
|
-
imports: [AngularFireModule, AngularElasticSeachModule],
|
|
1147
|
-
providers: [
|
|
1148
|
-
{
|
|
1149
|
-
provide: 'BeautyProfileRepository',
|
|
1150
|
-
useFactory: (firestore, userRepository) => {
|
|
1151
|
-
return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
1152
|
-
},
|
|
1153
|
-
deps: [AngularFirestore, 'UserRepository'],
|
|
1154
|
-
},
|
|
1155
|
-
{
|
|
1156
|
-
provide: 'Buy2WinRepository',
|
|
1157
|
-
useFactory: (firestore) => {
|
|
1158
|
-
return new Buy2WinFirestoreRepository(firestore.firestore);
|
|
1159
|
-
},
|
|
1160
|
-
deps: [AngularFirestore],
|
|
1161
|
-
},
|
|
1162
|
-
{
|
|
1163
|
-
provide: CategoryFirestoreRepository,
|
|
1164
|
-
useFactory: (firestore) => {
|
|
1165
|
-
return new CategoryFirestoreRepository(firestore.firestore);
|
|
1166
|
-
},
|
|
1167
|
-
deps: [AngularFirestore],
|
|
1168
|
-
},
|
|
1169
|
-
{
|
|
1170
|
-
provide: 'CheckoutRepository',
|
|
1171
|
-
useFactory: (firestore) => {
|
|
1172
|
-
return new CheckoutFirestoreRepository(firestore.firestore);
|
|
1173
|
-
},
|
|
1174
|
-
deps: [AngularFirestore],
|
|
1175
|
-
},
|
|
1176
|
-
{
|
|
1177
|
-
provide: 'CheckoutSubscriptionRepository',
|
|
1178
|
-
useFactory: (firestore) => {
|
|
1179
|
-
return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
1180
|
-
},
|
|
1181
|
-
deps: [AngularFirestore],
|
|
1182
|
-
},
|
|
1183
|
-
{
|
|
1184
|
-
provide: 'CouponRepository',
|
|
1185
|
-
useFactory: (firestore) => {
|
|
1186
|
-
return new CouponFirestoreRepository(firestore.firestore);
|
|
1187
|
-
},
|
|
1188
|
-
deps: [AngularFirestore],
|
|
1189
|
-
},
|
|
1190
|
-
{
|
|
1191
|
-
provide: 'CampaignHashtagRepository',
|
|
1192
|
-
useFactory: (firestore) => {
|
|
1193
|
-
return new CampaignHashtagFirestoreRepository(firestore.firestore);
|
|
1194
|
-
},
|
|
1195
|
-
deps: [AngularFirestore],
|
|
1196
|
-
},
|
|
1197
|
-
{
|
|
1198
|
-
provide: 'CampaignDashboardRepository',
|
|
1199
|
-
useFactory: (firestore) => {
|
|
1200
|
-
return new CampaignDashboardFirestoreRepository(firestore.firestore);
|
|
1201
|
-
},
|
|
1202
|
-
deps: [AngularFirestore],
|
|
1203
|
-
},
|
|
1204
|
-
{
|
|
1205
|
-
provide: 'EditionRepository',
|
|
1206
|
-
useFactory: (firestore, subscriptionRepository) => {
|
|
1207
|
-
return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
1208
|
-
},
|
|
1209
|
-
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
1210
|
-
},
|
|
1211
|
-
{
|
|
1212
|
-
provide: 'HomeRepository',
|
|
1213
|
-
useFactory: (firestore) => {
|
|
1214
|
-
return new HomeFirestoreRepository(firestore.firestore);
|
|
1215
|
-
},
|
|
1216
|
-
deps: [AngularFirestore],
|
|
1217
|
-
},
|
|
1218
|
-
{
|
|
1219
|
-
provide: 'LeadRepository',
|
|
1220
|
-
useFactory: (firestore) => {
|
|
1221
|
-
return new LeadFirestoreRepository(firestore.firestore);
|
|
1222
|
-
},
|
|
1223
|
-
deps: [AngularFirestore],
|
|
1224
|
-
},
|
|
1225
|
-
{
|
|
1226
|
-
provide: 'LegacyOrderRepository',
|
|
1227
|
-
useFactory: (firestore) => {
|
|
1228
|
-
return new LegacyOrderFirestoreRepository(firestore.firestore);
|
|
1229
|
-
},
|
|
1230
|
-
deps: [AngularFirestore],
|
|
1231
|
-
},
|
|
1232
|
-
{
|
|
1233
|
-
provide: 'ShopMenuRepository',
|
|
1234
|
-
useFactory: (firestore) => {
|
|
1235
|
-
return new ShopMenuFirestoreRepository(firestore.firestore);
|
|
1236
|
-
},
|
|
1237
|
-
deps: [AngularFirestore],
|
|
1238
|
-
},
|
|
1239
|
-
{
|
|
1240
|
-
provide: 'OrderRepository',
|
|
1241
|
-
useFactory: (firestore) => {
|
|
1242
|
-
return new OrderFirestoreRepository(firestore.firestore);
|
|
1243
|
-
},
|
|
1244
|
-
deps: [AngularFirestore],
|
|
1245
|
-
},
|
|
1246
|
-
{
|
|
1247
|
-
provide: 'PaymentRepository',
|
|
1248
|
-
useFactory: (firestore) => {
|
|
1249
|
-
return new PaymentFirestoreRepository(firestore.firestore);
|
|
1250
|
-
},
|
|
1251
|
-
deps: [AngularFirestore],
|
|
1252
|
-
},
|
|
1253
|
-
{
|
|
1254
|
-
provide: ProductFirestoreRepository,
|
|
1255
|
-
useFactory: (firestore) => {
|
|
1256
|
-
return new ProductFirestoreRepository(firestore.firestore);
|
|
1257
|
-
},
|
|
1258
|
-
deps: [AngularFirestore],
|
|
1259
|
-
},
|
|
1260
|
-
{
|
|
1261
|
-
provide: 'ShopSettingsRepository',
|
|
1262
|
-
useFactory: (firestore) => {
|
|
1263
|
-
return new ShopSettingsFirestoreRepository(firestore.firestore);
|
|
1264
|
-
},
|
|
1265
|
-
deps: [AngularFirestore],
|
|
1266
|
-
},
|
|
1267
|
-
{
|
|
1268
|
-
provide: 'SubscriptionPaymentRepository',
|
|
1269
|
-
useFactory: (firestore, subscriptionRepository) => {
|
|
1270
|
-
return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
1271
|
-
},
|
|
1272
|
-
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
1273
|
-
},
|
|
1274
|
-
{
|
|
1275
|
-
provide: 'SubscriptionPlanRepository',
|
|
1276
|
-
useFactory: (firestore) => {
|
|
1277
|
-
return new SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
1278
|
-
},
|
|
1279
|
-
deps: [AngularFirestore],
|
|
1280
|
-
},
|
|
1281
|
-
{
|
|
1282
|
-
provide: 'SubscriptionProductRepository',
|
|
1283
|
-
useFactory: (firestore) => {
|
|
1284
|
-
return new SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
1285
|
-
},
|
|
1286
|
-
deps: [AngularFirestore],
|
|
1287
|
-
},
|
|
1288
|
-
{
|
|
1289
|
-
provide: 'SubscriptionRepository',
|
|
1290
|
-
useFactory: (firestore) => {
|
|
1291
|
-
return new SubscriptionFirestoreRepository(firestore.firestore);
|
|
1292
|
-
},
|
|
1293
|
-
deps: [AngularFirestore],
|
|
1294
|
-
},
|
|
1295
|
-
{
|
|
1296
|
-
provide: 'UserRepository',
|
|
1297
|
-
useFactory: (firestore) => {
|
|
1298
|
-
return new UserFirestoreRepository(firestore.firestore);
|
|
1299
|
-
},
|
|
1300
|
-
deps: [AngularFirestore],
|
|
1301
|
-
},
|
|
1302
|
-
{
|
|
1303
|
-
provide: 'UserAddressRepository',
|
|
1304
|
-
useFactory: (firestore, userRepository) => {
|
|
1305
|
-
return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
1306
|
-
},
|
|
1307
|
-
deps: [AngularFirestore, 'UserRepository'],
|
|
1308
|
-
},
|
|
1309
|
-
{
|
|
1310
|
-
provide: 'UserPaymentMethodRepository',
|
|
1311
|
-
useFactory: (firestore, userRepository) => {
|
|
1312
|
-
return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
1313
|
-
},
|
|
1314
|
-
deps: [AngularFirestore, 'UserRepository'],
|
|
1315
|
-
},
|
|
1316
|
-
{
|
|
1317
|
-
provide: ProductVariantFirestoreRepository,
|
|
1318
|
-
useFactory: (firestore, productRepository) => {
|
|
1319
|
-
return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
1320
|
-
},
|
|
1321
|
-
deps: [AngularFirestore, ProductFirestoreRepository],
|
|
1322
|
-
},
|
|
1323
|
-
{
|
|
1324
|
-
provide: APP_INITIALIZER,
|
|
1325
|
-
useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
|
|
1326
|
-
deps: [AngularFirestore],
|
|
1327
|
-
multi: true,
|
|
1328
|
-
},
|
|
1329
|
-
],
|
|
1330
|
-
}]
|
|
1032
|
+
class AngularFirestoreModule {
|
|
1033
|
+
static initializeApp(options, nameOrConfig) {
|
|
1034
|
+
return {
|
|
1035
|
+
ngModule: AngularFirestoreModule,
|
|
1036
|
+
providers: [
|
|
1037
|
+
{ provide: FIREBASE_OPTIONS, useValue: options.firebase },
|
|
1038
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
1039
|
+
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
1040
|
+
],
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1045
|
+
AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule, AngularElasticSeachModule] });
|
|
1046
|
+
AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
|
|
1047
|
+
{
|
|
1048
|
+
provide: 'BeautyProfileRepository',
|
|
1049
|
+
useFactory: (firestore, userRepository) => {
|
|
1050
|
+
return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
1051
|
+
},
|
|
1052
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
provide: 'Buy2WinRepository',
|
|
1056
|
+
useFactory: (firestore) => {
|
|
1057
|
+
return new Buy2WinFirestoreRepository(firestore.firestore);
|
|
1058
|
+
},
|
|
1059
|
+
deps: [AngularFirestore],
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
provide: CategoryFirestoreRepository,
|
|
1063
|
+
useFactory: (firestore) => {
|
|
1064
|
+
return new CategoryFirestoreRepository(firestore.firestore);
|
|
1065
|
+
},
|
|
1066
|
+
deps: [AngularFirestore],
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
provide: 'CheckoutRepository',
|
|
1070
|
+
useFactory: (firestore) => {
|
|
1071
|
+
return new CheckoutFirestoreRepository(firestore.firestore);
|
|
1072
|
+
},
|
|
1073
|
+
deps: [AngularFirestore],
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
1077
|
+
useFactory: (firestore) => {
|
|
1078
|
+
return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
1079
|
+
},
|
|
1080
|
+
deps: [AngularFirestore],
|
|
1081
|
+
},
|
|
1082
|
+
{
|
|
1083
|
+
provide: 'CouponRepository',
|
|
1084
|
+
useFactory: (firestore) => {
|
|
1085
|
+
return new CouponFirestoreRepository(firestore.firestore);
|
|
1086
|
+
},
|
|
1087
|
+
deps: [AngularFirestore],
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
provide: 'CampaignHashtagRepository',
|
|
1091
|
+
useFactory: (firestore) => {
|
|
1092
|
+
return new CampaignHashtagFirestoreRepository(firestore.firestore);
|
|
1093
|
+
},
|
|
1094
|
+
deps: [AngularFirestore],
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
provide: 'CampaignDashboardRepository',
|
|
1098
|
+
useFactory: (firestore) => {
|
|
1099
|
+
return new CampaignDashboardFirestoreRepository(firestore.firestore);
|
|
1100
|
+
},
|
|
1101
|
+
deps: [AngularFirestore],
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
provide: 'EditionRepository',
|
|
1105
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
1106
|
+
return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
1107
|
+
},
|
|
1108
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
1109
|
+
},
|
|
1110
|
+
{
|
|
1111
|
+
provide: 'HomeRepository',
|
|
1112
|
+
useFactory: (firestore) => {
|
|
1113
|
+
return new HomeFirestoreRepository(firestore.firestore);
|
|
1114
|
+
},
|
|
1115
|
+
deps: [AngularFirestore],
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
provide: 'LeadRepository',
|
|
1119
|
+
useFactory: (firestore) => {
|
|
1120
|
+
return new LeadFirestoreRepository(firestore.firestore);
|
|
1121
|
+
},
|
|
1122
|
+
deps: [AngularFirestore],
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
provide: 'LegacyOrderRepository',
|
|
1126
|
+
useFactory: (firestore) => {
|
|
1127
|
+
return new LegacyOrderFirestoreRepository(firestore.firestore);
|
|
1128
|
+
},
|
|
1129
|
+
deps: [AngularFirestore],
|
|
1130
|
+
},
|
|
1131
|
+
{
|
|
1132
|
+
provide: 'ShopMenuRepository',
|
|
1133
|
+
useFactory: (firestore) => {
|
|
1134
|
+
return new ShopMenuFirestoreRepository(firestore.firestore);
|
|
1135
|
+
},
|
|
1136
|
+
deps: [AngularFirestore],
|
|
1137
|
+
},
|
|
1138
|
+
{
|
|
1139
|
+
provide: 'OrderRepository',
|
|
1140
|
+
useFactory: (firestore) => {
|
|
1141
|
+
return new OrderFirestoreRepository(firestore.firestore);
|
|
1142
|
+
},
|
|
1143
|
+
deps: [AngularFirestore],
|
|
1144
|
+
},
|
|
1145
|
+
{
|
|
1146
|
+
provide: 'PaymentRepository',
|
|
1147
|
+
useFactory: (firestore) => {
|
|
1148
|
+
return new PaymentFirestoreRepository(firestore.firestore);
|
|
1149
|
+
},
|
|
1150
|
+
deps: [AngularFirestore],
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
provide: ProductFirestoreRepository,
|
|
1154
|
+
useFactory: (firestore) => {
|
|
1155
|
+
return new ProductFirestoreRepository(firestore.firestore);
|
|
1156
|
+
},
|
|
1157
|
+
deps: [AngularFirestore],
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
provide: 'ShopSettingsRepository',
|
|
1161
|
+
useFactory: (firestore) => {
|
|
1162
|
+
return new ShopSettingsFirestoreRepository(firestore.firestore);
|
|
1163
|
+
},
|
|
1164
|
+
deps: [AngularFirestore],
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
provide: 'SubscriptionPaymentRepository',
|
|
1168
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
1169
|
+
return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
1170
|
+
},
|
|
1171
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
provide: 'SubscriptionPlanRepository',
|
|
1175
|
+
useFactory: (firestore) => {
|
|
1176
|
+
return new SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
1177
|
+
},
|
|
1178
|
+
deps: [AngularFirestore],
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
provide: 'SubscriptionProductRepository',
|
|
1182
|
+
useFactory: (firestore) => {
|
|
1183
|
+
return new SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
1184
|
+
},
|
|
1185
|
+
deps: [AngularFirestore],
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
provide: 'SubscriptionRepository',
|
|
1189
|
+
useFactory: (firestore) => {
|
|
1190
|
+
return new SubscriptionFirestoreRepository(firestore.firestore);
|
|
1191
|
+
},
|
|
1192
|
+
deps: [AngularFirestore],
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
provide: 'UserRepository',
|
|
1196
|
+
useFactory: (firestore) => {
|
|
1197
|
+
return new UserFirestoreRepository(firestore.firestore);
|
|
1198
|
+
},
|
|
1199
|
+
deps: [AngularFirestore],
|
|
1200
|
+
},
|
|
1201
|
+
{
|
|
1202
|
+
provide: 'UserAddressRepository',
|
|
1203
|
+
useFactory: (firestore, userRepository) => {
|
|
1204
|
+
return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
1205
|
+
},
|
|
1206
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
1207
|
+
},
|
|
1208
|
+
{
|
|
1209
|
+
provide: 'UserPaymentMethodRepository',
|
|
1210
|
+
useFactory: (firestore, userRepository) => {
|
|
1211
|
+
return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
1212
|
+
},
|
|
1213
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
1214
|
+
},
|
|
1215
|
+
{
|
|
1216
|
+
provide: ProductVariantFirestoreRepository,
|
|
1217
|
+
useFactory: (firestore, productRepository) => {
|
|
1218
|
+
return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
1219
|
+
},
|
|
1220
|
+
deps: [AngularFirestore, ProductFirestoreRepository],
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
provide: APP_INITIALIZER,
|
|
1224
|
+
useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
|
|
1225
|
+
deps: [AngularFirestore],
|
|
1226
|
+
multi: true,
|
|
1227
|
+
},
|
|
1228
|
+
], imports: [[AngularFireModule, AngularElasticSeachModule]] });
|
|
1229
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
1230
|
+
type: NgModule,
|
|
1231
|
+
args: [{
|
|
1232
|
+
imports: [AngularFireModule, AngularElasticSeachModule],
|
|
1233
|
+
providers: [
|
|
1234
|
+
{
|
|
1235
|
+
provide: 'BeautyProfileRepository',
|
|
1236
|
+
useFactory: (firestore, userRepository) => {
|
|
1237
|
+
return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
1238
|
+
},
|
|
1239
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
1240
|
+
},
|
|
1241
|
+
{
|
|
1242
|
+
provide: 'Buy2WinRepository',
|
|
1243
|
+
useFactory: (firestore) => {
|
|
1244
|
+
return new Buy2WinFirestoreRepository(firestore.firestore);
|
|
1245
|
+
},
|
|
1246
|
+
deps: [AngularFirestore],
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
provide: CategoryFirestoreRepository,
|
|
1250
|
+
useFactory: (firestore) => {
|
|
1251
|
+
return new CategoryFirestoreRepository(firestore.firestore);
|
|
1252
|
+
},
|
|
1253
|
+
deps: [AngularFirestore],
|
|
1254
|
+
},
|
|
1255
|
+
{
|
|
1256
|
+
provide: 'CheckoutRepository',
|
|
1257
|
+
useFactory: (firestore) => {
|
|
1258
|
+
return new CheckoutFirestoreRepository(firestore.firestore);
|
|
1259
|
+
},
|
|
1260
|
+
deps: [AngularFirestore],
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
1264
|
+
useFactory: (firestore) => {
|
|
1265
|
+
return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
1266
|
+
},
|
|
1267
|
+
deps: [AngularFirestore],
|
|
1268
|
+
},
|
|
1269
|
+
{
|
|
1270
|
+
provide: 'CouponRepository',
|
|
1271
|
+
useFactory: (firestore) => {
|
|
1272
|
+
return new CouponFirestoreRepository(firestore.firestore);
|
|
1273
|
+
},
|
|
1274
|
+
deps: [AngularFirestore],
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
provide: 'CampaignHashtagRepository',
|
|
1278
|
+
useFactory: (firestore) => {
|
|
1279
|
+
return new CampaignHashtagFirestoreRepository(firestore.firestore);
|
|
1280
|
+
},
|
|
1281
|
+
deps: [AngularFirestore],
|
|
1282
|
+
},
|
|
1283
|
+
{
|
|
1284
|
+
provide: 'CampaignDashboardRepository',
|
|
1285
|
+
useFactory: (firestore) => {
|
|
1286
|
+
return new CampaignDashboardFirestoreRepository(firestore.firestore);
|
|
1287
|
+
},
|
|
1288
|
+
deps: [AngularFirestore],
|
|
1289
|
+
},
|
|
1290
|
+
{
|
|
1291
|
+
provide: 'EditionRepository',
|
|
1292
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
1293
|
+
return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
1294
|
+
},
|
|
1295
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
1296
|
+
},
|
|
1297
|
+
{
|
|
1298
|
+
provide: 'HomeRepository',
|
|
1299
|
+
useFactory: (firestore) => {
|
|
1300
|
+
return new HomeFirestoreRepository(firestore.firestore);
|
|
1301
|
+
},
|
|
1302
|
+
deps: [AngularFirestore],
|
|
1303
|
+
},
|
|
1304
|
+
{
|
|
1305
|
+
provide: 'LeadRepository',
|
|
1306
|
+
useFactory: (firestore) => {
|
|
1307
|
+
return new LeadFirestoreRepository(firestore.firestore);
|
|
1308
|
+
},
|
|
1309
|
+
deps: [AngularFirestore],
|
|
1310
|
+
},
|
|
1311
|
+
{
|
|
1312
|
+
provide: 'LegacyOrderRepository',
|
|
1313
|
+
useFactory: (firestore) => {
|
|
1314
|
+
return new LegacyOrderFirestoreRepository(firestore.firestore);
|
|
1315
|
+
},
|
|
1316
|
+
deps: [AngularFirestore],
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
provide: 'ShopMenuRepository',
|
|
1320
|
+
useFactory: (firestore) => {
|
|
1321
|
+
return new ShopMenuFirestoreRepository(firestore.firestore);
|
|
1322
|
+
},
|
|
1323
|
+
deps: [AngularFirestore],
|
|
1324
|
+
},
|
|
1325
|
+
{
|
|
1326
|
+
provide: 'OrderRepository',
|
|
1327
|
+
useFactory: (firestore) => {
|
|
1328
|
+
return new OrderFirestoreRepository(firestore.firestore);
|
|
1329
|
+
},
|
|
1330
|
+
deps: [AngularFirestore],
|
|
1331
|
+
},
|
|
1332
|
+
{
|
|
1333
|
+
provide: 'PaymentRepository',
|
|
1334
|
+
useFactory: (firestore) => {
|
|
1335
|
+
return new PaymentFirestoreRepository(firestore.firestore);
|
|
1336
|
+
},
|
|
1337
|
+
deps: [AngularFirestore],
|
|
1338
|
+
},
|
|
1339
|
+
{
|
|
1340
|
+
provide: ProductFirestoreRepository,
|
|
1341
|
+
useFactory: (firestore) => {
|
|
1342
|
+
return new ProductFirestoreRepository(firestore.firestore);
|
|
1343
|
+
},
|
|
1344
|
+
deps: [AngularFirestore],
|
|
1345
|
+
},
|
|
1346
|
+
{
|
|
1347
|
+
provide: 'ShopSettingsRepository',
|
|
1348
|
+
useFactory: (firestore) => {
|
|
1349
|
+
return new ShopSettingsFirestoreRepository(firestore.firestore);
|
|
1350
|
+
},
|
|
1351
|
+
deps: [AngularFirestore],
|
|
1352
|
+
},
|
|
1353
|
+
{
|
|
1354
|
+
provide: 'SubscriptionPaymentRepository',
|
|
1355
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
1356
|
+
return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
1357
|
+
},
|
|
1358
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
1359
|
+
},
|
|
1360
|
+
{
|
|
1361
|
+
provide: 'SubscriptionPlanRepository',
|
|
1362
|
+
useFactory: (firestore) => {
|
|
1363
|
+
return new SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
1364
|
+
},
|
|
1365
|
+
deps: [AngularFirestore],
|
|
1366
|
+
},
|
|
1367
|
+
{
|
|
1368
|
+
provide: 'SubscriptionProductRepository',
|
|
1369
|
+
useFactory: (firestore) => {
|
|
1370
|
+
return new SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
1371
|
+
},
|
|
1372
|
+
deps: [AngularFirestore],
|
|
1373
|
+
},
|
|
1374
|
+
{
|
|
1375
|
+
provide: 'SubscriptionRepository',
|
|
1376
|
+
useFactory: (firestore) => {
|
|
1377
|
+
return new SubscriptionFirestoreRepository(firestore.firestore);
|
|
1378
|
+
},
|
|
1379
|
+
deps: [AngularFirestore],
|
|
1380
|
+
},
|
|
1381
|
+
{
|
|
1382
|
+
provide: 'UserRepository',
|
|
1383
|
+
useFactory: (firestore) => {
|
|
1384
|
+
return new UserFirestoreRepository(firestore.firestore);
|
|
1385
|
+
},
|
|
1386
|
+
deps: [AngularFirestore],
|
|
1387
|
+
},
|
|
1388
|
+
{
|
|
1389
|
+
provide: 'UserAddressRepository',
|
|
1390
|
+
useFactory: (firestore, userRepository) => {
|
|
1391
|
+
return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
1392
|
+
},
|
|
1393
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
1394
|
+
},
|
|
1395
|
+
{
|
|
1396
|
+
provide: 'UserPaymentMethodRepository',
|
|
1397
|
+
useFactory: (firestore, userRepository) => {
|
|
1398
|
+
return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
1399
|
+
},
|
|
1400
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
1401
|
+
},
|
|
1402
|
+
{
|
|
1403
|
+
provide: ProductVariantFirestoreRepository,
|
|
1404
|
+
useFactory: (firestore, productRepository) => {
|
|
1405
|
+
return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
1406
|
+
},
|
|
1407
|
+
deps: [AngularFirestore, ProductFirestoreRepository],
|
|
1408
|
+
},
|
|
1409
|
+
{
|
|
1410
|
+
provide: APP_INITIALIZER,
|
|
1411
|
+
useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
|
|
1412
|
+
deps: [AngularFirestore],
|
|
1413
|
+
multi: true,
|
|
1414
|
+
},
|
|
1415
|
+
],
|
|
1416
|
+
}]
|
|
1331
1417
|
}] });
|
|
1332
1418
|
|
|
1333
|
-
class AngularHasuraGraphQLModule {
|
|
1334
|
-
static initializeApp(options) {
|
|
1335
|
-
return {
|
|
1336
|
-
ngModule: AngularHasuraGraphQLModule,
|
|
1337
|
-
providers: [{ provide: HASURA_OPTIONS, useValue: options }],
|
|
1338
|
-
};
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1342
|
-
AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule });
|
|
1343
|
-
AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
|
|
1344
|
-
{
|
|
1345
|
-
provide: 'CategoryRepository',
|
|
1346
|
-
useExisting: CategoryHasuraGraphQLRepository,
|
|
1347
|
-
},
|
|
1348
|
-
{
|
|
1349
|
-
provide: CategoryHasuraGraphQLRepository,
|
|
1350
|
-
useFactory: (options, productRepository, categoryFilterRepository) => {
|
|
1351
|
-
return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
|
|
1352
|
-
},
|
|
1353
|
-
deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
1354
|
-
},
|
|
1355
|
-
{
|
|
1356
|
-
provide: 'ProductRepository',
|
|
1357
|
-
useExisting: ProductHasuraGraphQLRepository,
|
|
1358
|
-
},
|
|
1359
|
-
{
|
|
1360
|
-
provide: ProductHasuraGraphQLRepository,
|
|
1361
|
-
useFactory: (options) => {
|
|
1362
|
-
return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1363
|
-
},
|
|
1364
|
-
deps: [HASURA_OPTIONS],
|
|
1365
|
-
},
|
|
1366
|
-
{
|
|
1367
|
-
provide: 'VariantRepository',
|
|
1368
|
-
useExisting: VariantHasuraGraphQLRepository,
|
|
1369
|
-
},
|
|
1370
|
-
{
|
|
1371
|
-
provide: VariantHasuraGraphQLRepository,
|
|
1372
|
-
useFactory: (options) => {
|
|
1373
|
-
return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1374
|
-
},
|
|
1375
|
-
deps: [HASURA_OPTIONS],
|
|
1376
|
-
},
|
|
1377
|
-
{
|
|
1378
|
-
provide: 'CategoryFilterRepository',
|
|
1379
|
-
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
1380
|
-
},
|
|
1381
|
-
{
|
|
1382
|
-
provide: CategoryFilterHasuraGraphQLRepository,
|
|
1383
|
-
useFactory: (options) => {
|
|
1384
|
-
return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1385
|
-
},
|
|
1386
|
-
deps: [HASURA_OPTIONS],
|
|
1387
|
-
},
|
|
1388
|
-
{
|
|
1389
|
-
provide: 'FilterOptionRepository',
|
|
1390
|
-
useExisting: FilterOptionHasuraGraphQLRepository,
|
|
1391
|
-
},
|
|
1392
|
-
{
|
|
1393
|
-
provide: FilterOptionHasuraGraphQLRepository,
|
|
1394
|
-
useFactory: (options) => {
|
|
1395
|
-
return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1396
|
-
},
|
|
1397
|
-
deps: [HASURA_OPTIONS],
|
|
1398
|
-
},
|
|
1399
|
-
{
|
|
1400
|
-
provide: 'FilterRepository',
|
|
1401
|
-
useExisting: FilterHasuraGraphQLRepository,
|
|
1402
|
-
},
|
|
1403
|
-
{
|
|
1404
|
-
provide: FilterHasuraGraphQLRepository,
|
|
1405
|
-
useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
|
|
1406
|
-
return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
|
|
1407
|
-
},
|
|
1408
|
-
deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
1409
|
-
},
|
|
1410
|
-
] });
|
|
1411
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
|
|
1412
|
-
type: NgModule,
|
|
1413
|
-
args: [{
|
|
1414
|
-
providers: [
|
|
1415
|
-
{
|
|
1416
|
-
provide: 'CategoryRepository',
|
|
1417
|
-
useExisting: CategoryHasuraGraphQLRepository,
|
|
1418
|
-
},
|
|
1419
|
-
{
|
|
1420
|
-
provide: CategoryHasuraGraphQLRepository,
|
|
1421
|
-
useFactory: (options, productRepository, categoryFilterRepository) => {
|
|
1422
|
-
return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
|
|
1423
|
-
},
|
|
1424
|
-
deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
1425
|
-
},
|
|
1426
|
-
{
|
|
1427
|
-
provide: 'ProductRepository',
|
|
1428
|
-
useExisting: ProductHasuraGraphQLRepository,
|
|
1429
|
-
},
|
|
1430
|
-
{
|
|
1431
|
-
provide: ProductHasuraGraphQLRepository,
|
|
1432
|
-
useFactory: (options) => {
|
|
1433
|
-
return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1434
|
-
},
|
|
1435
|
-
deps: [HASURA_OPTIONS],
|
|
1436
|
-
},
|
|
1437
|
-
{
|
|
1438
|
-
provide: 'VariantRepository',
|
|
1439
|
-
useExisting: VariantHasuraGraphQLRepository,
|
|
1440
|
-
},
|
|
1441
|
-
{
|
|
1442
|
-
provide: VariantHasuraGraphQLRepository,
|
|
1443
|
-
useFactory: (options) => {
|
|
1444
|
-
return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1445
|
-
},
|
|
1446
|
-
deps: [HASURA_OPTIONS],
|
|
1447
|
-
},
|
|
1448
|
-
{
|
|
1449
|
-
provide: 'CategoryFilterRepository',
|
|
1450
|
-
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
1451
|
-
},
|
|
1452
|
-
{
|
|
1453
|
-
provide: CategoryFilterHasuraGraphQLRepository,
|
|
1454
|
-
useFactory: (options) => {
|
|
1455
|
-
return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1456
|
-
},
|
|
1457
|
-
deps: [HASURA_OPTIONS],
|
|
1458
|
-
},
|
|
1459
|
-
{
|
|
1460
|
-
provide: 'FilterOptionRepository',
|
|
1461
|
-
useExisting: FilterOptionHasuraGraphQLRepository,
|
|
1462
|
-
},
|
|
1463
|
-
{
|
|
1464
|
-
provide: FilterOptionHasuraGraphQLRepository,
|
|
1465
|
-
useFactory: (options) => {
|
|
1466
|
-
return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1467
|
-
},
|
|
1468
|
-
deps: [HASURA_OPTIONS],
|
|
1469
|
-
},
|
|
1470
|
-
{
|
|
1471
|
-
provide: 'FilterRepository',
|
|
1472
|
-
useExisting: FilterHasuraGraphQLRepository,
|
|
1473
|
-
},
|
|
1474
|
-
{
|
|
1475
|
-
provide: FilterHasuraGraphQLRepository,
|
|
1476
|
-
useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
|
|
1477
|
-
return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
|
|
1478
|
-
},
|
|
1479
|
-
deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
1480
|
-
},
|
|
1481
|
-
],
|
|
1482
|
-
}]
|
|
1419
|
+
class AngularHasuraGraphQLModule {
|
|
1420
|
+
static initializeApp(options) {
|
|
1421
|
+
return {
|
|
1422
|
+
ngModule: AngularHasuraGraphQLModule,
|
|
1423
|
+
providers: [{ provide: HASURA_OPTIONS, useValue: options }],
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1428
|
+
AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule });
|
|
1429
|
+
AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
|
|
1430
|
+
{
|
|
1431
|
+
provide: 'CategoryRepository',
|
|
1432
|
+
useExisting: CategoryHasuraGraphQLRepository,
|
|
1433
|
+
},
|
|
1434
|
+
{
|
|
1435
|
+
provide: CategoryHasuraGraphQLRepository,
|
|
1436
|
+
useFactory: (options, productRepository, categoryFilterRepository) => {
|
|
1437
|
+
return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
|
|
1438
|
+
},
|
|
1439
|
+
deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
1440
|
+
},
|
|
1441
|
+
{
|
|
1442
|
+
provide: 'ProductRepository',
|
|
1443
|
+
useExisting: ProductHasuraGraphQLRepository,
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
provide: ProductHasuraGraphQLRepository,
|
|
1447
|
+
useFactory: (options) => {
|
|
1448
|
+
return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1449
|
+
},
|
|
1450
|
+
deps: [HASURA_OPTIONS],
|
|
1451
|
+
},
|
|
1452
|
+
{
|
|
1453
|
+
provide: 'VariantRepository',
|
|
1454
|
+
useExisting: VariantHasuraGraphQLRepository,
|
|
1455
|
+
},
|
|
1456
|
+
{
|
|
1457
|
+
provide: VariantHasuraGraphQLRepository,
|
|
1458
|
+
useFactory: (options) => {
|
|
1459
|
+
return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1460
|
+
},
|
|
1461
|
+
deps: [HASURA_OPTIONS],
|
|
1462
|
+
},
|
|
1463
|
+
{
|
|
1464
|
+
provide: 'CategoryFilterRepository',
|
|
1465
|
+
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
1466
|
+
},
|
|
1467
|
+
{
|
|
1468
|
+
provide: CategoryFilterHasuraGraphQLRepository,
|
|
1469
|
+
useFactory: (options) => {
|
|
1470
|
+
return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1471
|
+
},
|
|
1472
|
+
deps: [HASURA_OPTIONS],
|
|
1473
|
+
},
|
|
1474
|
+
{
|
|
1475
|
+
provide: 'FilterOptionRepository',
|
|
1476
|
+
useExisting: FilterOptionHasuraGraphQLRepository,
|
|
1477
|
+
},
|
|
1478
|
+
{
|
|
1479
|
+
provide: FilterOptionHasuraGraphQLRepository,
|
|
1480
|
+
useFactory: (options) => {
|
|
1481
|
+
return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1482
|
+
},
|
|
1483
|
+
deps: [HASURA_OPTIONS],
|
|
1484
|
+
},
|
|
1485
|
+
{
|
|
1486
|
+
provide: 'FilterRepository',
|
|
1487
|
+
useExisting: FilterHasuraGraphQLRepository,
|
|
1488
|
+
},
|
|
1489
|
+
{
|
|
1490
|
+
provide: FilterHasuraGraphQLRepository,
|
|
1491
|
+
useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
|
|
1492
|
+
return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
|
|
1493
|
+
},
|
|
1494
|
+
deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
1495
|
+
},
|
|
1496
|
+
] });
|
|
1497
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
|
|
1498
|
+
type: NgModule,
|
|
1499
|
+
args: [{
|
|
1500
|
+
providers: [
|
|
1501
|
+
{
|
|
1502
|
+
provide: 'CategoryRepository',
|
|
1503
|
+
useExisting: CategoryHasuraGraphQLRepository,
|
|
1504
|
+
},
|
|
1505
|
+
{
|
|
1506
|
+
provide: CategoryHasuraGraphQLRepository,
|
|
1507
|
+
useFactory: (options, productRepository, categoryFilterRepository) => {
|
|
1508
|
+
return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
|
|
1509
|
+
},
|
|
1510
|
+
deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
1511
|
+
},
|
|
1512
|
+
{
|
|
1513
|
+
provide: 'ProductRepository',
|
|
1514
|
+
useExisting: ProductHasuraGraphQLRepository,
|
|
1515
|
+
},
|
|
1516
|
+
{
|
|
1517
|
+
provide: ProductHasuraGraphQLRepository,
|
|
1518
|
+
useFactory: (options) => {
|
|
1519
|
+
return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1520
|
+
},
|
|
1521
|
+
deps: [HASURA_OPTIONS],
|
|
1522
|
+
},
|
|
1523
|
+
{
|
|
1524
|
+
provide: 'VariantRepository',
|
|
1525
|
+
useExisting: VariantHasuraGraphQLRepository,
|
|
1526
|
+
},
|
|
1527
|
+
{
|
|
1528
|
+
provide: VariantHasuraGraphQLRepository,
|
|
1529
|
+
useFactory: (options) => {
|
|
1530
|
+
return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1531
|
+
},
|
|
1532
|
+
deps: [HASURA_OPTIONS],
|
|
1533
|
+
},
|
|
1534
|
+
{
|
|
1535
|
+
provide: 'CategoryFilterRepository',
|
|
1536
|
+
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
1537
|
+
},
|
|
1538
|
+
{
|
|
1539
|
+
provide: CategoryFilterHasuraGraphQLRepository,
|
|
1540
|
+
useFactory: (options) => {
|
|
1541
|
+
return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1542
|
+
},
|
|
1543
|
+
deps: [HASURA_OPTIONS],
|
|
1544
|
+
},
|
|
1545
|
+
{
|
|
1546
|
+
provide: 'FilterOptionRepository',
|
|
1547
|
+
useExisting: FilterOptionHasuraGraphQLRepository,
|
|
1548
|
+
},
|
|
1549
|
+
{
|
|
1550
|
+
provide: FilterOptionHasuraGraphQLRepository,
|
|
1551
|
+
useFactory: (options) => {
|
|
1552
|
+
return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
|
|
1553
|
+
},
|
|
1554
|
+
deps: [HASURA_OPTIONS],
|
|
1555
|
+
},
|
|
1556
|
+
{
|
|
1557
|
+
provide: 'FilterRepository',
|
|
1558
|
+
useExisting: FilterHasuraGraphQLRepository,
|
|
1559
|
+
},
|
|
1560
|
+
{
|
|
1561
|
+
provide: FilterHasuraGraphQLRepository,
|
|
1562
|
+
useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
|
|
1563
|
+
return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
|
|
1564
|
+
},
|
|
1565
|
+
deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
1566
|
+
},
|
|
1567
|
+
],
|
|
1568
|
+
}]
|
|
1483
1569
|
}] });
|
|
1484
1570
|
|
|
1485
|
-
class AngularConnectModule {
|
|
1486
|
-
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
1487
|
-
return {
|
|
1488
|
-
ngModule: AngularConnectModule,
|
|
1489
|
-
providers: [
|
|
1490
|
-
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
1491
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
|
|
1492
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
1493
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
|
|
1494
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
|
|
1495
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
|
|
1496
|
-
],
|
|
1497
|
-
};
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1501
|
-
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
|
|
1502
|
-
AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
|
|
1503
|
-
AuthService,
|
|
1504
|
-
CartService,
|
|
1505
|
-
CheckoutService,
|
|
1506
|
-
CheckoutSubscriptionService,
|
|
1507
|
-
CouponService,
|
|
1508
|
-
HomeShopService,
|
|
1509
|
-
OrderService,
|
|
1510
|
-
ShippingService,
|
|
1511
|
-
], imports: [[AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
|
|
1512
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
1513
|
-
type: NgModule,
|
|
1514
|
-
args: [{
|
|
1515
|
-
imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
|
|
1516
|
-
providers: [
|
|
1517
|
-
AuthService,
|
|
1518
|
-
CartService,
|
|
1519
|
-
CheckoutService,
|
|
1520
|
-
CheckoutSubscriptionService,
|
|
1521
|
-
CouponService,
|
|
1522
|
-
HomeShopService,
|
|
1523
|
-
OrderService,
|
|
1524
|
-
ShippingService,
|
|
1525
|
-
],
|
|
1526
|
-
}]
|
|
1571
|
+
class AngularConnectModule {
|
|
1572
|
+
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
1573
|
+
return {
|
|
1574
|
+
ngModule: AngularConnectModule,
|
|
1575
|
+
providers: [
|
|
1576
|
+
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
1577
|
+
...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
|
|
1578
|
+
...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
1579
|
+
...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
|
|
1580
|
+
...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
|
|
1581
|
+
...(isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
|
|
1582
|
+
],
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1587
|
+
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
|
|
1588
|
+
AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
|
|
1589
|
+
AuthService,
|
|
1590
|
+
CartService,
|
|
1591
|
+
CheckoutService,
|
|
1592
|
+
CheckoutSubscriptionService,
|
|
1593
|
+
CouponService,
|
|
1594
|
+
HomeShopService,
|
|
1595
|
+
OrderService,
|
|
1596
|
+
ShippingService,
|
|
1597
|
+
], imports: [[AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
|
|
1598
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
1599
|
+
type: NgModule,
|
|
1600
|
+
args: [{
|
|
1601
|
+
imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
|
|
1602
|
+
providers: [
|
|
1603
|
+
AuthService,
|
|
1604
|
+
CartService,
|
|
1605
|
+
CheckoutService,
|
|
1606
|
+
CheckoutSubscriptionService,
|
|
1607
|
+
CouponService,
|
|
1608
|
+
HomeShopService,
|
|
1609
|
+
OrderService,
|
|
1610
|
+
ShippingService,
|
|
1611
|
+
],
|
|
1612
|
+
}]
|
|
1527
1613
|
}] });
|
|
1528
1614
|
|
|
1529
|
-
/**
|
|
1530
|
-
* Generated bundle index. Do not edit.
|
|
1615
|
+
/**
|
|
1616
|
+
* Generated bundle index. Do not edit.
|
|
1531
1617
|
*/
|
|
1532
1618
|
|
|
1533
1619
|
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ShippingService };
|