@infrab4a/connect-angular 3.7.9 → 3.8.0-beta.1

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