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