@infrab4a/connect-angular 4.0.0-beta.49 → 4.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/angular-connect.module.d.ts +0 -2
- package/angular-firestore.module.d.ts +1 -2
- package/consts/index.d.ts +0 -2
- package/esm2020/angular-connect.module.mjs +3 -19
- package/esm2020/angular-elastic-search.module.mjs +7 -3
- package/esm2020/angular-firestore.module.mjs +139 -240
- package/esm2020/angular-hasura-graphql.module.mjs +23 -108
- package/esm2020/consts/index.mjs +1 -3
- package/esm2020/index.mjs +3 -3
- package/esm2020/services/auth.service.mjs +3 -3
- package/esm2020/services/cart.service.mjs +23 -161
- package/esm2020/services/checkout-subscription.service.mjs +3 -5
- package/esm2020/services/checkout.service.mjs +5 -3
- package/esm2020/services/coupon.service.mjs +140 -132
- package/esm2020/services/errors/group-invalid-coupon.error.mjs +8 -0
- package/esm2020/services/errors/index.mjs +3 -0
- package/esm2020/services/errors/invalid-coupon.error.mjs +7 -0
- package/esm2020/services/index.mjs +3 -6
- package/fesm2015/infrab4a-connect-angular.mjs +1021 -1794
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +887 -1638
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/index.d.ts +2 -2
- package/package.json +3 -2
- package/services/cart.service.d.ts +2 -9
- package/services/coupon.service.d.ts +10 -13
- package/services/errors/group-invalid-coupon.error.d.ts +6 -0
- package/services/errors/index.d.ts +2 -0
- package/services/errors/invalid-coupon.error.d.ts +4 -0
- package/services/index.d.ts +2 -5
- package/consts/backend-url.const.d.ts +0 -1
- package/consts/category-structure.d.ts +0 -1
- package/esm2020/consts/backend-url.const.mjs +0 -2
- package/esm2020/consts/category-structure.mjs +0 -2
- package/esm2020/helpers/index.mjs +0 -2
- package/esm2020/helpers/mobile-operation-system-checker.helper.mjs +0 -7
- package/esm2020/services/catalog/adapters/category-structure.adapter.mjs +0 -2
- package/esm2020/services/catalog/adapters/index.mjs +0 -4
- package/esm2020/services/catalog/adapters/new-category-structure.adapter.mjs +0 -42
- package/esm2020/services/catalog/adapters/old-category-structure.adapter.mjs +0 -23
- package/esm2020/services/catalog/catalog.service.mjs +0 -98
- package/esm2020/services/catalog/category.service.mjs +0 -51
- package/esm2020/services/catalog/enums/index.mjs +0 -2
- package/esm2020/services/catalog/enums/product-sorts.enum.mjs +0 -11
- package/esm2020/services/catalog/index.mjs +0 -7
- package/esm2020/services/catalog/models/category-with-tree.model.mjs +0 -10
- package/esm2020/services/catalog/models/index.mjs +0 -2
- package/esm2020/services/catalog/types/index.mjs +0 -2
- package/esm2020/services/catalog/types/product-sort.type.mjs +0 -2
- package/esm2020/services/catalog/wishlist.service.mjs +0 -106
- package/esm2020/services/helpers/index.mjs +0 -2
- package/esm2020/services/helpers/util.service.mjs +0 -29
- package/esm2020/services/shipping.service.mjs +0 -96
- package/esm2020/services/types/shipping-methods.type.mjs +0 -2
- package/helpers/index.d.ts +0 -1
- package/helpers/mobile-operation-system-checker.helper.d.ts +0 -3
- package/services/catalog/adapters/category-structure.adapter.d.ts +0 -4
- package/services/catalog/adapters/index.d.ts +0 -3
- package/services/catalog/adapters/new-category-structure.adapter.d.ts +0 -14
- package/services/catalog/adapters/old-category-structure.adapter.d.ts +0 -10
- package/services/catalog/catalog.service.d.ts +0 -54
- package/services/catalog/category.service.d.ts +0 -15
- package/services/catalog/enums/index.d.ts +0 -1
- package/services/catalog/enums/product-sorts.enum.d.ts +0 -9
- package/services/catalog/index.d.ts +0 -6
- package/services/catalog/models/category-with-tree.model.d.ts +0 -4
- package/services/catalog/models/index.d.ts +0 -1
- package/services/catalog/types/index.d.ts +0 -1
- package/services/catalog/types/product-sort.type.d.ts +0 -2
- package/services/catalog/wishlist.service.d.ts +0 -25
- package/services/helpers/index.d.ts +0 -1
- package/services/helpers/util.service.d.ts +0 -7
- package/services/shipping.service.d.ts +0 -19
- package/services/types/shipping-methods.type.d.ts +0 -12
|
@@ -1,25 +1,52 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import * as i1
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { provideFirebaseApp, initializeApp, FirebaseApp } from '@angular/fire/app';
|
|
7
|
-
import * as i1$1 from '@angular/fire/auth';
|
|
8
|
-
import { Auth, provideAuth, getAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
9
|
-
import { isPlatformBrowser } from '@angular/common';
|
|
10
|
-
import * as i1$2 from '@angular/fire/firestore';
|
|
11
|
-
import { Firestore, provideFirestore, getFirestore, initializeFirestore, enableIndexedDbPersistence, docSnapshots, doc } from '@angular/fire/firestore';
|
|
12
|
-
import { initializeApp as initializeApp$1 } from 'firebase/app';
|
|
13
|
-
import { combineLatest, from, of, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
2
|
+
import { Injectable, Inject, InjectionToken, NgModule, PLATFORM_ID } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/fire/auth';
|
|
4
|
+
import { getIdToken, authState, Auth, provideAuth, getAuth } from '@angular/fire/auth';
|
|
5
|
+
import { combineLatest, of, from, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
14
6
|
import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
|
|
15
|
-
import { __awaiter
|
|
7
|
+
import { __awaiter } from 'tslib';
|
|
8
|
+
import * as i2 from '@infrab4a/connect';
|
|
9
|
+
import { Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, Status, isNil, NotFoundError, Checkout, pick, LineItem, CheckoutSubscription, Order, Category, Product, RequiredArgumentError, add, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, VariantHasuraGraphQLRepository } from '@infrab4a/connect';
|
|
16
10
|
import cookie from 'js-cookie';
|
|
17
|
-
import {
|
|
18
|
-
import * as i1$
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
import { CustomError } from 'ts-custom-error';
|
|
12
|
+
import * as i1$1 from '@angular/fire/firestore';
|
|
13
|
+
import { docSnapshots, doc, Firestore, provideFirestore, getFirestore } from '@angular/fire/firestore';
|
|
14
|
+
import * as i1$2 from '@angular/fire/app';
|
|
15
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
16
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
21
17
|
|
|
22
|
-
|
|
18
|
+
class AuthService {
|
|
19
|
+
constructor(angularFireAuth, userRepository) {
|
|
20
|
+
this.angularFireAuth = angularFireAuth;
|
|
21
|
+
this.userRepository = userRepository;
|
|
22
|
+
}
|
|
23
|
+
getAuthstate() {
|
|
24
|
+
const observables = [this.getFireUser(), this.getUser()];
|
|
25
|
+
return combineLatest(observables).pipe(map(([fireUser, user]) => ({
|
|
26
|
+
user,
|
|
27
|
+
isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
|
|
28
|
+
})));
|
|
29
|
+
}
|
|
30
|
+
getUser() {
|
|
31
|
+
return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? this.userRepository.get({ id }) : of(null))), catchError(() => of(null)));
|
|
32
|
+
}
|
|
33
|
+
getTokenId() {
|
|
34
|
+
return from(getIdToken(this.angularFireAuth.currentUser));
|
|
35
|
+
}
|
|
36
|
+
getFireUser() {
|
|
37
|
+
return authState(this.angularFireAuth).pipe(catchError(() => of(null)));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, deps: [{ token: i1.Auth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
41
|
+
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService });
|
|
42
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, decorators: [{
|
|
43
|
+
type: Injectable
|
|
44
|
+
}], ctorParameters: function () {
|
|
45
|
+
return [{ type: i1.Auth }, { type: undefined, decorators: [{
|
|
46
|
+
type: Inject,
|
|
47
|
+
args: ['UserRepository']
|
|
48
|
+
}] }];
|
|
49
|
+
} });
|
|
23
50
|
|
|
24
51
|
const DEFAULT_SHOP = 'DEFAULT_SHOP';
|
|
25
52
|
|
|
@@ -30,977 +57,170 @@ const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
|
|
|
30
57
|
|
|
31
58
|
const HASURA_OPTIONS = 'HASURA_OPTIONS';
|
|
32
59
|
|
|
33
|
-
class
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
ngModule: AngularFirebaseAuthModule,
|
|
37
|
-
providers: [
|
|
38
|
-
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
39
|
-
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
40
|
-
],
|
|
41
|
-
};
|
|
60
|
+
class InvalidCouponError extends CustomError {
|
|
61
|
+
constructor(message) {
|
|
62
|
+
super(message);
|
|
42
63
|
}
|
|
43
64
|
}
|
|
44
|
-
AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
45
|
-
AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1.FirebaseAppModule, i1$1.AuthModule] });
|
|
46
|
-
AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
|
|
47
|
-
{
|
|
48
|
-
provide: 'Authentication',
|
|
49
|
-
useFactory: (authenticationService, userRepository) => {
|
|
50
|
-
return new Authentication(authenticationService, userRepository);
|
|
51
|
-
},
|
|
52
|
-
deps: ['AuthenticationService', 'UserRepository'],
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
provide: 'AuthenticationService',
|
|
56
|
-
useFactory: (angularFireAuth) => {
|
|
57
|
-
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
58
|
-
},
|
|
59
|
-
deps: [Auth],
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
provide: 'Register',
|
|
63
|
-
useFactory: (registerService, userRepository) => {
|
|
64
|
-
return new Register(registerService, userRepository);
|
|
65
|
-
},
|
|
66
|
-
deps: ['RegisterService', 'UserRepository'],
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
provide: 'RegisterService',
|
|
70
|
-
useFactory: (angularFireAuth) => {
|
|
71
|
-
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
72
|
-
},
|
|
73
|
-
deps: [Auth],
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
provide: 'SignOut',
|
|
77
|
-
useFactory: (authenticationService) => {
|
|
78
|
-
return new SignOut(authenticationService);
|
|
79
|
-
},
|
|
80
|
-
deps: ['AuthenticationService'],
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
provide: 'RecoveryPassword',
|
|
84
|
-
useFactory: (authenticationService) => {
|
|
85
|
-
return new RecoveryPassword(authenticationService);
|
|
86
|
-
},
|
|
87
|
-
deps: ['AuthenticationService'],
|
|
88
|
-
},
|
|
89
|
-
], imports: [provideFirebaseApp((injector) => {
|
|
90
|
-
const appName = injector.get(FIREBASE_APP_NAME);
|
|
91
|
-
return appName
|
|
92
|
-
? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
|
|
93
|
-
: initializeApp(injector.get(FIREBASE_OPTIONS));
|
|
94
|
-
}),
|
|
95
|
-
provideAuth(() => getAuth())] });
|
|
96
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
|
|
97
|
-
type: NgModule,
|
|
98
|
-
args: [{
|
|
99
|
-
imports: [
|
|
100
|
-
provideFirebaseApp((injector) => {
|
|
101
|
-
const appName = injector.get(FIREBASE_APP_NAME);
|
|
102
|
-
return appName
|
|
103
|
-
? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
|
|
104
|
-
: initializeApp(injector.get(FIREBASE_OPTIONS));
|
|
105
|
-
}),
|
|
106
|
-
provideAuth(() => getAuth()),
|
|
107
|
-
],
|
|
108
|
-
providers: [
|
|
109
|
-
{
|
|
110
|
-
provide: 'Authentication',
|
|
111
|
-
useFactory: (authenticationService, userRepository) => {
|
|
112
|
-
return new Authentication(authenticationService, userRepository);
|
|
113
|
-
},
|
|
114
|
-
deps: ['AuthenticationService', 'UserRepository'],
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
provide: 'AuthenticationService',
|
|
118
|
-
useFactory: (angularFireAuth) => {
|
|
119
|
-
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
120
|
-
},
|
|
121
|
-
deps: [Auth],
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
provide: 'Register',
|
|
125
|
-
useFactory: (registerService, userRepository) => {
|
|
126
|
-
return new Register(registerService, userRepository);
|
|
127
|
-
},
|
|
128
|
-
deps: ['RegisterService', 'UserRepository'],
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
provide: 'RegisterService',
|
|
132
|
-
useFactory: (angularFireAuth) => {
|
|
133
|
-
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
134
|
-
},
|
|
135
|
-
deps: [Auth],
|
|
136
|
-
},
|
|
137
|
-
{
|
|
138
|
-
provide: 'SignOut',
|
|
139
|
-
useFactory: (authenticationService) => {
|
|
140
|
-
return new SignOut(authenticationService);
|
|
141
|
-
},
|
|
142
|
-
deps: ['AuthenticationService'],
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
provide: 'RecoveryPassword',
|
|
146
|
-
useFactory: (authenticationService) => {
|
|
147
|
-
return new RecoveryPassword(authenticationService);
|
|
148
|
-
},
|
|
149
|
-
deps: ['AuthenticationService'],
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
}]
|
|
153
|
-
}] });
|
|
154
65
|
|
|
155
|
-
class
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
providers: [{ provide: ES_CONFIG, useValue: options }],
|
|
160
|
-
};
|
|
66
|
+
class GroupInvalidCouponError extends CustomError {
|
|
67
|
+
constructor(errors) {
|
|
68
|
+
super('Many coupon errors throw');
|
|
69
|
+
this.errors = errors;
|
|
161
70
|
}
|
|
162
71
|
}
|
|
163
|
-
AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
164
|
-
AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule });
|
|
165
|
-
AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, providers: [
|
|
166
|
-
{
|
|
167
|
-
provide: ProductsIndex,
|
|
168
|
-
useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
|
|
169
|
-
deps: [ES_CONFIG],
|
|
170
|
-
},
|
|
171
|
-
] });
|
|
172
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
|
|
173
|
-
type: NgModule,
|
|
174
|
-
args: [{
|
|
175
|
-
providers: [
|
|
176
|
-
{
|
|
177
|
-
provide: ProductsIndex,
|
|
178
|
-
useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
|
|
179
|
-
deps: [ES_CONFIG],
|
|
180
|
-
},
|
|
181
|
-
],
|
|
182
|
-
}]
|
|
183
|
-
}] });
|
|
184
72
|
|
|
185
|
-
class
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
73
|
+
class CouponService {
|
|
74
|
+
constructor(couponRepository, defaultShop, orderRepository, subscriptionRepository, categoryRepository) {
|
|
75
|
+
this.couponRepository = couponRepository;
|
|
76
|
+
this.defaultShop = defaultShop;
|
|
77
|
+
this.orderRepository = orderRepository;
|
|
78
|
+
this.subscriptionRepository = subscriptionRepository;
|
|
79
|
+
this.categoryRepository = categoryRepository;
|
|
80
|
+
this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
|
|
190
81
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
{ provide: FIREBASE_OPTIONS, useValue: options.firebase },
|
|
199
|
-
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
200
|
-
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
201
|
-
],
|
|
202
|
-
};
|
|
82
|
+
checkCoupon(nickname, userEmail, checkoutType, plan, checkout, isSubscription) {
|
|
83
|
+
return from(this.couponRepository.find({
|
|
84
|
+
filters: {
|
|
85
|
+
nickname: { operator: Where.EQUALS, value: nickname },
|
|
86
|
+
active: { operator: Where.EQUALS, value: true },
|
|
87
|
+
},
|
|
88
|
+
})).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));
|
|
203
89
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
90
|
+
checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription) {
|
|
91
|
+
// Caso não ache nenhum cupom, retorna erro
|
|
92
|
+
if (coupons.count < 1) {
|
|
93
|
+
return throwError('Cupom inválido.');
|
|
94
|
+
}
|
|
95
|
+
// Get Primeiro Cupom (o find do repository retorna um array)
|
|
96
|
+
const coupon = coupons.data.shift();
|
|
97
|
+
// Verifica se o cupom é aplicavel na loja
|
|
98
|
+
const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
|
|
99
|
+
// Cupon não aplicavel a loja retorna erro
|
|
100
|
+
if (!isInShop)
|
|
101
|
+
return throwError('Cupom inválido para loja.');
|
|
102
|
+
// Verifica se o coupon é aplicado no checkout que está sendo realizado
|
|
103
|
+
const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
|
|
104
|
+
// Cupon não aplicavel ao checkout retorna erro
|
|
105
|
+
if (!isCheckoutType)
|
|
106
|
+
return throwError('Cupom inválido. Erro de checkout.');
|
|
107
|
+
// Verifica se o cupom é ou pode ser aplicado para subscription
|
|
108
|
+
if (checkoutType === CheckoutTypes.ALL || checkoutType === CheckoutTypes.SUBSCRIPTION) {
|
|
109
|
+
// Se o cupom tiver um plano associado, verifica se é o mesmo plano do checkout da assinatura
|
|
110
|
+
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
|
|
111
|
+
return throwError('Cupom inválido para sua assinatura.');
|
|
112
|
+
}
|
|
113
|
+
if (isSubscription)
|
|
114
|
+
return of(coupon);
|
|
115
|
+
// Verifica se possui o valor minimo de compra para utilização do cupom
|
|
116
|
+
const hasMinSubTotal = this.hasMinSubTotal(coupon, checkout);
|
|
117
|
+
// Se não tem valor mínimo atingido, retorna erro
|
|
118
|
+
if (!hasMinSubTotal)
|
|
119
|
+
return throwError('Valor mínimo não atingido');
|
|
120
|
+
return of(coupon);
|
|
121
|
+
}
|
|
122
|
+
isValidCoupon(coupon, userEmail) {
|
|
123
|
+
// Verifica a data de inicio de validade do cupom
|
|
124
|
+
if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) > new Date())
|
|
125
|
+
throw new InvalidCouponError('Cupom ainda não liberado.');
|
|
126
|
+
// Verifica a data de validade do cupom
|
|
127
|
+
if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
|
|
128
|
+
throw new InvalidCouponError('Cupom expirado.');
|
|
129
|
+
return coupon;
|
|
130
|
+
}
|
|
131
|
+
checkCouponUseAndLimit(coupon, userEmail, checkout) {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
const orders = yield this.orderRepository.find({
|
|
134
|
+
filters: {
|
|
135
|
+
coupon: { id: coupon.id },
|
|
136
|
+
payment: { status: 'paid' },
|
|
226
137
|
},
|
|
227
|
-
})
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
{
|
|
238
|
-
provide: 'Buy2WinRepository',
|
|
239
|
-
useFactory: (options) => {
|
|
240
|
-
return new Buy2WinFirestoreRepository(options);
|
|
241
|
-
},
|
|
242
|
-
deps: ['FirestoreOptions'],
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
provide: CategoryFirestoreRepository,
|
|
246
|
-
useFactory: (options) => {
|
|
247
|
-
return new CategoryFirestoreRepository(options);
|
|
248
|
-
},
|
|
249
|
-
deps: ['FirestoreOptions'],
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
provide: 'CheckoutRepository',
|
|
253
|
-
useFactory: (options) => {
|
|
254
|
-
return new CheckoutFirestoreRepository(options);
|
|
255
|
-
},
|
|
256
|
-
deps: ['FirestoreOptions'],
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
provide: 'CheckoutSubscriptionRepository',
|
|
260
|
-
useFactory: (options) => {
|
|
261
|
-
return new CheckoutSubscriptionFirestoreRepository(options);
|
|
262
|
-
},
|
|
263
|
-
deps: ['FirestoreOptions'],
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
provide: 'CouponRepository',
|
|
267
|
-
useFactory: (options) => {
|
|
268
|
-
return new CouponFirestoreRepository(options);
|
|
269
|
-
},
|
|
270
|
-
deps: ['FirestoreOptions'],
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
provide: 'CampaignHashtagRepository',
|
|
274
|
-
useFactory: (options) => {
|
|
275
|
-
return new CampaignHashtagFirestoreRepository(options);
|
|
276
|
-
},
|
|
277
|
-
deps: ['FirestoreOptions'],
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
provide: 'CampaignDashboardRepository',
|
|
281
|
-
useFactory: (options) => {
|
|
282
|
-
return new CampaignDashboardFirestoreRepository(options);
|
|
283
|
-
},
|
|
284
|
-
deps: ['FirestoreOptions'],
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
provide: 'EditionRepository',
|
|
288
|
-
useFactory: (options, subscriptionRepository) => {
|
|
289
|
-
return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
|
|
290
|
-
},
|
|
291
|
-
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
provide: 'HomeRepository',
|
|
295
|
-
useFactory: (options) => {
|
|
296
|
-
return new HomeFirestoreRepository(options);
|
|
297
|
-
},
|
|
298
|
-
deps: ['FirestoreOptions'],
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
provide: 'LeadRepository',
|
|
302
|
-
useFactory: (options) => {
|
|
303
|
-
return new LeadFirestoreRepository(options);
|
|
304
|
-
},
|
|
305
|
-
deps: ['FirestoreOptions'],
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
provide: 'LegacyOrderRepository',
|
|
309
|
-
useFactory: (options) => {
|
|
310
|
-
return new LegacyOrderFirestoreRepository(options);
|
|
311
|
-
},
|
|
312
|
-
deps: ['FirestoreOptions'],
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
provide: 'ShopMenuRepository',
|
|
316
|
-
useFactory: (options) => {
|
|
317
|
-
return new ShopMenuFirestoreRepository(options);
|
|
318
|
-
},
|
|
319
|
-
deps: ['FirestoreOptions'],
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
provide: 'OrderRepository',
|
|
323
|
-
useFactory: (options) => {
|
|
324
|
-
return new OrderFirestoreRepository(options);
|
|
325
|
-
},
|
|
326
|
-
deps: ['FirestoreOptions'],
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
provide: 'PaymentRepository',
|
|
330
|
-
useFactory: (options) => {
|
|
331
|
-
return new PaymentFirestoreRepository(options);
|
|
332
|
-
},
|
|
333
|
-
deps: ['FirestoreOptions'],
|
|
334
|
-
},
|
|
335
|
-
{
|
|
336
|
-
provide: ProductFirestoreRepository,
|
|
337
|
-
useFactory: (options) => {
|
|
338
|
-
return new ProductFirestoreRepository(options);
|
|
339
|
-
},
|
|
340
|
-
deps: ['FirestoreOptions'],
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
provide: 'ShopSettingsRepository',
|
|
344
|
-
useFactory: (options) => {
|
|
345
|
-
return new ShopSettingsFirestoreRepository(options);
|
|
346
|
-
},
|
|
347
|
-
deps: ['FirestoreOptions'],
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
provide: 'SubscriptionPaymentRepository',
|
|
351
|
-
useFactory: (options, subscriptionRepository) => {
|
|
352
|
-
return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
|
|
353
|
-
},
|
|
354
|
-
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
provide: 'SubscriptionPlanRepository',
|
|
358
|
-
useFactory: (options) => {
|
|
359
|
-
return new SubscriptionPlanFirestoreRepository(options);
|
|
360
|
-
},
|
|
361
|
-
deps: ['FirestoreOptions'],
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
provide: 'SubscriptionProductRepository',
|
|
365
|
-
useFactory: (options) => {
|
|
366
|
-
return new SubscriptionProductFirestoreRepository(options);
|
|
367
|
-
},
|
|
368
|
-
deps: ['FirestoreOptions'],
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
provide: 'SubscriptionRepository',
|
|
372
|
-
useFactory: (options) => {
|
|
373
|
-
return new SubscriptionFirestoreRepository(options);
|
|
374
|
-
},
|
|
375
|
-
deps: ['FirestoreOptions'],
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
provide: 'UserRepository',
|
|
379
|
-
useFactory: (options) => {
|
|
380
|
-
return new UserFirestoreRepository(options);
|
|
381
|
-
},
|
|
382
|
-
deps: ['FirestoreOptions'],
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
provide: 'UserAddressRepository',
|
|
386
|
-
useFactory: (options, userRepository) => {
|
|
387
|
-
return new UserAddressFirestoreRepository(options, userRepository);
|
|
388
|
-
},
|
|
389
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
provide: 'UserPaymentMethodRepository',
|
|
393
|
-
useFactory: (options, userRepository) => {
|
|
394
|
-
return new UserPaymentMethodFirestoreRepository(options, userRepository);
|
|
395
|
-
},
|
|
396
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
397
|
-
},
|
|
398
|
-
{
|
|
399
|
-
provide: ProductVariantFirestoreRepository,
|
|
400
|
-
useFactory: (options, productRepository) => {
|
|
401
|
-
return new ProductVariantFirestoreRepository(options, productRepository);
|
|
402
|
-
},
|
|
403
|
-
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
404
|
-
},
|
|
405
|
-
], imports: [AngularElasticSeachModule,
|
|
406
|
-
provideFirebaseApp((injector) => {
|
|
407
|
-
const appName = injector.get(FIREBASE_APP_NAME);
|
|
408
|
-
return appName
|
|
409
|
-
? initializeApp$1(injector.get(FIREBASE_OPTIONS), appName)
|
|
410
|
-
: initializeApp$1(injector.get(FIREBASE_OPTIONS));
|
|
411
|
-
}),
|
|
412
|
-
provideFirestore((injector) => {
|
|
413
|
-
if (!MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
414
|
-
return getFirestore();
|
|
415
|
-
const firestore = initializeFirestore(injector.get(FirebaseApp), { experimentalForceLongPolling: true });
|
|
416
|
-
enableIndexedDbPersistence(firestore).catch(console.error);
|
|
417
|
-
return firestore;
|
|
418
|
-
})] });
|
|
419
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
420
|
-
type: NgModule,
|
|
421
|
-
args: [{
|
|
422
|
-
imports: [
|
|
423
|
-
AngularElasticSeachModule,
|
|
424
|
-
provideFirebaseApp((injector) => {
|
|
425
|
-
const appName = injector.get(FIREBASE_APP_NAME);
|
|
426
|
-
return appName
|
|
427
|
-
? initializeApp$1(injector.get(FIREBASE_OPTIONS), appName)
|
|
428
|
-
: initializeApp$1(injector.get(FIREBASE_OPTIONS));
|
|
429
|
-
}),
|
|
430
|
-
provideFirestore((injector) => {
|
|
431
|
-
if (!MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
432
|
-
return getFirestore();
|
|
433
|
-
const firestore = initializeFirestore(injector.get(FirebaseApp), { experimentalForceLongPolling: true });
|
|
434
|
-
enableIndexedDbPersistence(firestore).catch(console.error);
|
|
435
|
-
return firestore;
|
|
436
|
-
}),
|
|
437
|
-
],
|
|
438
|
-
providers: [
|
|
439
|
-
{
|
|
440
|
-
provide: 'FirestoreOptions',
|
|
441
|
-
useFactory: (firestore, platformId) => ({
|
|
442
|
-
firestore,
|
|
443
|
-
interceptors: {
|
|
444
|
-
request: (request) => {
|
|
445
|
-
if (isPlatformBrowser(platformId))
|
|
446
|
-
return request;
|
|
447
|
-
const interval = setInterval(() => { }, 100);
|
|
448
|
-
request.interval = interval;
|
|
449
|
-
return request;
|
|
450
|
-
},
|
|
451
|
-
response: (response, request) => {
|
|
452
|
-
if (isPlatformBrowser(platformId))
|
|
453
|
-
return response;
|
|
454
|
-
clearInterval(request.interval);
|
|
455
|
-
return response;
|
|
456
|
-
},
|
|
457
|
-
},
|
|
458
|
-
}),
|
|
459
|
-
deps: [Firestore, PLATFORM_ID],
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
provide: 'BeautyProfileRepository',
|
|
463
|
-
useFactory: (config, userRepository) => {
|
|
464
|
-
return new UserBeautyProfileFirestoreRepository(config, userRepository);
|
|
465
|
-
},
|
|
466
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
provide: 'Buy2WinRepository',
|
|
470
|
-
useFactory: (options) => {
|
|
471
|
-
return new Buy2WinFirestoreRepository(options);
|
|
472
|
-
},
|
|
473
|
-
deps: ['FirestoreOptions'],
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
provide: CategoryFirestoreRepository,
|
|
477
|
-
useFactory: (options) => {
|
|
478
|
-
return new CategoryFirestoreRepository(options);
|
|
479
|
-
},
|
|
480
|
-
deps: ['FirestoreOptions'],
|
|
481
|
-
},
|
|
482
|
-
{
|
|
483
|
-
provide: 'CheckoutRepository',
|
|
484
|
-
useFactory: (options) => {
|
|
485
|
-
return new CheckoutFirestoreRepository(options);
|
|
486
|
-
},
|
|
487
|
-
deps: ['FirestoreOptions'],
|
|
488
|
-
},
|
|
489
|
-
{
|
|
490
|
-
provide: 'CheckoutSubscriptionRepository',
|
|
491
|
-
useFactory: (options) => {
|
|
492
|
-
return new CheckoutSubscriptionFirestoreRepository(options);
|
|
493
|
-
},
|
|
494
|
-
deps: ['FirestoreOptions'],
|
|
495
|
-
},
|
|
496
|
-
{
|
|
497
|
-
provide: 'CouponRepository',
|
|
498
|
-
useFactory: (options) => {
|
|
499
|
-
return new CouponFirestoreRepository(options);
|
|
500
|
-
},
|
|
501
|
-
deps: ['FirestoreOptions'],
|
|
502
|
-
},
|
|
503
|
-
{
|
|
504
|
-
provide: 'CampaignHashtagRepository',
|
|
505
|
-
useFactory: (options) => {
|
|
506
|
-
return new CampaignHashtagFirestoreRepository(options);
|
|
507
|
-
},
|
|
508
|
-
deps: ['FirestoreOptions'],
|
|
509
|
-
},
|
|
510
|
-
{
|
|
511
|
-
provide: 'CampaignDashboardRepository',
|
|
512
|
-
useFactory: (options) => {
|
|
513
|
-
return new CampaignDashboardFirestoreRepository(options);
|
|
514
|
-
},
|
|
515
|
-
deps: ['FirestoreOptions'],
|
|
516
|
-
},
|
|
517
|
-
{
|
|
518
|
-
provide: 'EditionRepository',
|
|
519
|
-
useFactory: (options, subscriptionRepository) => {
|
|
520
|
-
return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
|
|
521
|
-
},
|
|
522
|
-
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
523
|
-
},
|
|
524
|
-
{
|
|
525
|
-
provide: 'HomeRepository',
|
|
526
|
-
useFactory: (options) => {
|
|
527
|
-
return new HomeFirestoreRepository(options);
|
|
528
|
-
},
|
|
529
|
-
deps: ['FirestoreOptions'],
|
|
530
|
-
},
|
|
531
|
-
{
|
|
532
|
-
provide: 'LeadRepository',
|
|
533
|
-
useFactory: (options) => {
|
|
534
|
-
return new LeadFirestoreRepository(options);
|
|
535
|
-
},
|
|
536
|
-
deps: ['FirestoreOptions'],
|
|
537
|
-
},
|
|
538
|
-
{
|
|
539
|
-
provide: 'LegacyOrderRepository',
|
|
540
|
-
useFactory: (options) => {
|
|
541
|
-
return new LegacyOrderFirestoreRepository(options);
|
|
542
|
-
},
|
|
543
|
-
deps: ['FirestoreOptions'],
|
|
544
|
-
},
|
|
545
|
-
{
|
|
546
|
-
provide: 'ShopMenuRepository',
|
|
547
|
-
useFactory: (options) => {
|
|
548
|
-
return new ShopMenuFirestoreRepository(options);
|
|
549
|
-
},
|
|
550
|
-
deps: ['FirestoreOptions'],
|
|
551
|
-
},
|
|
552
|
-
{
|
|
553
|
-
provide: 'OrderRepository',
|
|
554
|
-
useFactory: (options) => {
|
|
555
|
-
return new OrderFirestoreRepository(options);
|
|
556
|
-
},
|
|
557
|
-
deps: ['FirestoreOptions'],
|
|
558
|
-
},
|
|
559
|
-
{
|
|
560
|
-
provide: 'PaymentRepository',
|
|
561
|
-
useFactory: (options) => {
|
|
562
|
-
return new PaymentFirestoreRepository(options);
|
|
563
|
-
},
|
|
564
|
-
deps: ['FirestoreOptions'],
|
|
565
|
-
},
|
|
566
|
-
{
|
|
567
|
-
provide: ProductFirestoreRepository,
|
|
568
|
-
useFactory: (options) => {
|
|
569
|
-
return new ProductFirestoreRepository(options);
|
|
570
|
-
},
|
|
571
|
-
deps: ['FirestoreOptions'],
|
|
572
|
-
},
|
|
573
|
-
{
|
|
574
|
-
provide: 'ShopSettingsRepository',
|
|
575
|
-
useFactory: (options) => {
|
|
576
|
-
return new ShopSettingsFirestoreRepository(options);
|
|
577
|
-
},
|
|
578
|
-
deps: ['FirestoreOptions'],
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
provide: 'SubscriptionPaymentRepository',
|
|
582
|
-
useFactory: (options, subscriptionRepository) => {
|
|
583
|
-
return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
|
|
584
|
-
},
|
|
585
|
-
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
provide: 'SubscriptionPlanRepository',
|
|
589
|
-
useFactory: (options) => {
|
|
590
|
-
return new SubscriptionPlanFirestoreRepository(options);
|
|
591
|
-
},
|
|
592
|
-
deps: ['FirestoreOptions'],
|
|
593
|
-
},
|
|
594
|
-
{
|
|
595
|
-
provide: 'SubscriptionProductRepository',
|
|
596
|
-
useFactory: (options) => {
|
|
597
|
-
return new SubscriptionProductFirestoreRepository(options);
|
|
598
|
-
},
|
|
599
|
-
deps: ['FirestoreOptions'],
|
|
600
|
-
},
|
|
601
|
-
{
|
|
602
|
-
provide: 'SubscriptionRepository',
|
|
603
|
-
useFactory: (options) => {
|
|
604
|
-
return new SubscriptionFirestoreRepository(options);
|
|
605
|
-
},
|
|
606
|
-
deps: ['FirestoreOptions'],
|
|
607
|
-
},
|
|
608
|
-
{
|
|
609
|
-
provide: 'UserRepository',
|
|
610
|
-
useFactory: (options) => {
|
|
611
|
-
return new UserFirestoreRepository(options);
|
|
612
|
-
},
|
|
613
|
-
deps: ['FirestoreOptions'],
|
|
614
|
-
},
|
|
615
|
-
{
|
|
616
|
-
provide: 'UserAddressRepository',
|
|
617
|
-
useFactory: (options, userRepository) => {
|
|
618
|
-
return new UserAddressFirestoreRepository(options, userRepository);
|
|
619
|
-
},
|
|
620
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
621
|
-
},
|
|
622
|
-
{
|
|
623
|
-
provide: 'UserPaymentMethodRepository',
|
|
624
|
-
useFactory: (options, userRepository) => {
|
|
625
|
-
return new UserPaymentMethodFirestoreRepository(options, userRepository);
|
|
626
|
-
},
|
|
627
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
628
|
-
},
|
|
629
|
-
{
|
|
630
|
-
provide: ProductVariantFirestoreRepository,
|
|
631
|
-
useFactory: (options, productRepository) => {
|
|
632
|
-
return new ProductVariantFirestoreRepository(options, productRepository);
|
|
633
|
-
},
|
|
634
|
-
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
635
|
-
},
|
|
636
|
-
],
|
|
637
|
-
}]
|
|
638
|
-
}] });
|
|
639
|
-
|
|
640
|
-
class AngularHasuraGraphQLModule {
|
|
641
|
-
static initializeApp(options) {
|
|
642
|
-
return {
|
|
643
|
-
ngModule: AngularHasuraGraphQLModule,
|
|
644
|
-
providers: [{ provide: HASURA_OPTIONS, useValue: options }],
|
|
645
|
-
};
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
649
|
-
AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule });
|
|
650
|
-
AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
|
|
651
|
-
{
|
|
652
|
-
provide: 'HasuraConfig',
|
|
653
|
-
useFactory: (options, platformId) => ({
|
|
654
|
-
endpoint: options.endpoint,
|
|
655
|
-
authOptions: options.credentials,
|
|
656
|
-
interceptors: {
|
|
657
|
-
request: (request) => {
|
|
658
|
-
if (isPlatformBrowser(platformId))
|
|
659
|
-
return request;
|
|
660
|
-
const interval = setInterval(() => { }, 100);
|
|
661
|
-
request.interval = interval;
|
|
662
|
-
return request;
|
|
663
|
-
},
|
|
664
|
-
response: (response, request) => {
|
|
665
|
-
if (isPlatformBrowser(platformId))
|
|
666
|
-
return response;
|
|
667
|
-
clearInterval(request.interval);
|
|
668
|
-
return response;
|
|
669
|
-
},
|
|
670
|
-
},
|
|
671
|
-
}),
|
|
672
|
-
deps: [HASURA_OPTIONS, PLATFORM_ID],
|
|
673
|
-
},
|
|
674
|
-
{
|
|
675
|
-
provide: 'CategoryRepository',
|
|
676
|
-
useExisting: CategoryHasuraGraphQLRepository,
|
|
677
|
-
},
|
|
678
|
-
{
|
|
679
|
-
provide: CategoryHasuraGraphQLRepository,
|
|
680
|
-
useFactory: (options, productRepository, categoryFilterRepository) => {
|
|
681
|
-
return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
|
|
682
|
-
},
|
|
683
|
-
deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
684
|
-
},
|
|
685
|
-
{
|
|
686
|
-
provide: 'ProductRepository',
|
|
687
|
-
useExisting: ProductHasuraGraphQLRepository,
|
|
688
|
-
},
|
|
689
|
-
{
|
|
690
|
-
provide: ProductHasuraGraphQLRepository,
|
|
691
|
-
useFactory: (hasuraConfig) => {
|
|
692
|
-
return new ProductHasuraGraphQLRepository(hasuraConfig);
|
|
693
|
-
},
|
|
694
|
-
deps: ['HasuraConfig'],
|
|
695
|
-
},
|
|
696
|
-
{
|
|
697
|
-
provide: 'VariantRepository',
|
|
698
|
-
useExisting: VariantHasuraGraphQLRepository,
|
|
699
|
-
},
|
|
700
|
-
{
|
|
701
|
-
provide: VariantHasuraGraphQLRepository,
|
|
702
|
-
useFactory: (hasuraConfig) => {
|
|
703
|
-
return new VariantHasuraGraphQLRepository(hasuraConfig);
|
|
704
|
-
},
|
|
705
|
-
deps: ['HasuraConfig'],
|
|
706
|
-
},
|
|
707
|
-
{
|
|
708
|
-
provide: 'CategoryFilterRepository',
|
|
709
|
-
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
710
|
-
},
|
|
711
|
-
{
|
|
712
|
-
provide: CategoryFilterHasuraGraphQLRepository,
|
|
713
|
-
useFactory: (options) => {
|
|
714
|
-
return new CategoryFilterHasuraGraphQLRepository(options);
|
|
715
|
-
},
|
|
716
|
-
deps: ['HasuraConfig'],
|
|
717
|
-
},
|
|
718
|
-
{
|
|
719
|
-
provide: 'FilterOptionRepository',
|
|
720
|
-
useExisting: FilterOptionHasuraGraphQLRepository,
|
|
721
|
-
},
|
|
722
|
-
{
|
|
723
|
-
provide: FilterOptionHasuraGraphQLRepository,
|
|
724
|
-
useFactory: (options) => {
|
|
725
|
-
return new FilterOptionHasuraGraphQLRepository(options);
|
|
726
|
-
},
|
|
727
|
-
deps: ['HasuraConfig'],
|
|
728
|
-
},
|
|
729
|
-
{
|
|
730
|
-
provide: 'FilterRepository',
|
|
731
|
-
useExisting: FilterHasuraGraphQLRepository,
|
|
732
|
-
},
|
|
733
|
-
{
|
|
734
|
-
provide: FilterHasuraGraphQLRepository,
|
|
735
|
-
useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
|
|
736
|
-
return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
|
|
737
|
-
},
|
|
738
|
-
deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
739
|
-
},
|
|
740
|
-
{
|
|
741
|
-
provide: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
742
|
-
useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials),
|
|
743
|
-
},
|
|
744
|
-
{
|
|
745
|
-
provide: 'CategoryCollectionChildrenRepository',
|
|
746
|
-
useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
747
|
-
},
|
|
748
|
-
{
|
|
749
|
-
provide: 'WishlistRepository',
|
|
750
|
-
useExisting: WishlistHasuraGraphQLRepository,
|
|
751
|
-
},
|
|
752
|
-
] });
|
|
753
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
|
|
754
|
-
type: NgModule,
|
|
755
|
-
args: [{
|
|
756
|
-
providers: [
|
|
757
|
-
{
|
|
758
|
-
provide: 'HasuraConfig',
|
|
759
|
-
useFactory: (options, platformId) => ({
|
|
760
|
-
endpoint: options.endpoint,
|
|
761
|
-
authOptions: options.credentials,
|
|
762
|
-
interceptors: {
|
|
763
|
-
request: (request) => {
|
|
764
|
-
if (isPlatformBrowser(platformId))
|
|
765
|
-
return request;
|
|
766
|
-
const interval = setInterval(() => { }, 100);
|
|
767
|
-
request.interval = interval;
|
|
768
|
-
return request;
|
|
769
|
-
},
|
|
770
|
-
response: (response, request) => {
|
|
771
|
-
if (isPlatformBrowser(platformId))
|
|
772
|
-
return response;
|
|
773
|
-
clearInterval(request.interval);
|
|
774
|
-
return response;
|
|
775
|
-
},
|
|
776
|
-
},
|
|
777
|
-
}),
|
|
778
|
-
deps: [HASURA_OPTIONS, PLATFORM_ID],
|
|
779
|
-
},
|
|
780
|
-
{
|
|
781
|
-
provide: 'CategoryRepository',
|
|
782
|
-
useExisting: CategoryHasuraGraphQLRepository,
|
|
783
|
-
},
|
|
784
|
-
{
|
|
785
|
-
provide: CategoryHasuraGraphQLRepository,
|
|
786
|
-
useFactory: (options, productRepository, categoryFilterRepository) => {
|
|
787
|
-
return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
|
|
788
|
-
},
|
|
789
|
-
deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
790
|
-
},
|
|
791
|
-
{
|
|
792
|
-
provide: 'ProductRepository',
|
|
793
|
-
useExisting: ProductHasuraGraphQLRepository,
|
|
794
|
-
},
|
|
795
|
-
{
|
|
796
|
-
provide: ProductHasuraGraphQLRepository,
|
|
797
|
-
useFactory: (hasuraConfig) => {
|
|
798
|
-
return new ProductHasuraGraphQLRepository(hasuraConfig);
|
|
799
|
-
},
|
|
800
|
-
deps: ['HasuraConfig'],
|
|
801
|
-
},
|
|
802
|
-
{
|
|
803
|
-
provide: 'VariantRepository',
|
|
804
|
-
useExisting: VariantHasuraGraphQLRepository,
|
|
805
|
-
},
|
|
806
|
-
{
|
|
807
|
-
provide: VariantHasuraGraphQLRepository,
|
|
808
|
-
useFactory: (hasuraConfig) => {
|
|
809
|
-
return new VariantHasuraGraphQLRepository(hasuraConfig);
|
|
810
|
-
},
|
|
811
|
-
deps: ['HasuraConfig'],
|
|
812
|
-
},
|
|
813
|
-
{
|
|
814
|
-
provide: 'CategoryFilterRepository',
|
|
815
|
-
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
816
|
-
},
|
|
817
|
-
{
|
|
818
|
-
provide: CategoryFilterHasuraGraphQLRepository,
|
|
819
|
-
useFactory: (options) => {
|
|
820
|
-
return new CategoryFilterHasuraGraphQLRepository(options);
|
|
821
|
-
},
|
|
822
|
-
deps: ['HasuraConfig'],
|
|
823
|
-
},
|
|
824
|
-
{
|
|
825
|
-
provide: 'FilterOptionRepository',
|
|
826
|
-
useExisting: FilterOptionHasuraGraphQLRepository,
|
|
827
|
-
},
|
|
828
|
-
{
|
|
829
|
-
provide: FilterOptionHasuraGraphQLRepository,
|
|
830
|
-
useFactory: (options) => {
|
|
831
|
-
return new FilterOptionHasuraGraphQLRepository(options);
|
|
832
|
-
},
|
|
833
|
-
deps: ['HasuraConfig'],
|
|
834
|
-
},
|
|
835
|
-
{
|
|
836
|
-
provide: 'FilterRepository',
|
|
837
|
-
useExisting: FilterHasuraGraphQLRepository,
|
|
838
|
-
},
|
|
839
|
-
{
|
|
840
|
-
provide: FilterHasuraGraphQLRepository,
|
|
841
|
-
useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
|
|
842
|
-
return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
|
|
843
|
-
},
|
|
844
|
-
deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
845
|
-
},
|
|
846
|
-
{
|
|
847
|
-
provide: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
848
|
-
useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials),
|
|
849
|
-
},
|
|
850
|
-
{
|
|
851
|
-
provide: 'CategoryCollectionChildrenRepository',
|
|
852
|
-
useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
853
|
-
},
|
|
854
|
-
{
|
|
855
|
-
provide: 'WishlistRepository',
|
|
856
|
-
useExisting: WishlistHasuraGraphQLRepository,
|
|
857
|
-
},
|
|
858
|
-
],
|
|
859
|
-
}]
|
|
860
|
-
}] });
|
|
861
|
-
|
|
862
|
-
class AuthService {
|
|
863
|
-
constructor(angularFireAuth, userRepository) {
|
|
864
|
-
this.angularFireAuth = angularFireAuth;
|
|
865
|
-
this.userRepository = userRepository;
|
|
866
|
-
}
|
|
867
|
-
getAuthstate() {
|
|
868
|
-
const observables = [this.getFireUser(), this.getUser()];
|
|
869
|
-
return combineLatest(observables).pipe(map(([fireUser, user]) => ({
|
|
870
|
-
user,
|
|
871
|
-
isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
|
|
872
|
-
})));
|
|
873
|
-
}
|
|
874
|
-
getUser() {
|
|
875
|
-
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))));
|
|
876
|
-
}
|
|
877
|
-
getTokenId() {
|
|
878
|
-
return from(getIdToken(this.angularFireAuth.currentUser));
|
|
879
|
-
}
|
|
880
|
-
getFireUser() {
|
|
881
|
-
return authState(this.angularFireAuth).pipe(catchError(() => of(null)));
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, deps: [{ token: i1$1.Auth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
885
|
-
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService });
|
|
886
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, decorators: [{
|
|
887
|
-
type: Injectable
|
|
888
|
-
}], ctorParameters: function () {
|
|
889
|
-
return [{ type: i1$1.Auth }, { type: undefined, decorators: [{
|
|
890
|
-
type: Inject,
|
|
891
|
-
args: ['UserRepository']
|
|
892
|
-
}] }];
|
|
893
|
-
} });
|
|
894
|
-
|
|
895
|
-
class CouponService {
|
|
896
|
-
constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
|
|
897
|
-
this.couponRepository = couponRepository;
|
|
898
|
-
this.defaultShop = defaultShop;
|
|
899
|
-
this.orderRepository = orderRepository;
|
|
900
|
-
this.categoryRepository = categoryRepository;
|
|
901
|
-
this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
|
|
902
|
-
}
|
|
903
|
-
checkCoupon(nickname, checkoutType, checkout, plan) {
|
|
904
|
-
return from(this.couponRepository
|
|
905
|
-
.find({
|
|
906
|
-
filters: {
|
|
907
|
-
nickname: { operator: Where.EQUALS, value: nickname },
|
|
908
|
-
active: { operator: Where.EQUALS, value: true },
|
|
909
|
-
},
|
|
910
|
-
})
|
|
911
|
-
.then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation(couponValid, checkoutType, checkout, plan)), map((couponValidated) => couponValidated));
|
|
912
|
-
}
|
|
913
|
-
couponValidation(coupon, checkoutType) {
|
|
914
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
915
|
-
if (!coupon)
|
|
916
|
-
throw 'Cupom inválido.';
|
|
917
|
-
if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) && (coupon === null || coupon === void 0 ? void 0 : coupon.beginAt.getTime()) > new Date().getTime())
|
|
918
|
-
throw 'Cupom inválido.';
|
|
919
|
-
if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) && (coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn.getTime()) < new Date().getTime())
|
|
920
|
-
throw 'Cupom expirado.';
|
|
921
|
-
const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
|
|
922
|
-
if (!isInShop)
|
|
923
|
-
throw 'Cupom inválido para loja.';
|
|
924
|
-
const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
|
|
925
|
-
if (!isCheckoutType)
|
|
926
|
-
throw 'Cupom inválido. Erro de checkout.';
|
|
927
|
-
return coupon;
|
|
928
|
-
});
|
|
929
|
-
}
|
|
930
|
-
couponRulesValidation(coupon, checkoutType, checkout, plan) {
|
|
931
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
932
|
-
if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
|
|
933
|
-
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
|
|
934
|
-
throw 'Cupom inválido para sua assinatura.';
|
|
935
|
-
return coupon;
|
|
936
|
-
}
|
|
937
|
-
const validUser = this.coupomUserValidation(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
|
|
138
|
+
});
|
|
139
|
+
// orders que usuario ja fez com o cupom
|
|
140
|
+
const ordersUserCoupon = orders.data.filter((o) => o.user.email == userEmail);
|
|
141
|
+
// Verifica o limite de uso de cupom por usuario
|
|
142
|
+
if (coupon.useLimitPerUser && ordersUserCoupon.length)
|
|
143
|
+
throw new InvalidCouponError('Limite de uso por usuário atingido.');
|
|
144
|
+
// Verifica o limite de uso geral por usuario
|
|
145
|
+
if (coupon.useLimit && orders.data.length >= coupon.useLimit)
|
|
146
|
+
throw new InvalidCouponError('Limite de uso atingido.');
|
|
147
|
+
const validUser = yield this.userValidationAndSubscriptionStatus(coupon, userEmail);
|
|
938
148
|
if (!validUser)
|
|
939
|
-
throw 'Usuário não elegível.';
|
|
940
|
-
const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
|
|
941
|
-
if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
|
|
942
|
-
const orders = yield this.getOrdersWithCoupon(coupon);
|
|
943
|
-
if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
|
|
944
|
-
throw 'Limite de uso atingido.';
|
|
945
|
-
if (couponUseLimits.limitedPerUser) {
|
|
946
|
-
const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
|
|
947
|
-
if (ordersWithUser > 0)
|
|
948
|
-
throw 'Limite de uso por usuário atingido.';
|
|
949
|
-
}
|
|
950
|
-
}
|
|
149
|
+
throw new InvalidCouponError('Usuário não elegível.');
|
|
951
150
|
const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
|
|
952
151
|
if (!hasProductCategories)
|
|
953
152
|
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
954
|
-
const hasMinSubTotal = yield this.hasMinSubTotal(coupon, checkout);
|
|
955
|
-
if (!hasMinSubTotal)
|
|
956
|
-
throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`;
|
|
957
153
|
return coupon;
|
|
958
154
|
});
|
|
959
155
|
}
|
|
960
156
|
calcDiscountSubscription(coupon, checkout) {
|
|
157
|
+
//
|
|
961
158
|
let discount = 0;
|
|
962
|
-
if (coupon.
|
|
963
|
-
discount = coupon.discount
|
|
964
|
-
else
|
|
965
|
-
discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount
|
|
159
|
+
if (coupon.type === CouponTypes.ABSOLUTE)
|
|
160
|
+
discount = coupon.discount;
|
|
161
|
+
else if (coupon.type === CouponTypes.PERCENTAGE)
|
|
162
|
+
discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount / 100);
|
|
966
163
|
return of(discount);
|
|
967
164
|
}
|
|
968
165
|
calcDiscountShopping(coupon, checkout) {
|
|
969
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
970
167
|
let discount = 0;
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
168
|
+
switch (coupon.type) {
|
|
169
|
+
case CouponTypes.ABSOLUTE: {
|
|
170
|
+
discount = coupon.discount;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
case CouponTypes.PERCENTAGE: {
|
|
174
|
+
discount = yield this.calcShoppingPercentageDiscount(coupon, checkout);
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
976
177
|
}
|
|
977
178
|
return discount;
|
|
978
179
|
});
|
|
979
180
|
}
|
|
980
|
-
|
|
181
|
+
calcShoppingPercentageDiscount(coupon, checkout) {
|
|
182
|
+
var _a;
|
|
981
183
|
return __awaiter(this, void 0, void 0, function* () {
|
|
982
184
|
let discount = 0;
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
185
|
+
const shop = checkout.shop;
|
|
186
|
+
let lineItensDiscount = [];
|
|
187
|
+
const couponCategories = yield this.getCouponCategoriesId(coupon);
|
|
188
|
+
if (coupon.productsCategories && coupon.productsCategories.length) {
|
|
189
|
+
lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
|
|
190
|
+
var _a;
|
|
191
|
+
if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
|
|
192
|
+
return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
|
|
193
|
+
}
|
|
194
|
+
return true;
|
|
195
|
+
});
|
|
987
196
|
}
|
|
988
197
|
else {
|
|
989
|
-
|
|
198
|
+
lineItensDiscount = checkout.lineItems;
|
|
990
199
|
}
|
|
200
|
+
const subTotal = lineItensDiscount.reduce((acc, curr) => {
|
|
201
|
+
var _a, _b, _c;
|
|
202
|
+
return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
|
|
203
|
+
? acc + ((_c = curr.price) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
|
|
204
|
+
: acc + curr.pricePaid * curr.quantity;
|
|
205
|
+
}, 0) || 0;
|
|
206
|
+
discount = subTotal * (coupon.discount / 100);
|
|
991
207
|
return discount;
|
|
992
208
|
});
|
|
993
209
|
}
|
|
994
210
|
hasMinSubTotal(coupon, checkout) {
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
211
|
+
var _a;
|
|
212
|
+
if (!coupon.minSubTotalValue)
|
|
213
|
+
return true;
|
|
214
|
+
const shop = checkout.shop;
|
|
215
|
+
let subTotal = ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.reduce((acc, curr) => {
|
|
216
|
+
var _a, _b, _c;
|
|
217
|
+
return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
|
|
218
|
+
? acc + ((_c = curr.price) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
|
|
219
|
+
: acc + curr.pricePaid * curr.quantity;
|
|
220
|
+
}, 0)) || 0;
|
|
221
|
+
if (coupon.minSubTotalValue <= subTotal)
|
|
222
|
+
return true;
|
|
223
|
+
return false;
|
|
1004
224
|
}
|
|
1005
225
|
hasProductCategories(coupon, checkout) {
|
|
1006
226
|
var _a;
|
|
@@ -1008,106 +228,66 @@ class CouponService {
|
|
|
1008
228
|
if (!coupon.productsCategories || !coupon.productsCategories.length) {
|
|
1009
229
|
return true;
|
|
1010
230
|
}
|
|
1011
|
-
const couponCategories = yield this.getCouponCategoriesId(coupon
|
|
231
|
+
const couponCategories = yield this.getCouponCategoriesId(coupon);
|
|
1012
232
|
const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
|
|
1013
233
|
var _a;
|
|
1014
234
|
if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
1015
235
|
return true;
|
|
1016
|
-
return i.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
236
|
+
return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
|
|
1017
237
|
});
|
|
1018
238
|
return hasCategories.length ? true : false;
|
|
1019
239
|
});
|
|
1020
240
|
}
|
|
1021
|
-
|
|
1022
|
-
if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
|
|
1023
|
-
return true;
|
|
1024
|
-
let userTypes = [];
|
|
1025
|
-
if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) && this.emailIsFromCollaborator(user.email))
|
|
1026
|
-
userTypes.push(Exclusivities.COLLABORATORS);
|
|
1027
|
-
if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) && coupon.userExclusiveEmail.includes(user.email))
|
|
1028
|
-
userTypes.push(Exclusivities.SPECIFIC_USER);
|
|
1029
|
-
if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
|
|
1030
|
-
user.isSubscriber &&
|
|
1031
|
-
user.subscriptionPlan != '')
|
|
1032
|
-
userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
|
|
1033
|
-
if (user.isSubscriber &&
|
|
1034
|
-
user.subscriptionPlan == '' &&
|
|
1035
|
-
coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
|
|
1036
|
-
userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
|
|
1037
|
-
if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
|
|
1038
|
-
userTypes.push(Exclusivities.NON_SUBSCRIBER);
|
|
1039
|
-
return coupon.exclusivityType.some((r) => userTypes.includes(r));
|
|
1040
|
-
}
|
|
1041
|
-
getCouponCategoriesId(productsCategories) {
|
|
241
|
+
userValidationAndSubscriptionStatus(coupon, userEmail) {
|
|
1042
242
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
243
|
+
// Verifica se o email do usuário é coorporativo
|
|
244
|
+
if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
|
|
245
|
+
throw new InvalidCouponError('Você não é colaborador.');
|
|
246
|
+
// Verifica se o email do usuário é associado ao cupom de uso por usuario
|
|
247
|
+
if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== userEmail)
|
|
248
|
+
throw new InvalidCouponError('Cupom não é válido para este usuário.');
|
|
249
|
+
const couponRuleSubscription = coupon.exclusivityType === Exclusivities.ACTIVE_SUBSCRIBER ||
|
|
250
|
+
coupon.exclusivityType === Exclusivities.INACTIVE_SUBSCRIBER ||
|
|
251
|
+
coupon.exclusivityType === Exclusivities.NON_SUBSCRIBER;
|
|
252
|
+
if (couponRuleSubscription && userEmail) {
|
|
253
|
+
const sub = yield this.subscriptionRepository
|
|
254
|
+
.find({
|
|
255
|
+
filters: {
|
|
256
|
+
user: {
|
|
257
|
+
email: { operator: Where.EQUALS, value: userEmail },
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
})
|
|
261
|
+
.then((sub) => sub.data);
|
|
262
|
+
const activeSubs = sub === null || sub === void 0 ? void 0 : sub.filter((s) => s.status === Status.ACTIVE);
|
|
263
|
+
switch (coupon.exclusivityType) {
|
|
264
|
+
case Exclusivities.ACTIVE_SUBSCRIBER:
|
|
265
|
+
return activeSubs.length > 0;
|
|
266
|
+
case Exclusivities.INACTIVE_SUBSCRIBER:
|
|
267
|
+
return activeSubs.length === 0;
|
|
268
|
+
case Exclusivities.NON_SUBSCRIBER:
|
|
269
|
+
return sub.length === 0;
|
|
270
|
+
default:
|
|
271
|
+
return false;
|
|
1051
272
|
}
|
|
1052
273
|
}
|
|
1053
|
-
return
|
|
274
|
+
return true;
|
|
1054
275
|
});
|
|
1055
276
|
}
|
|
1056
|
-
|
|
1057
|
-
var _a;
|
|
277
|
+
getCouponCategoriesId(coupon) {
|
|
1058
278
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1059
|
-
let
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
var _a;
|
|
1064
|
-
if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1065
|
-
return i.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
1066
|
-
}
|
|
1067
|
-
return true;
|
|
279
|
+
let couponCategories = [];
|
|
280
|
+
for (let index = 0; index < coupon.productsCategories.length; index++) {
|
|
281
|
+
let c = yield this.categoryRepository.get({
|
|
282
|
+
id: coupon.productsCategories[index],
|
|
1068
283
|
});
|
|
284
|
+
couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
|
|
1069
285
|
}
|
|
1070
|
-
|
|
1071
|
-
lineItensDiscount = checkout.lineItems;
|
|
1072
|
-
}
|
|
1073
|
-
return lineItensDiscount;
|
|
1074
|
-
});
|
|
1075
|
-
}
|
|
1076
|
-
calcCheckoutSubtotal(lineItens, user, shop) {
|
|
1077
|
-
return ((lineItens === null || lineItens === void 0 ? void 0 : lineItens.reduce((acc, curr) => {
|
|
1078
|
-
var _a;
|
|
1079
|
-
return (user === null || user === void 0 ? void 0 : user.isSubscriber) && curr.price.subscriberPrice
|
|
1080
|
-
? acc + ((_a = curr.price) === null || _a === void 0 ? void 0 : _a.subscriberPrice) * curr.quantity
|
|
1081
|
-
: acc + curr.pricePaid * curr.quantity;
|
|
1082
|
-
}, 0)) || 0);
|
|
1083
|
-
}
|
|
1084
|
-
getOrdersWithCoupon(coupon) {
|
|
1085
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1086
|
-
return yield this.orderRepository
|
|
1087
|
-
.find({
|
|
1088
|
-
filters: {
|
|
1089
|
-
coupon: { id: coupon.id },
|
|
1090
|
-
payment: { status: 'paid' },
|
|
1091
|
-
},
|
|
1092
|
-
})
|
|
1093
|
-
.then((result) => result.data);
|
|
286
|
+
return couponCategories;
|
|
1094
287
|
});
|
|
1095
288
|
}
|
|
1096
|
-
countOrdersWithUser(orders, email) {
|
|
1097
|
-
return orders.filter((o) => o.user.email == email).length;
|
|
1098
|
-
}
|
|
1099
|
-
getCouponUseLimits(coupon, checkoutType, user) {
|
|
1100
|
-
let couponUseLimits;
|
|
1101
|
-
if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
|
|
1102
|
-
couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
|
|
1103
|
-
}
|
|
1104
|
-
else {
|
|
1105
|
-
couponUseLimits = coupon.useLimits.subscription;
|
|
1106
|
-
}
|
|
1107
|
-
return couponUseLimits;
|
|
1108
|
-
}
|
|
1109
289
|
}
|
|
1110
|
-
CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
290
|
+
CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'SubscriptionRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1111
291
|
CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
|
|
1112
292
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
|
|
1113
293
|
type: Injectable,
|
|
@@ -1118,12 +298,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
1118
298
|
return [{ type: undefined, decorators: [{
|
|
1119
299
|
type: Inject,
|
|
1120
300
|
args: ['CouponRepository']
|
|
1121
|
-
}] }, { type:
|
|
301
|
+
}] }, { type: i2.Shops, decorators: [{
|
|
1122
302
|
type: Inject,
|
|
1123
303
|
args: [DEFAULT_SHOP]
|
|
1124
304
|
}] }, { type: undefined, decorators: [{
|
|
1125
305
|
type: Inject,
|
|
1126
306
|
args: ['OrderRepository']
|
|
307
|
+
}] }, { type: undefined, decorators: [{
|
|
308
|
+
type: Inject,
|
|
309
|
+
args: ['SubscriptionRepository']
|
|
1127
310
|
}] }, { type: undefined, decorators: [{
|
|
1128
311
|
type: Inject,
|
|
1129
312
|
args: ['CategoryRepository']
|
|
@@ -1161,7 +344,12 @@ class CheckoutService {
|
|
|
1161
344
|
return this.getCheckout().pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.couponService.calcDiscountShopping(coupon, checkout); })));
|
|
1162
345
|
}
|
|
1163
346
|
checkCoupon(nickname, checkoutType) {
|
|
1164
|
-
return this.getCheckout().pipe(concatMap((checkout) =>
|
|
347
|
+
return this.getCheckout().pipe(concatMap((checkout) => {
|
|
348
|
+
var _a;
|
|
349
|
+
return this.couponService
|
|
350
|
+
.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, CheckoutTypes.ECOMMERCE, checkout.user.subscriptionPlan, checkout, false)
|
|
351
|
+
.pipe();
|
|
352
|
+
}));
|
|
1165
353
|
}
|
|
1166
354
|
createCheckout(checkoutData) {
|
|
1167
355
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1185,26 +373,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
1185
373
|
}] }, { type: undefined, decorators: [{
|
|
1186
374
|
type: Inject,
|
|
1187
375
|
args: ['UserRepository']
|
|
1188
|
-
}] }, { type:
|
|
376
|
+
}] }, { type: i2.Shops, decorators: [{
|
|
1189
377
|
type: Inject,
|
|
1190
378
|
args: [DEFAULT_SHOP]
|
|
1191
379
|
}] }];
|
|
1192
380
|
} });
|
|
1193
381
|
|
|
1194
382
|
class CartService {
|
|
1195
|
-
constructor(authService, checkoutService, defaultShop, productRepository
|
|
383
|
+
constructor(authService, checkoutService, defaultShop, productRepository) {
|
|
1196
384
|
this.authService = authService;
|
|
1197
385
|
this.checkoutService = checkoutService;
|
|
1198
386
|
this.defaultShop = defaultShop;
|
|
1199
387
|
this.productRepository = productRepository;
|
|
1200
|
-
this.categoryRepository = categoryRepository;
|
|
1201
|
-
this.variantRepository = variantRepository;
|
|
1202
|
-
this.buy2WinRepository = buy2WinRepository;
|
|
1203
388
|
this.cartSubject = new Subject();
|
|
1204
389
|
this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
|
|
1205
390
|
var _a;
|
|
1206
391
|
const items = [];
|
|
1207
|
-
const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.
|
|
392
|
+
const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
|
|
1208
393
|
if (index > -1) {
|
|
1209
394
|
checkoutLoaded.lineItems[index].quantity += quantity;
|
|
1210
395
|
checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
|
|
@@ -1215,25 +400,28 @@ class CartService {
|
|
|
1215
400
|
.updateCheckoutLineItems(checkoutLoaded)
|
|
1216
401
|
.pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
|
|
1217
402
|
}));
|
|
1218
|
-
this.generateCartObject = (items) =>
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
403
|
+
this.generateCartObject = (items) => {
|
|
404
|
+
const cart = {};
|
|
405
|
+
items === null || items === void 0 ? void 0 : items.forEach((item) => {
|
|
406
|
+
var _a;
|
|
407
|
+
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) })));
|
|
408
|
+
});
|
|
409
|
+
return cart;
|
|
410
|
+
};
|
|
1222
411
|
this.buildLineItem = ({ checkout, item, quantity, }) => __awaiter(this, void 0, void 0, function* () {
|
|
1223
412
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1224
|
-
const product = yield this.
|
|
1225
|
-
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.
|
|
413
|
+
const product = yield this.productRepository.get({ id: item.id });
|
|
414
|
+
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;
|
|
1226
415
|
if (this.checkMaxStock(item, quantity || 0))
|
|
1227
416
|
throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
|
|
1228
417
|
const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
|
|
1229
|
-
const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
|
|
418
|
+
const { id, name, EAN, brand, slug, stock, price, weight, categories, sku, type } = item;
|
|
1230
419
|
const isGift = item.isGift || null;
|
|
1231
420
|
const pricePaid = this.getProductPrice({
|
|
1232
421
|
product: item,
|
|
1233
422
|
shop: checkout.shop || this.defaultShop,
|
|
1234
423
|
isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
|
|
1235
424
|
});
|
|
1236
|
-
RoundProductPricesHelper.roundProductPrices(item);
|
|
1237
425
|
return {
|
|
1238
426
|
checkout,
|
|
1239
427
|
lineItem: LineItem.toInstance({
|
|
@@ -1244,7 +432,7 @@ class CartService {
|
|
|
1244
432
|
slug: slug !== null && slug !== void 0 ? slug : product.slug,
|
|
1245
433
|
sku: sku !== null && sku !== void 0 ? sku : product.sku,
|
|
1246
434
|
stock,
|
|
1247
|
-
price
|
|
435
|
+
price,
|
|
1248
436
|
image,
|
|
1249
437
|
weight: weight !== null && weight !== void 0 ? weight : product.weight,
|
|
1250
438
|
quantity: (item.quantity || 0) + (quantity || 0),
|
|
@@ -1260,9 +448,7 @@ class CartService {
|
|
|
1260
448
|
const info = product.price;
|
|
1261
449
|
if (product.isGift)
|
|
1262
450
|
return 0;
|
|
1263
|
-
return isSubscriber && info.subscriberPrice > 0
|
|
1264
|
-
? Number(info.subscriberPrice.toFixed(2))
|
|
1265
|
-
: Number(info.price.toFixed(2));
|
|
451
|
+
return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
|
|
1266
452
|
};
|
|
1267
453
|
this.checkMaxStock = (item, quantity) => {
|
|
1268
454
|
var _a;
|
|
@@ -1277,7 +463,7 @@ class CartService {
|
|
|
1277
463
|
decreaseItem(item) {
|
|
1278
464
|
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1279
465
|
var _a;
|
|
1280
|
-
const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.
|
|
466
|
+
const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
|
|
1281
467
|
if (!isNil(checkoutItem))
|
|
1282
468
|
checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
|
|
1283
469
|
return checkout;
|
|
@@ -1295,7 +481,7 @@ class CartService {
|
|
|
1295
481
|
}
|
|
1296
482
|
removeItem(item) {
|
|
1297
483
|
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1298
|
-
const index = checkout.lineItems.findIndex((lineItem) => lineItem.
|
|
484
|
+
const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
|
|
1299
485
|
if (index >= 0)
|
|
1300
486
|
checkout.lineItems.splice(index, 1);
|
|
1301
487
|
return checkout;
|
|
@@ -1304,12 +490,8 @@ class CartService {
|
|
|
1304
490
|
updateUserCart(user) {
|
|
1305
491
|
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* () {
|
|
1306
492
|
var _a, _b;
|
|
1307
|
-
return this.checkoutService
|
|
1308
|
-
|
|
1309
|
-
? 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; })))
|
|
1310
|
-
: [] })))
|
|
1311
|
-
.toPromise();
|
|
1312
|
-
})), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
493
|
+
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();
|
|
494
|
+
})), map(checkout => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1313
495
|
}
|
|
1314
496
|
clearCart() {
|
|
1315
497
|
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
@@ -1318,513 +500,21 @@ class CartService {
|
|
|
1318
500
|
}), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
|
|
1319
501
|
}
|
|
1320
502
|
buildCartFromCheckout(checkoutData) {
|
|
1321
|
-
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
1322
|
-
}
|
|
1323
|
-
roundPrice(productPrice) {
|
|
1324
|
-
const { price, fullPrice, subscriberPrice } = productPrice;
|
|
1325
|
-
return Object.assign(Object.assign(Object.assign({}, productPrice), { price: Number(price.toFixed(2)), fullPrice: Number(fullPrice.toFixed(2)) }), (subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }));
|
|
1326
|
-
}
|
|
1327
|
-
getProductData(productId) {
|
|
1328
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1329
|
-
let product;
|
|
1330
|
-
let variant;
|
|
1331
|
-
try {
|
|
1332
|
-
product = yield this.productRepository.get({ id: productId });
|
|
1333
|
-
}
|
|
1334
|
-
catch (error) {
|
|
1335
|
-
if (!(error instanceof NotFoundError))
|
|
1336
|
-
throw error;
|
|
1337
|
-
const { data: variants } = yield this.variantRepository.find({ filters: { id: productId } });
|
|
1338
|
-
variant = variants.shift();
|
|
1339
|
-
if (!variant)
|
|
1340
|
-
throw error;
|
|
1341
|
-
product = yield this.productRepository.get({ id: variant.productId });
|
|
1342
|
-
}
|
|
1343
|
-
return Object.assign(Object.assign({}, product.toPlain()), (variant && Object.assign({}, variant.toPlain())));
|
|
1344
|
-
});
|
|
1345
|
-
}
|
|
1346
|
-
getGifts() {
|
|
1347
|
-
return this.checkoutService.getCheckout().pipe(mergeMap((checkout) => __awaiter(this, void 0, void 0, function* () {
|
|
1348
|
-
const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
|
|
1349
|
-
if (!notGiftItems.length)
|
|
1350
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: [] });
|
|
1351
|
-
const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1352
|
-
const campaigns = yield this.buy2WinRepository
|
|
1353
|
-
.find({
|
|
1354
|
-
filters: {
|
|
1355
|
-
active: { operator: Where.EQUALS, value: true },
|
|
1356
|
-
shop: { operator: Where.EQUALS, value: this.defaultShop },
|
|
1357
|
-
},
|
|
1358
|
-
})
|
|
1359
|
-
.then((data) => data.data);
|
|
1360
|
-
if (!campaigns.length)
|
|
1361
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
|
|
1362
|
-
const elegibleCampaigns = [];
|
|
1363
|
-
for (const campaign of campaigns) {
|
|
1364
|
-
const today = new Date().getDate();
|
|
1365
|
-
if (!(campaign.startDate.getDate() <= today) && !(campaign.endDate.getDate() >= today))
|
|
1366
|
-
continue;
|
|
1367
|
-
if (campaign.activeCategory) {
|
|
1368
|
-
const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
|
|
1369
|
-
const categoriesCampaingFullTree = [];
|
|
1370
|
-
for (const id of categoriesCampaing) {
|
|
1371
|
-
const children = yield this.categoryRepository.getChildren(parseInt(id));
|
|
1372
|
-
categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
|
|
1373
|
-
}
|
|
1374
|
-
const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
|
|
1375
|
-
const filterProductsCategories = checkout.lineItems.filter((l) => {
|
|
1376
|
-
var _a;
|
|
1377
|
-
if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
1378
|
-
return true;
|
|
1379
|
-
return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
|
|
1380
|
-
});
|
|
1381
|
-
if (filterProductsCategories.length) {
|
|
1382
|
-
const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1383
|
-
if (cartTotalCategories >= campaign.cartValueMin)
|
|
1384
|
-
elegibleCampaigns.push(campaign);
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
else {
|
|
1388
|
-
if (campaign.cartValue && campaign.cartValue > 0) {
|
|
1389
|
-
if (campaign.cartValue <= cartTotal)
|
|
1390
|
-
elegibleCampaigns.push(campaign);
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
if (!elegibleCampaigns.length)
|
|
1395
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
|
|
1396
|
-
const campaingnProducts = [];
|
|
1397
|
-
for (const campaign of elegibleCampaigns) {
|
|
1398
|
-
let elegibleProducts = [];
|
|
1399
|
-
for (const product of campaign.products) {
|
|
1400
|
-
const { data: productData } = yield this.productRepository.find({ filters: { sku: product } });
|
|
1401
|
-
if (!productData.length)
|
|
1402
|
-
continue;
|
|
1403
|
-
const gift = productData.shift();
|
|
1404
|
-
if (gift.stock.quantity < 1)
|
|
1405
|
-
continue;
|
|
1406
|
-
elegibleProducts.push(gift);
|
|
1407
|
-
}
|
|
1408
|
-
campaingnProducts.push(elegibleProducts);
|
|
1409
|
-
}
|
|
1410
|
-
if (!campaingnProducts.length)
|
|
1411
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
|
|
1412
|
-
const gifts = this.giftToLineItems([].concat(...campaingnProducts));
|
|
1413
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems.concat(gifts) });
|
|
1414
|
-
})), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1415
|
-
}
|
|
1416
|
-
giftToLineItems(items) {
|
|
1417
|
-
return items.map((item) => {
|
|
1418
|
-
var _a;
|
|
1419
|
-
const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
|
|
1420
|
-
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];
|
|
1421
|
-
return LineItem.toInstance({
|
|
1422
|
-
brand,
|
|
1423
|
-
categories,
|
|
1424
|
-
id: id.toString(),
|
|
1425
|
-
name,
|
|
1426
|
-
price,
|
|
1427
|
-
sku,
|
|
1428
|
-
slug,
|
|
1429
|
-
stock,
|
|
1430
|
-
weight,
|
|
1431
|
-
EAN,
|
|
1432
|
-
image,
|
|
1433
|
-
pricePaid: 0,
|
|
1434
|
-
quantity: 1,
|
|
1435
|
-
isGift: true,
|
|
1436
|
-
});
|
|
1437
|
-
});
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1441
|
-
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
|
|
1442
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
|
|
1443
|
-
type: Injectable
|
|
1444
|
-
}], ctorParameters: function () {
|
|
1445
|
-
return [{ type: AuthService }, { type: CheckoutService }, { type: i1$3.Shops, decorators: [{
|
|
1446
|
-
type: Inject,
|
|
1447
|
-
args: [DEFAULT_SHOP]
|
|
1448
|
-
}] }, { type: undefined, decorators: [{
|
|
1449
|
-
type: Inject,
|
|
1450
|
-
args: ['ProductRepository']
|
|
1451
|
-
}] }, { type: undefined, decorators: [{
|
|
1452
|
-
type: Inject,
|
|
1453
|
-
args: ['CategoryRepository']
|
|
1454
|
-
}] }, { type: undefined, decorators: [{
|
|
1455
|
-
type: Inject,
|
|
1456
|
-
args: ['VariantRepository']
|
|
1457
|
-
}] }, { type: i1$3.Buy2WinFirestoreRepository, decorators: [{
|
|
1458
|
-
type: Inject,
|
|
1459
|
-
args: ['Buy2WinRepository']
|
|
1460
|
-
}] }];
|
|
1461
|
-
} });
|
|
1462
|
-
|
|
1463
|
-
class CatalogService {
|
|
1464
|
-
constructor(productRepository, categoryStructureAdapter, shop) {
|
|
1465
|
-
this.productRepository = productRepository;
|
|
1466
|
-
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1467
|
-
this.shop = shop;
|
|
1468
|
-
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1469
|
-
const filters = {};
|
|
1470
|
-
if (clubDiscount === null || clubDiscount === void 0 ? void 0 : clubDiscount.length)
|
|
1471
|
-
set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
|
|
1472
|
-
if (brands === null || brands === void 0 ? void 0 : brands.length)
|
|
1473
|
-
filters.brand = { operator: Where.IN, value: brands };
|
|
1474
|
-
if (gender === null || gender === void 0 ? void 0 : gender.length)
|
|
1475
|
-
filters.tags = {
|
|
1476
|
-
operator: Where.IN,
|
|
1477
|
-
value: gender
|
|
1478
|
-
.map((genderOptions) => genderOptions === 'female' ? 'feminino' : genderOptions === 'male' ? 'masculino' : null)
|
|
1479
|
-
.filter(Boolean),
|
|
1480
|
-
};
|
|
1481
|
-
if ((prices === null || prices === void 0 ? void 0 : prices.min) || (prices === null || prices === void 0 ? void 0 : prices.max))
|
|
1482
|
-
set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', [
|
|
1483
|
-
...(prices.min ? [{ operator: Where.GTE, value: Math.round(prices.min) }] : []),
|
|
1484
|
-
...(prices.max ? [{ operator: Where.LTE, value: Math.ceil(prices.max) }] : []),
|
|
1485
|
-
]);
|
|
1486
|
-
if (rate)
|
|
1487
|
-
filters.rate = { operator: Where.GTE, value: rate };
|
|
1488
|
-
if (tags === null || tags === void 0 ? void 0 : tags.length)
|
|
1489
|
-
filters.tags = { operator: Where.LIKE, value: tags };
|
|
1490
|
-
if (customOptions === null || customOptions === void 0 ? void 0 : customOptions.length)
|
|
1491
|
-
filters.filters = { operator: Where.LIKE, value: customOptions };
|
|
1492
|
-
return filters;
|
|
1493
|
-
};
|
|
1494
|
-
this.buildSortQuery = (sort) => {
|
|
1495
|
-
if (!sort || sort === 'most-relevant')
|
|
1496
|
-
return {};
|
|
1497
|
-
if (sort === 'best-sellers')
|
|
1498
|
-
return { shoppingCount: 'desc' };
|
|
1499
|
-
if (sort === 'biggest-price')
|
|
1500
|
-
return { price: 'desc' };
|
|
1501
|
-
if (sort === 'lowest-price')
|
|
1502
|
-
return { price: 'asc' };
|
|
1503
|
-
if (sort === 'best-rating')
|
|
1504
|
-
return { rate: 'desc' };
|
|
1505
|
-
if (sort === 'news')
|
|
1506
|
-
return { createdAt: 'desc' };
|
|
1507
|
-
};
|
|
1508
|
-
this.buildLimitQuery = (options) => {
|
|
1509
|
-
const limit = (options === null || options === void 0 ? void 0 : options.perPage) || 20;
|
|
1510
|
-
return {
|
|
1511
|
-
limit,
|
|
1512
|
-
offset: (((options === null || options === void 0 ? void 0 : options.page) || 1) - 1) * limit,
|
|
1513
|
-
};
|
|
1514
|
-
};
|
|
1515
|
-
}
|
|
1516
|
-
fetchProducts(category, options) {
|
|
1517
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1518
|
-
const limits = this.buildLimitQuery(options);
|
|
1519
|
-
return yield this.productRepository
|
|
1520
|
-
.findCatalog(Object.assign(Object.assign({ filters: Object.assign(Object.assign({}, (yield this.categoryStructureAdapter.buildProductFilterByCategory(category))), this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})) }, ((options === null || options === void 0 ? void 0 : options.sort) ? { orderBy: this.buildSortQuery(options === null || options === void 0 ? void 0 : options.sort) } : {})), { limits, options: { minimal: ['price'], maximum: ['price'] } }), (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1521
|
-
.then(({ data, count: total, maximum, minimal }) => {
|
|
1522
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1523
|
-
return ({
|
|
1524
|
-
products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
|
|
1525
|
-
pages: Math.ceil(total / limits.limit),
|
|
1526
|
-
prices: {
|
|
1527
|
-
price: { min: +((_b = (_a = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.toFixed(2)), max: +((_d = (_c = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _c === void 0 ? void 0 : _c.price) === null || _d === void 0 ? void 0 : _d.toFixed(2)) },
|
|
1528
|
-
subscriberPrice: {
|
|
1529
|
-
min: +((_f = (_e = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _e === void 0 ? void 0 : _e.subscriberPrice) === null || _f === void 0 ? void 0 : _f.toFixed(2)),
|
|
1530
|
-
max: +((_h = (_g = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _g === void 0 ? void 0 : _g.subscriberPrice) === null || _h === void 0 ? void 0 : _h.toFixed(2)),
|
|
1531
|
-
},
|
|
1532
|
-
},
|
|
1533
|
-
});
|
|
1534
|
-
});
|
|
1535
|
-
});
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1539
|
-
CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
|
|
1540
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
|
|
1541
|
-
type: Injectable
|
|
1542
|
-
}], ctorParameters: function () {
|
|
1543
|
-
return [{ type: undefined, decorators: [{
|
|
1544
|
-
type: Inject,
|
|
1545
|
-
args: ['ProductRepository']
|
|
1546
|
-
}] }, { type: undefined, decorators: [{
|
|
1547
|
-
type: Inject,
|
|
1548
|
-
args: [CATEGORY_STRUCTURE]
|
|
1549
|
-
}] }, { type: i1$3.Shops, decorators: [{
|
|
1550
|
-
type: Inject,
|
|
1551
|
-
args: [DEFAULT_SHOP]
|
|
1552
|
-
}] }];
|
|
1553
|
-
} });
|
|
1554
|
-
|
|
1555
|
-
class CategoryService {
|
|
1556
|
-
constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
|
|
1557
|
-
this.productRepository = productRepository;
|
|
1558
|
-
this.categoryRepository = categoryRepository;
|
|
1559
|
-
this.categoryFilterRepository = categoryFilterRepository;
|
|
1560
|
-
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1561
|
-
this.shop = shop;
|
|
1562
|
-
}
|
|
1563
|
-
fetchBrands(category, mainGender) {
|
|
1564
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1565
|
-
const brands = yield this.productRepository
|
|
1566
|
-
.findCatalog({
|
|
1567
|
-
filters: yield this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1568
|
-
fields: ['brand'],
|
|
1569
|
-
}, mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1570
|
-
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => (Object.assign(Object.assign({}, brands), { [brand]: true })), {})));
|
|
1571
|
-
return this.categoryRepository
|
|
1572
|
-
.find({ filters: { brandCategory: true }, orderBy: { name: 'asc' } })
|
|
1573
|
-
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1574
|
-
});
|
|
1575
|
-
}
|
|
1576
|
-
fetchFilterOptions(category, filters) {
|
|
1577
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1578
|
-
return yield this.categoryFilterRepository
|
|
1579
|
-
.find({ filters: { categoryId: +category.id } })
|
|
1580
|
-
.then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
|
|
1581
|
-
});
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
CategoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1585
|
-
CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
|
|
1586
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
|
|
1587
|
-
type: Injectable
|
|
1588
|
-
}], ctorParameters: function () {
|
|
1589
|
-
return [{ type: undefined, decorators: [{
|
|
1590
|
-
type: Inject,
|
|
1591
|
-
args: ['ProductRepository']
|
|
1592
|
-
}] }, { type: undefined, decorators: [{
|
|
1593
|
-
type: Inject,
|
|
1594
|
-
args: ['CategoryRepository']
|
|
1595
|
-
}] }, { type: undefined, decorators: [{
|
|
1596
|
-
type: Inject,
|
|
1597
|
-
args: ['CategoryFilterRepository']
|
|
1598
|
-
}] }, { type: undefined, decorators: [{
|
|
1599
|
-
type: Inject,
|
|
1600
|
-
args: [CATEGORY_STRUCTURE]
|
|
1601
|
-
}] }, { type: i1$3.Shops, decorators: [{
|
|
1602
|
-
type: Inject,
|
|
1603
|
-
args: [DEFAULT_SHOP]
|
|
1604
|
-
}] }];
|
|
1605
|
-
} });
|
|
1606
|
-
|
|
1607
|
-
var ProductSorts;
|
|
1608
|
-
(function (ProductSorts) {
|
|
1609
|
-
ProductSorts["MOST_RELEVANT"] = "most-relevant";
|
|
1610
|
-
ProductSorts["BEST_SELLER"] = "best-sellers";
|
|
1611
|
-
ProductSorts["BIGGEST_PRICE"] = "biggest-price";
|
|
1612
|
-
ProductSorts["LOWEST_PRICE"] = "lowest-price";
|
|
1613
|
-
ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
|
|
1614
|
-
ProductSorts["BEST_RATING"] = "best-rating";
|
|
1615
|
-
ProductSorts["NEWS"] = "news";
|
|
1616
|
-
})(ProductSorts || (ProductSorts = {}));
|
|
1617
|
-
|
|
1618
|
-
class CategoryWithTree extends Category {
|
|
1619
|
-
}
|
|
1620
|
-
__decorate([
|
|
1621
|
-
Type(() => CategoryWithTree),
|
|
1622
|
-
__metadata("design:type", Array)
|
|
1623
|
-
], CategoryWithTree.prototype, "children", void 0);
|
|
1624
|
-
|
|
1625
|
-
class NewCategoryStructureAdapter {
|
|
1626
|
-
constructor(categoryRepository, categoryCollectionChildrenRepository) {
|
|
1627
|
-
this.categoryRepository = categoryRepository;
|
|
1628
|
-
this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
|
|
1629
|
-
}
|
|
1630
|
-
buildProductFilterByCategory(category) {
|
|
1631
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1632
|
-
const categoriesIds = (yield this.isCollection(category))
|
|
1633
|
-
? yield this.getAllCategoriesIdFromCollection(category)
|
|
1634
|
-
: [...(yield this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
|
|
1635
|
-
return { category: { id: { operator: Where.IN, value: categoriesIds } } };
|
|
1636
|
-
});
|
|
1637
|
-
}
|
|
1638
|
-
getAllCategoriesIdFromCategory(category) {
|
|
1639
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1640
|
-
return this.categoryRepository
|
|
1641
|
-
.getChildren(+category.id)
|
|
1642
|
-
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1643
|
-
});
|
|
1644
|
-
}
|
|
1645
|
-
getAllCategoriesIdFromCollection(category) {
|
|
1646
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1647
|
-
return this.categoryCollectionChildrenRepository
|
|
1648
|
-
.find({ filters: { collectionId: +category.id } })
|
|
1649
|
-
.then(({ data }) => data.map((categoryCollection) => categoryCollection.categoryId.toString()));
|
|
1650
|
-
});
|
|
1651
|
-
}
|
|
1652
|
-
isCollection(category) {
|
|
1653
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1654
|
-
return !isNil(category.isCollection)
|
|
1655
|
-
? category.isCollection
|
|
1656
|
-
: this.categoryRepository.get({ id: category.id }).then((category) => category.isCollection);
|
|
1657
|
-
});
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }, { token: 'CategoryCollectionChildrenRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1661
|
-
NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
|
|
1662
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
|
|
1663
|
-
type: Injectable
|
|
1664
|
-
}], ctorParameters: function () {
|
|
1665
|
-
return [{ type: undefined, decorators: [{
|
|
1666
|
-
type: Inject,
|
|
1667
|
-
args: ['CategoryRepository']
|
|
1668
|
-
}] }, { type: undefined, decorators: [{
|
|
1669
|
-
type: Inject,
|
|
1670
|
-
args: ['CategoryCollectionChildrenRepository']
|
|
1671
|
-
}] }];
|
|
1672
|
-
} });
|
|
1673
|
-
|
|
1674
|
-
class OldCategoryStructureAdapter {
|
|
1675
|
-
constructor(categoryRepository) {
|
|
1676
|
-
this.categoryRepository = categoryRepository;
|
|
1677
|
-
}
|
|
1678
|
-
buildProductFilterByCategory(category) {
|
|
1679
|
-
var _a;
|
|
1680
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1681
|
-
const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
|
|
1682
|
-
? category.products
|
|
1683
|
-
: yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
|
|
1684
|
-
return { id: { operator: Where.IN, value: productsIds } };
|
|
1685
|
-
});
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1689
|
-
OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter });
|
|
1690
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
|
|
1691
|
-
type: Injectable
|
|
1692
|
-
}], ctorParameters: function () {
|
|
1693
|
-
return [{ type: undefined, decorators: [{
|
|
1694
|
-
type: Inject,
|
|
1695
|
-
args: ['CategoryRepository']
|
|
1696
|
-
}] }];
|
|
1697
|
-
} });
|
|
1698
|
-
|
|
1699
|
-
class UtilService {
|
|
1700
|
-
constructor() { }
|
|
1701
|
-
createSlug(name) {
|
|
1702
|
-
return name
|
|
1703
|
-
.toLowerCase()
|
|
1704
|
-
.replace(/\s+/g, '-') // Replace spaces with -
|
|
1705
|
-
.replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
|
|
1706
|
-
.replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
|
|
1707
|
-
.replace(/[ìíïî]/g, 'i') // Replace spaces with -
|
|
1708
|
-
.replace(/[õòóöô]/g, 'o') // Replace spaces with -
|
|
1709
|
-
.replace(/[ùúüû]/g, 'u') // Replace spaces with -
|
|
1710
|
-
.replace(/[ñ]/g, 'n') // Replace spaces with -
|
|
1711
|
-
.replace(/[ç]/g, 'c') // Replace spaces with -
|
|
1712
|
-
.replace(/[&]/g, 'and') // Replace spaces with -
|
|
1713
|
-
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
|
1714
|
-
.replace(/\-\-+/g, '-'); // Replace multiple - with single -
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
UtilService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: UtilService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1718
|
-
UtilService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: UtilService, providedIn: 'root' });
|
|
1719
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: UtilService, decorators: [{
|
|
1720
|
-
type: Injectable,
|
|
1721
|
-
args: [{
|
|
1722
|
-
providedIn: 'root',
|
|
1723
|
-
}]
|
|
1724
|
-
}], ctorParameters: function () { return []; } });
|
|
1725
|
-
|
|
1726
|
-
class WishlistService {
|
|
1727
|
-
constructor(wishlistRepository, productRepository, categoryFilterRepository, categoryCollectionChildrenRepository, shop, categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository, categoryCollectionChildrenRepository), catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop), categoryService = new CategoryService(productRepository, wishlistRepository, categoryFilterRepository, categoryStructureAdapter, shop), utilService) {
|
|
1728
|
-
this.wishlistRepository = wishlistRepository;
|
|
1729
|
-
this.shop = shop;
|
|
1730
|
-
this.catalogService = catalogService;
|
|
1731
|
-
this.categoryService = categoryService;
|
|
1732
|
-
this.utilService = utilService;
|
|
1733
|
-
}
|
|
1734
|
-
getCatalogService() {
|
|
1735
|
-
return this.catalogService;
|
|
1736
|
-
}
|
|
1737
|
-
getCategoryService() {
|
|
1738
|
-
return this.categoryService;
|
|
1739
|
-
}
|
|
1740
|
-
create(personId, title, description, userFullName) {
|
|
1741
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1742
|
-
const data = {
|
|
1743
|
-
slug: this.utilService.createSlug(`favoritos ${userFullName} ${title}`),
|
|
1744
|
-
name: title,
|
|
1745
|
-
description,
|
|
1746
|
-
metadata: {
|
|
1747
|
-
title: `${userFullName} - ${title}`,
|
|
1748
|
-
description: `${userFullName} - ${description}`,
|
|
1749
|
-
},
|
|
1750
|
-
shop: this.shop,
|
|
1751
|
-
shops: [this.shop],
|
|
1752
|
-
personId,
|
|
1753
|
-
brandCategory: false,
|
|
1754
|
-
published: true,
|
|
1755
|
-
};
|
|
1756
|
-
const newWishlist = yield this.wishlistRepository.create(data);
|
|
1757
|
-
return this.wishlistRepository.update({ id: newWishlist.id, slug: `${newWishlist.id}-${newWishlist.slug}` });
|
|
1758
|
-
});
|
|
1759
|
-
}
|
|
1760
|
-
update(id, title, description, userFullName) {
|
|
1761
|
-
const data = {
|
|
1762
|
-
id,
|
|
1763
|
-
slug: this.utilService.createSlug(`${id}-favoritos ${userFullName} ${title}`),
|
|
1764
|
-
name: title,
|
|
1765
|
-
description,
|
|
1766
|
-
metadata: {
|
|
1767
|
-
title: `${userFullName} - ${title}`,
|
|
1768
|
-
description: `${userFullName} - ${description}`,
|
|
1769
|
-
},
|
|
1770
|
-
};
|
|
1771
|
-
return this.wishlistRepository.update(data);
|
|
1772
|
-
}
|
|
1773
|
-
delete(wishlistId) {
|
|
1774
|
-
return this.wishlistRepository.delete({ id: wishlistId });
|
|
1775
|
-
}
|
|
1776
|
-
getWishlistBySlug(slug) {
|
|
1777
|
-
return this.wishlistRepository.getWishlistBySlug(slug);
|
|
1778
|
-
}
|
|
1779
|
-
getWishlistsByPerson(personId) {
|
|
1780
|
-
return this.wishlistRepository.getWishlistByPerson(personId);
|
|
1781
|
-
}
|
|
1782
|
-
addProduct(wishlistId, productId) {
|
|
1783
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1784
|
-
const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
|
|
1785
|
-
const hasProduct = wishlist.products.some((p) => p == productId);
|
|
1786
|
-
if (!hasProduct) {
|
|
1787
|
-
wishlist.products = [...wishlist.products, productId];
|
|
1788
|
-
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
1789
|
-
}
|
|
1790
|
-
return wishlist;
|
|
1791
|
-
});
|
|
1792
|
-
}
|
|
1793
|
-
removeProduct(wishlistId, productId) {
|
|
1794
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1795
|
-
const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
|
|
1796
|
-
const productIndex = wishlist.products.findIndex((p) => p == productId);
|
|
1797
|
-
if (productIndex != -1) {
|
|
1798
|
-
wishlist.products.splice(productIndex, 1);
|
|
1799
|
-
if (!wishlist.products.length)
|
|
1800
|
-
return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
|
|
1801
|
-
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
1802
|
-
}
|
|
1803
|
-
return wishlist;
|
|
1804
|
-
});
|
|
503
|
+
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
1805
504
|
}
|
|
1806
505
|
}
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type:
|
|
506
|
+
CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
507
|
+
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
|
|
508
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
|
|
1810
509
|
type: Injectable
|
|
1811
510
|
}], ctorParameters: function () {
|
|
1812
|
-
return [{ type:
|
|
511
|
+
return [{ type: AuthService }, { type: CheckoutService }, { type: i2.Shops, decorators: [{
|
|
1813
512
|
type: Inject,
|
|
1814
|
-
args: [
|
|
513
|
+
args: [DEFAULT_SHOP]
|
|
1815
514
|
}] }, { type: undefined, decorators: [{
|
|
1816
515
|
type: Inject,
|
|
1817
516
|
args: ['ProductRepository']
|
|
1818
|
-
}] }
|
|
1819
|
-
type: Inject,
|
|
1820
|
-
args: ['CategoryFilterRepository']
|
|
1821
|
-
}] }, { type: undefined, decorators: [{
|
|
1822
|
-
type: Inject,
|
|
1823
|
-
args: ['CategoryCollectionChildrenRepository']
|
|
1824
|
-
}] }, { type: i1$3.Shops, decorators: [{
|
|
1825
|
-
type: Inject,
|
|
1826
|
-
args: [DEFAULT_SHOP]
|
|
1827
|
-
}] }, { type: undefined }, { type: undefined }, { type: undefined }, { type: UtilService }];
|
|
517
|
+
}] }];
|
|
1828
518
|
} });
|
|
1829
519
|
|
|
1830
520
|
class CheckoutSubscriptionService {
|
|
@@ -1851,9 +541,7 @@ class CheckoutSubscriptionService {
|
|
|
1851
541
|
return of();
|
|
1852
542
|
}
|
|
1853
543
|
checkCoupon(nickname, userEmail) {
|
|
1854
|
-
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
1855
|
-
.checkCoupon(nickname, CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
|
|
1856
|
-
.pipe()));
|
|
544
|
+
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, null, true).pipe()));
|
|
1857
545
|
}
|
|
1858
546
|
calcDiscountSubscription(coupon) {
|
|
1859
547
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
@@ -1873,247 +561,794 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
1873
561
|
}] }, { type: CouponService }];
|
|
1874
562
|
} });
|
|
1875
563
|
|
|
1876
|
-
class
|
|
1877
|
-
constructor(
|
|
1878
|
-
this.
|
|
1879
|
-
this.
|
|
1880
|
-
this.
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
return
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
564
|
+
class OrderService {
|
|
565
|
+
constructor(angularFirestore, orderRepository) {
|
|
566
|
+
this.angularFirestore = angularFirestore;
|
|
567
|
+
this.orderRepository = orderRepository;
|
|
568
|
+
this.orderSubject = new Subject();
|
|
569
|
+
}
|
|
570
|
+
getOrder(id) {
|
|
571
|
+
docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
|
|
572
|
+
.pipe(map((doc) => Order.toInstance(doc.data())))
|
|
573
|
+
.subscribe((doc) => this.orderSubject.next(doc));
|
|
574
|
+
return this.orderSubject;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, deps: [{ token: i1$1.Firestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
578
|
+
OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
|
|
579
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
|
|
580
|
+
type: Injectable
|
|
581
|
+
}], ctorParameters: function () {
|
|
582
|
+
return [{ type: i1$1.Firestore }, { type: i2.OrderFirestoreRepository, decorators: [{
|
|
583
|
+
type: Inject,
|
|
584
|
+
args: ['OrderRepository']
|
|
585
|
+
}] }];
|
|
586
|
+
} });
|
|
587
|
+
|
|
588
|
+
class HomeShopService {
|
|
589
|
+
constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
590
|
+
this.categoryRepository = categoryRepository;
|
|
591
|
+
this.homeRepository = homeRepository;
|
|
592
|
+
this.productRepository = productRepository;
|
|
593
|
+
this.defaultShop = defaultShop;
|
|
594
|
+
this.buildCategoryGroupWithRequiredData = (group) => {
|
|
595
|
+
var _a, _b;
|
|
596
|
+
return ({
|
|
597
|
+
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'])),
|
|
598
|
+
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()) || {}, [
|
|
599
|
+
'id',
|
|
600
|
+
'price',
|
|
601
|
+
'reviews',
|
|
602
|
+
'hasVariants',
|
|
603
|
+
'slug',
|
|
604
|
+
'sku',
|
|
605
|
+
'stock',
|
|
606
|
+
'costPrice',
|
|
607
|
+
'images',
|
|
608
|
+
'miniatures',
|
|
609
|
+
'name',
|
|
610
|
+
'weight',
|
|
611
|
+
'rate',
|
|
612
|
+
'type',
|
|
613
|
+
])))) || [],
|
|
614
|
+
});
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
get homeId() {
|
|
618
|
+
if (this.defaultShop === Shops.GLAMSHOP)
|
|
619
|
+
return 'glamshop';
|
|
620
|
+
if (this.defaultShop === Shops.MENSMARKET)
|
|
621
|
+
return 'mens_market';
|
|
622
|
+
return null;
|
|
623
|
+
}
|
|
624
|
+
getHomeData() {
|
|
625
|
+
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
|
|
626
|
+
? of(home)
|
|
627
|
+
: forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
|
|
628
|
+
discoverProducts,
|
|
629
|
+
featuredProducts,
|
|
630
|
+
verticalProducts,
|
|
631
|
+
})), concatMap((data) => this.saveHomeData(data)))));
|
|
632
|
+
}
|
|
633
|
+
getBanners(type) {
|
|
634
|
+
return this.getHomeConfiguration().pipe(map((home) => {
|
|
635
|
+
if (type === 'brand')
|
|
636
|
+
return home.brandsCarousel;
|
|
637
|
+
if (type === 'buyToWin')
|
|
638
|
+
return [home.buyToWinBanner];
|
|
639
|
+
if (type === 'block')
|
|
640
|
+
return home.blockBanners;
|
|
641
|
+
if (type === 'blog')
|
|
642
|
+
return [home.blogBanner];
|
|
643
|
+
return [];
|
|
644
|
+
}));
|
|
645
|
+
}
|
|
646
|
+
getMinValueForFreeShipping() {
|
|
647
|
+
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
648
|
+
}
|
|
649
|
+
getDiscoverProducts() {
|
|
650
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
651
|
+
}
|
|
652
|
+
getFeaturedProducts() {
|
|
653
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
654
|
+
}
|
|
655
|
+
getVerticalProducts() {
|
|
656
|
+
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({
|
|
657
|
+
filters: { categories: { operator: Where.IN, value: [category.id] } },
|
|
658
|
+
limits: { limit: 12 },
|
|
659
|
+
})).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
|
|
660
|
+
}
|
|
661
|
+
getHomeConfiguration() {
|
|
662
|
+
return of(this.homeConfiguration).pipe(concatMap((home) => home
|
|
663
|
+
? of(home)
|
|
664
|
+
: !this.homeId
|
|
665
|
+
? throwError(new RequiredArgumentError(['homeId']))
|
|
666
|
+
: from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
|
|
667
|
+
}
|
|
668
|
+
saveHomeData(homeData) {
|
|
669
|
+
const data = {
|
|
670
|
+
createdAt: new Date(),
|
|
671
|
+
expiresAt: add(new Date(), { hours: 1 }),
|
|
672
|
+
data: homeData,
|
|
673
|
+
};
|
|
674
|
+
return from(this.homeRepository.update({
|
|
675
|
+
id: this.homeId,
|
|
676
|
+
data,
|
|
677
|
+
})).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
681
|
+
HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
|
|
682
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
|
|
683
|
+
type: Injectable
|
|
684
|
+
}], ctorParameters: function () {
|
|
685
|
+
return [{ type: undefined, decorators: [{
|
|
686
|
+
type: Inject,
|
|
687
|
+
args: ['CategoryRepository']
|
|
688
|
+
}] }, { type: undefined, decorators: [{
|
|
689
|
+
type: Inject,
|
|
690
|
+
args: ['HomeRepository']
|
|
691
|
+
}] }, { type: undefined, decorators: [{
|
|
692
|
+
type: Inject,
|
|
693
|
+
args: ['ProductRepository']
|
|
694
|
+
}] }, { type: i2.Shops, decorators: [{
|
|
695
|
+
type: Inject,
|
|
696
|
+
args: [DEFAULT_SHOP]
|
|
697
|
+
}] }];
|
|
698
|
+
} });
|
|
699
|
+
|
|
700
|
+
class AngularFirebaseAuthModule {
|
|
701
|
+
static initializeApp(options, nameOrConfig) {
|
|
702
|
+
return {
|
|
703
|
+
ngModule: AngularFirebaseAuthModule,
|
|
704
|
+
providers: [
|
|
705
|
+
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
706
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
707
|
+
],
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
712
|
+
AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1$2.FirebaseAppModule, i1.AuthModule] });
|
|
713
|
+
AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
|
|
714
|
+
{
|
|
715
|
+
provide: 'Authentication',
|
|
716
|
+
useFactory: (authenticationService, userRepository) => {
|
|
717
|
+
return new Authentication(authenticationService, userRepository);
|
|
718
|
+
},
|
|
719
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
provide: 'AuthenticationService',
|
|
723
|
+
useFactory: (angularFireAuth) => {
|
|
724
|
+
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
725
|
+
},
|
|
726
|
+
deps: [Auth],
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
provide: 'Register',
|
|
730
|
+
useFactory: (registerService, userRepository) => {
|
|
731
|
+
return new Register(registerService, userRepository);
|
|
732
|
+
},
|
|
733
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
provide: 'RegisterService',
|
|
737
|
+
useFactory: (angularFireAuth) => {
|
|
738
|
+
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
739
|
+
},
|
|
740
|
+
deps: [Auth],
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
provide: 'SignOut',
|
|
744
|
+
useFactory: (authenticationService) => {
|
|
745
|
+
return new SignOut(authenticationService);
|
|
746
|
+
},
|
|
747
|
+
deps: ['AuthenticationService'],
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
provide: 'RecoveryPassword',
|
|
751
|
+
useFactory: (authenticationService) => {
|
|
752
|
+
return new RecoveryPassword(authenticationService);
|
|
753
|
+
},
|
|
754
|
+
deps: ['AuthenticationService'],
|
|
755
|
+
},
|
|
756
|
+
], imports: [provideFirebaseApp((injector) => {
|
|
757
|
+
const appName = injector.get(FIREBASE_APP_NAME);
|
|
758
|
+
return appName
|
|
759
|
+
? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
|
|
760
|
+
: initializeApp(injector.get(FIREBASE_OPTIONS));
|
|
761
|
+
}),
|
|
762
|
+
provideAuth(() => getAuth())] });
|
|
763
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
|
|
764
|
+
type: NgModule,
|
|
765
|
+
args: [{
|
|
766
|
+
imports: [
|
|
767
|
+
provideFirebaseApp((injector) => {
|
|
768
|
+
const appName = injector.get(FIREBASE_APP_NAME);
|
|
769
|
+
return appName
|
|
770
|
+
? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
|
|
771
|
+
: initializeApp(injector.get(FIREBASE_OPTIONS));
|
|
772
|
+
}),
|
|
773
|
+
provideAuth(() => getAuth()),
|
|
774
|
+
],
|
|
775
|
+
providers: [
|
|
776
|
+
{
|
|
777
|
+
provide: 'Authentication',
|
|
778
|
+
useFactory: (authenticationService, userRepository) => {
|
|
779
|
+
return new Authentication(authenticationService, userRepository);
|
|
780
|
+
},
|
|
781
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
provide: 'AuthenticationService',
|
|
785
|
+
useFactory: (angularFireAuth) => {
|
|
786
|
+
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
787
|
+
},
|
|
788
|
+
deps: [Auth],
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
provide: 'Register',
|
|
792
|
+
useFactory: (registerService, userRepository) => {
|
|
793
|
+
return new Register(registerService, userRepository);
|
|
794
|
+
},
|
|
795
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
provide: 'RegisterService',
|
|
799
|
+
useFactory: (angularFireAuth) => {
|
|
800
|
+
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
801
|
+
},
|
|
802
|
+
deps: [Auth],
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
provide: 'SignOut',
|
|
806
|
+
useFactory: (authenticationService) => {
|
|
807
|
+
return new SignOut(authenticationService);
|
|
808
|
+
},
|
|
809
|
+
deps: ['AuthenticationService'],
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
provide: 'RecoveryPassword',
|
|
813
|
+
useFactory: (authenticationService) => {
|
|
814
|
+
return new RecoveryPassword(authenticationService);
|
|
815
|
+
},
|
|
816
|
+
deps: ['AuthenticationService'],
|
|
817
|
+
},
|
|
818
|
+
],
|
|
819
|
+
}]
|
|
820
|
+
}] });
|
|
821
|
+
|
|
822
|
+
class AngularElasticSeachModule {
|
|
823
|
+
static initializeApp(options) {
|
|
824
|
+
return {
|
|
825
|
+
ngModule: AngularElasticSeachModule,
|
|
826
|
+
providers: [{ provide: ES_CONFIG, useValue: options }],
|
|
1961
827
|
};
|
|
1962
|
-
return from(this.homeRepository.update({
|
|
1963
|
-
id: this.homeId,
|
|
1964
|
-
data,
|
|
1965
|
-
})).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
|
|
1966
828
|
}
|
|
1967
829
|
}
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
i0.ɵɵ
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
830
|
+
AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
831
|
+
AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule });
|
|
832
|
+
AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, providers: [
|
|
833
|
+
{
|
|
834
|
+
provide: ProductsIndex,
|
|
835
|
+
useFactory: (configuration) => {
|
|
836
|
+
return new ProductsIndex(new AxiosAdapter(configuration));
|
|
837
|
+
},
|
|
838
|
+
deps: [ES_CONFIG],
|
|
839
|
+
},
|
|
840
|
+
] });
|
|
841
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
|
|
842
|
+
type: NgModule,
|
|
843
|
+
args: [{
|
|
844
|
+
providers: [
|
|
845
|
+
{
|
|
846
|
+
provide: ProductsIndex,
|
|
847
|
+
useFactory: (configuration) => {
|
|
848
|
+
return new ProductsIndex(new AxiosAdapter(configuration));
|
|
849
|
+
},
|
|
850
|
+
deps: [ES_CONFIG],
|
|
851
|
+
},
|
|
852
|
+
],
|
|
853
|
+
}]
|
|
854
|
+
}] });
|
|
1987
855
|
|
|
1988
|
-
class
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
return this.orderSubject;
|
|
856
|
+
class AngularFirestoreModule {
|
|
857
|
+
static initializeApp(options, nameOrConfig) {
|
|
858
|
+
return {
|
|
859
|
+
ngModule: AngularFirestoreModule,
|
|
860
|
+
providers: [
|
|
861
|
+
{ provide: FIREBASE_OPTIONS, useValue: options.firebase },
|
|
862
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
863
|
+
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
864
|
+
],
|
|
865
|
+
};
|
|
1999
866
|
}
|
|
2000
867
|
}
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
i0.ɵɵ
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
868
|
+
AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
869
|
+
AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$2.FirebaseAppModule, i1$1.FirestoreModule] });
|
|
870
|
+
AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, providers: [
|
|
871
|
+
{
|
|
872
|
+
provide: 'BeautyProfileRepository',
|
|
873
|
+
useFactory: (firestore, userRepository) => {
|
|
874
|
+
return new UserBeautyProfileFirestoreRepository(firestore, userRepository);
|
|
875
|
+
},
|
|
876
|
+
deps: [Firestore, 'UserRepository'],
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
provide: 'Buy2WinRepository',
|
|
880
|
+
useFactory: (firestore) => {
|
|
881
|
+
return new Buy2WinFirestoreRepository(firestore);
|
|
882
|
+
},
|
|
883
|
+
deps: [Firestore],
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
provide: CategoryFirestoreRepository,
|
|
887
|
+
useFactory: (firestore) => {
|
|
888
|
+
return new CategoryFirestoreRepository(firestore);
|
|
889
|
+
},
|
|
890
|
+
deps: [Firestore],
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
provide: 'CheckoutRepository',
|
|
894
|
+
useFactory: (firestore) => {
|
|
895
|
+
return new CheckoutFirestoreRepository(firestore);
|
|
896
|
+
},
|
|
897
|
+
deps: [Firestore],
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
901
|
+
useFactory: (firestore) => {
|
|
902
|
+
return new CheckoutSubscriptionFirestoreRepository(firestore);
|
|
903
|
+
},
|
|
904
|
+
deps: [Firestore],
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
provide: 'CouponRepository',
|
|
908
|
+
useFactory: (firestore) => {
|
|
909
|
+
return new CouponFirestoreRepository(firestore);
|
|
910
|
+
},
|
|
911
|
+
deps: [Firestore],
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
provide: 'EditionRepository',
|
|
915
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
916
|
+
return new SubscriptionEditionFirestoreRepository(firestore, subscriptionRepository);
|
|
917
|
+
},
|
|
918
|
+
deps: [Firestore, 'SubscriptionRepository'],
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
provide: 'HomeRepository',
|
|
922
|
+
useFactory: (firestore) => {
|
|
923
|
+
return new HomeFirestoreRepository(firestore);
|
|
924
|
+
},
|
|
925
|
+
deps: [Firestore],
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
provide: 'LeadRepository',
|
|
929
|
+
useFactory: (firestore) => {
|
|
930
|
+
return new LeadFirestoreRepository(firestore);
|
|
931
|
+
},
|
|
932
|
+
deps: [Firestore],
|
|
933
|
+
},
|
|
934
|
+
{
|
|
935
|
+
provide: 'LegacyOrderRepository',
|
|
936
|
+
useFactory: (firestore) => {
|
|
937
|
+
return new LegacyOrderFirestoreRepository(firestore);
|
|
938
|
+
},
|
|
939
|
+
deps: [Firestore],
|
|
940
|
+
},
|
|
941
|
+
{
|
|
942
|
+
provide: 'ShopMenuRepository',
|
|
943
|
+
useFactory: (firestore) => {
|
|
944
|
+
return new ShopMenuFirestoreRepository(firestore);
|
|
945
|
+
},
|
|
946
|
+
deps: [Firestore],
|
|
947
|
+
},
|
|
948
|
+
{
|
|
949
|
+
provide: 'OrderRepository',
|
|
950
|
+
useFactory: (firestore) => {
|
|
951
|
+
return new OrderFirestoreRepository(firestore);
|
|
952
|
+
},
|
|
953
|
+
deps: [Firestore],
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
provide: 'PaymentRepository',
|
|
957
|
+
useFactory: (firestore) => {
|
|
958
|
+
return new PaymentFirestoreRepository(firestore);
|
|
959
|
+
},
|
|
960
|
+
deps: [Firestore],
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
provide: ProductFirestoreRepository,
|
|
964
|
+
useFactory: (firestore) => {
|
|
965
|
+
return new ProductFirestoreRepository(firestore);
|
|
966
|
+
},
|
|
967
|
+
deps: [Firestore],
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
provide: 'SubscriptionPaymentRepository',
|
|
971
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
972
|
+
return new SubscriptionPaymentFirestoreRepository(firestore, subscriptionRepository);
|
|
973
|
+
},
|
|
974
|
+
deps: [Firestore, 'SubscriptionRepository'],
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
provide: 'SubscriptionPlanRepository',
|
|
978
|
+
useFactory: (firestore) => {
|
|
979
|
+
return new SubscriptionPlanFirestoreRepository(firestore);
|
|
980
|
+
},
|
|
981
|
+
deps: [Firestore],
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
provide: 'SubscriptionProductRepository',
|
|
985
|
+
useFactory: (firestore) => {
|
|
986
|
+
return new SubscriptionProductFirestoreRepository(firestore);
|
|
987
|
+
},
|
|
988
|
+
deps: [Firestore],
|
|
989
|
+
},
|
|
990
|
+
{
|
|
991
|
+
provide: 'SubscriptionRepository',
|
|
992
|
+
useFactory: (firestore) => {
|
|
993
|
+
return new SubscriptionFirestoreRepository(firestore);
|
|
994
|
+
},
|
|
995
|
+
deps: [Firestore],
|
|
996
|
+
},
|
|
997
|
+
{
|
|
998
|
+
provide: 'UserRepository',
|
|
999
|
+
useFactory: (firestore) => {
|
|
1000
|
+
return new UserFirestoreRepository(firestore);
|
|
1001
|
+
},
|
|
1002
|
+
deps: [Firestore],
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
provide: 'UserAddressRepository',
|
|
1006
|
+
useFactory: (firestore, userRepository) => {
|
|
1007
|
+
return new UserAddressFirestoreRepository(firestore, userRepository);
|
|
1008
|
+
},
|
|
1009
|
+
deps: [Firestore, 'UserRepository'],
|
|
1010
|
+
},
|
|
1011
|
+
{
|
|
1012
|
+
provide: 'UserPaymentMethodRepository',
|
|
1013
|
+
useFactory: (firestore, userRepository) => {
|
|
1014
|
+
return new UserPaymentMethodFirestoreRepository(firestore, userRepository);
|
|
1015
|
+
},
|
|
1016
|
+
deps: [Firestore, 'UserRepository'],
|
|
1017
|
+
},
|
|
1018
|
+
{
|
|
1019
|
+
provide: ProductVariantFirestoreRepository,
|
|
1020
|
+
useFactory: (firestore, productRepository) => {
|
|
1021
|
+
return new ProductVariantFirestoreRepository(firestore, productRepository);
|
|
1022
|
+
},
|
|
1023
|
+
deps: [Firestore, ProductFirestoreRepository],
|
|
1024
|
+
},
|
|
1025
|
+
], imports: [AngularElasticSeachModule,
|
|
1026
|
+
provideFirebaseApp((injector) => {
|
|
1027
|
+
const appName = injector.get(FIREBASE_APP_NAME);
|
|
1028
|
+
return appName
|
|
1029
|
+
? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
|
|
1030
|
+
: initializeApp(injector.get(FIREBASE_OPTIONS));
|
|
1031
|
+
}),
|
|
1032
|
+
provideFirestore(() => getFirestore())] });
|
|
1033
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
1034
|
+
type: NgModule,
|
|
1035
|
+
args: [{
|
|
1036
|
+
imports: [
|
|
1037
|
+
AngularElasticSeachModule,
|
|
1038
|
+
provideFirebaseApp((injector) => {
|
|
1039
|
+
const appName = injector.get(FIREBASE_APP_NAME);
|
|
1040
|
+
return appName
|
|
1041
|
+
? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
|
|
1042
|
+
: initializeApp(injector.get(FIREBASE_OPTIONS));
|
|
1043
|
+
}),
|
|
1044
|
+
provideFirestore(() => getFirestore()),
|
|
1045
|
+
],
|
|
1046
|
+
providers: [
|
|
1047
|
+
{
|
|
1048
|
+
provide: 'BeautyProfileRepository',
|
|
1049
|
+
useFactory: (firestore, userRepository) => {
|
|
1050
|
+
return new UserBeautyProfileFirestoreRepository(firestore, userRepository);
|
|
1051
|
+
},
|
|
1052
|
+
deps: [Firestore, 'UserRepository'],
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
provide: 'Buy2WinRepository',
|
|
1056
|
+
useFactory: (firestore) => {
|
|
1057
|
+
return new Buy2WinFirestoreRepository(firestore);
|
|
1058
|
+
},
|
|
1059
|
+
deps: [Firestore],
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
provide: CategoryFirestoreRepository,
|
|
1063
|
+
useFactory: (firestore) => {
|
|
1064
|
+
return new CategoryFirestoreRepository(firestore);
|
|
1065
|
+
},
|
|
1066
|
+
deps: [Firestore],
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
provide: 'CheckoutRepository',
|
|
1070
|
+
useFactory: (firestore) => {
|
|
1071
|
+
return new CheckoutFirestoreRepository(firestore);
|
|
1072
|
+
},
|
|
1073
|
+
deps: [Firestore],
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
1077
|
+
useFactory: (firestore) => {
|
|
1078
|
+
return new CheckoutSubscriptionFirestoreRepository(firestore);
|
|
1079
|
+
},
|
|
1080
|
+
deps: [Firestore],
|
|
1081
|
+
},
|
|
1082
|
+
{
|
|
1083
|
+
provide: 'CouponRepository',
|
|
1084
|
+
useFactory: (firestore) => {
|
|
1085
|
+
return new CouponFirestoreRepository(firestore);
|
|
1086
|
+
},
|
|
1087
|
+
deps: [Firestore],
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
provide: 'EditionRepository',
|
|
1091
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
1092
|
+
return new SubscriptionEditionFirestoreRepository(firestore, subscriptionRepository);
|
|
1093
|
+
},
|
|
1094
|
+
deps: [Firestore, 'SubscriptionRepository'],
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
provide: 'HomeRepository',
|
|
1098
|
+
useFactory: (firestore) => {
|
|
1099
|
+
return new HomeFirestoreRepository(firestore);
|
|
1100
|
+
},
|
|
1101
|
+
deps: [Firestore],
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
provide: 'LeadRepository',
|
|
1105
|
+
useFactory: (firestore) => {
|
|
1106
|
+
return new LeadFirestoreRepository(firestore);
|
|
1107
|
+
},
|
|
1108
|
+
deps: [Firestore],
|
|
1109
|
+
},
|
|
1110
|
+
{
|
|
1111
|
+
provide: 'LegacyOrderRepository',
|
|
1112
|
+
useFactory: (firestore) => {
|
|
1113
|
+
return new LegacyOrderFirestoreRepository(firestore);
|
|
1114
|
+
},
|
|
1115
|
+
deps: [Firestore],
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
provide: 'ShopMenuRepository',
|
|
1119
|
+
useFactory: (firestore) => {
|
|
1120
|
+
return new ShopMenuFirestoreRepository(firestore);
|
|
1121
|
+
},
|
|
1122
|
+
deps: [Firestore],
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
provide: 'OrderRepository',
|
|
1126
|
+
useFactory: (firestore) => {
|
|
1127
|
+
return new OrderFirestoreRepository(firestore);
|
|
1128
|
+
},
|
|
1129
|
+
deps: [Firestore],
|
|
1130
|
+
},
|
|
1131
|
+
{
|
|
1132
|
+
provide: 'PaymentRepository',
|
|
1133
|
+
useFactory: (firestore) => {
|
|
1134
|
+
return new PaymentFirestoreRepository(firestore);
|
|
1135
|
+
},
|
|
1136
|
+
deps: [Firestore],
|
|
1137
|
+
},
|
|
1138
|
+
{
|
|
1139
|
+
provide: ProductFirestoreRepository,
|
|
1140
|
+
useFactory: (firestore) => {
|
|
1141
|
+
return new ProductFirestoreRepository(firestore);
|
|
1142
|
+
},
|
|
1143
|
+
deps: [Firestore],
|
|
1144
|
+
},
|
|
1145
|
+
{
|
|
1146
|
+
provide: 'SubscriptionPaymentRepository',
|
|
1147
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
1148
|
+
return new SubscriptionPaymentFirestoreRepository(firestore, subscriptionRepository);
|
|
1149
|
+
},
|
|
1150
|
+
deps: [Firestore, 'SubscriptionRepository'],
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
provide: 'SubscriptionPlanRepository',
|
|
1154
|
+
useFactory: (firestore) => {
|
|
1155
|
+
return new SubscriptionPlanFirestoreRepository(firestore);
|
|
1156
|
+
},
|
|
1157
|
+
deps: [Firestore],
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
provide: 'SubscriptionProductRepository',
|
|
1161
|
+
useFactory: (firestore) => {
|
|
1162
|
+
return new SubscriptionProductFirestoreRepository(firestore);
|
|
1163
|
+
},
|
|
1164
|
+
deps: [Firestore],
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
provide: 'SubscriptionRepository',
|
|
1168
|
+
useFactory: (firestore) => {
|
|
1169
|
+
return new SubscriptionFirestoreRepository(firestore);
|
|
1170
|
+
},
|
|
1171
|
+
deps: [Firestore],
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
provide: 'UserRepository',
|
|
1175
|
+
useFactory: (firestore) => {
|
|
1176
|
+
return new UserFirestoreRepository(firestore);
|
|
1177
|
+
},
|
|
1178
|
+
deps: [Firestore],
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
provide: 'UserAddressRepository',
|
|
1182
|
+
useFactory: (firestore, userRepository) => {
|
|
1183
|
+
return new UserAddressFirestoreRepository(firestore, userRepository);
|
|
1184
|
+
},
|
|
1185
|
+
deps: [Firestore, 'UserRepository'],
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
provide: 'UserPaymentMethodRepository',
|
|
1189
|
+
useFactory: (firestore, userRepository) => {
|
|
1190
|
+
return new UserPaymentMethodFirestoreRepository(firestore, userRepository);
|
|
1191
|
+
},
|
|
1192
|
+
deps: [Firestore, 'UserRepository'],
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
provide: ProductVariantFirestoreRepository,
|
|
1196
|
+
useFactory: (firestore, productRepository) => {
|
|
1197
|
+
return new ProductVariantFirestoreRepository(firestore, productRepository);
|
|
1198
|
+
},
|
|
1199
|
+
deps: [Firestore, ProductFirestoreRepository],
|
|
1200
|
+
},
|
|
1201
|
+
],
|
|
1202
|
+
}]
|
|
1203
|
+
}] });
|
|
2011
1204
|
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
return combineLatest([
|
|
2020
|
-
this.homeService.getHomeData(),
|
|
2021
|
-
this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
|
|
2022
|
-
]).pipe(map(([datas, shippingMethodsResponse]) => {
|
|
2023
|
-
let shippingMethods = shippingMethodsResponse.result;
|
|
2024
|
-
if (!shippingMethods.length)
|
|
2025
|
-
return [];
|
|
2026
|
-
shippingMethods = shippingMethods.map((shippingMethod) => {
|
|
2027
|
-
if (shippingMethod.ShippingCompanyName == 'Same Day EG')
|
|
2028
|
-
shippingMethod.ShippingCompanyName = 'Same Day';
|
|
2029
|
-
return shippingMethod;
|
|
2030
|
-
});
|
|
2031
|
-
const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
|
|
2032
|
-
if (this.isHolidays(datasSameDayNotAvaliable)) {
|
|
2033
|
-
shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
|
|
2034
|
-
}
|
|
2035
|
-
if (totalPrice >= 200) {
|
|
2036
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2037
|
-
if (s.serviceName !== 'Same Day')
|
|
2038
|
-
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
2039
|
-
else
|
|
2040
|
-
return s;
|
|
2041
|
-
});
|
|
2042
|
-
}
|
|
2043
|
-
if (shop == Shops.GLAMSHOP)
|
|
2044
|
-
return shippingMethods;
|
|
2045
|
-
if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
|
|
2046
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2047
|
-
if (s.serviceName == 'Same Day')
|
|
2048
|
-
return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
|
|
2049
|
-
else
|
|
2050
|
-
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
2051
|
-
});
|
|
2052
|
-
}
|
|
2053
|
-
if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
|
|
2054
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2055
|
-
return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
|
|
2056
|
-
});
|
|
2057
|
-
}
|
|
2058
|
-
return shippingMethods;
|
|
2059
|
-
}));
|
|
2060
|
-
}
|
|
2061
|
-
isFreeShippingBySubscription(shop, subscriptionPlan) {
|
|
2062
|
-
if (!subscriptionPlan)
|
|
2063
|
-
return false;
|
|
2064
|
-
if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
|
|
2065
|
-
return true;
|
|
2066
|
-
return false;
|
|
2067
|
-
}
|
|
2068
|
-
isHalfShippingBySubscription(shop, subscriptionPlan) {
|
|
2069
|
-
if (!subscriptionPlan)
|
|
2070
|
-
return false;
|
|
2071
|
-
if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
|
|
2072
|
-
return true;
|
|
2073
|
-
}
|
|
2074
|
-
return false;
|
|
2075
|
-
}
|
|
2076
|
-
isHolidays(datas) {
|
|
2077
|
-
const today = new Date();
|
|
2078
|
-
for (const key in datas) {
|
|
2079
|
-
let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
|
|
2080
|
-
let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
|
|
2081
|
-
if (start > end)
|
|
2082
|
-
end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
|
|
2083
|
-
if (today >= start && today <= end)
|
|
2084
|
-
return true;
|
|
2085
|
-
}
|
|
2086
|
-
return false;
|
|
1205
|
+
const processes = {};
|
|
1206
|
+
class AngularHasuraGraphQLModule {
|
|
1207
|
+
static initializeApp(options) {
|
|
1208
|
+
return {
|
|
1209
|
+
ngModule: AngularHasuraGraphQLModule,
|
|
1210
|
+
providers: [{ provide: HASURA_OPTIONS, useValue: options }],
|
|
1211
|
+
};
|
|
2087
1212
|
}
|
|
2088
1213
|
}
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
i0.ɵɵ
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
1214
|
+
AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1215
|
+
AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule });
|
|
1216
|
+
AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
|
|
1217
|
+
{
|
|
1218
|
+
provide: 'HasuraConfig',
|
|
1219
|
+
useFactory: (options, platformId) => ({
|
|
1220
|
+
endpoint: options.endpoint,
|
|
1221
|
+
authOptions: options.credentials,
|
|
1222
|
+
interceptors: {
|
|
1223
|
+
request: (request) => {
|
|
1224
|
+
if (isPlatformBrowser(platformId))
|
|
1225
|
+
return request;
|
|
1226
|
+
const index = Date.now();
|
|
1227
|
+
processes[index] = true;
|
|
1228
|
+
request.proccess = index;
|
|
1229
|
+
console.log('request', request.proccess);
|
|
1230
|
+
return request;
|
|
1231
|
+
},
|
|
1232
|
+
response: (response) => {
|
|
1233
|
+
if (isPlatformBrowser(platformId))
|
|
1234
|
+
return response;
|
|
1235
|
+
console.log('response', response.proccess);
|
|
1236
|
+
delete processes[response.proccess];
|
|
1237
|
+
},
|
|
1238
|
+
},
|
|
1239
|
+
}),
|
|
1240
|
+
deps: [HASURA_OPTIONS, PLATFORM_ID],
|
|
1241
|
+
},
|
|
1242
|
+
{
|
|
1243
|
+
provide: 'CategoryRepository',
|
|
1244
|
+
useExisting: CategoryHasuraGraphQLRepository,
|
|
1245
|
+
},
|
|
1246
|
+
{
|
|
1247
|
+
provide: CategoryHasuraGraphQLRepository,
|
|
1248
|
+
useFactory: (hasuraConfig, productRepository) => {
|
|
1249
|
+
return new CategoryHasuraGraphQLRepository(hasuraConfig, productRepository);
|
|
1250
|
+
},
|
|
1251
|
+
deps: ['HasuraConfig', ProductHasuraGraphQLRepository],
|
|
1252
|
+
},
|
|
1253
|
+
{
|
|
1254
|
+
provide: 'ProductRepository',
|
|
1255
|
+
useExisting: ProductHasuraGraphQLRepository,
|
|
1256
|
+
},
|
|
1257
|
+
{
|
|
1258
|
+
provide: ProductHasuraGraphQLRepository,
|
|
1259
|
+
useFactory: (hasuraConfig) => {
|
|
1260
|
+
return new ProductHasuraGraphQLRepository(hasuraConfig);
|
|
1261
|
+
},
|
|
1262
|
+
deps: ['HasuraConfig'],
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
provide: 'VariantRepository',
|
|
1266
|
+
useExisting: VariantHasuraGraphQLRepository,
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
provide: VariantHasuraGraphQLRepository,
|
|
1270
|
+
useFactory: (hasuraConfig) => {
|
|
1271
|
+
return new VariantHasuraGraphQLRepository(hasuraConfig);
|
|
1272
|
+
},
|
|
1273
|
+
deps: ['HasuraConfig'],
|
|
1274
|
+
},
|
|
1275
|
+
] });
|
|
1276
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
|
|
1277
|
+
type: NgModule,
|
|
1278
|
+
args: [{
|
|
1279
|
+
providers: [
|
|
1280
|
+
{
|
|
1281
|
+
provide: 'HasuraConfig',
|
|
1282
|
+
useFactory: (options, platformId) => ({
|
|
1283
|
+
endpoint: options.endpoint,
|
|
1284
|
+
authOptions: options.credentials,
|
|
1285
|
+
interceptors: {
|
|
1286
|
+
request: (request) => {
|
|
1287
|
+
if (isPlatformBrowser(platformId))
|
|
1288
|
+
return request;
|
|
1289
|
+
const index = Date.now();
|
|
1290
|
+
processes[index] = true;
|
|
1291
|
+
request.proccess = index;
|
|
1292
|
+
console.log('request', request.proccess);
|
|
1293
|
+
return request;
|
|
1294
|
+
},
|
|
1295
|
+
response: (response) => {
|
|
1296
|
+
if (isPlatformBrowser(platformId))
|
|
1297
|
+
return response;
|
|
1298
|
+
console.log('response', response.proccess);
|
|
1299
|
+
delete processes[response.proccess];
|
|
1300
|
+
},
|
|
1301
|
+
},
|
|
1302
|
+
}),
|
|
1303
|
+
deps: [HASURA_OPTIONS, PLATFORM_ID],
|
|
1304
|
+
},
|
|
1305
|
+
{
|
|
1306
|
+
provide: 'CategoryRepository',
|
|
1307
|
+
useExisting: CategoryHasuraGraphQLRepository,
|
|
1308
|
+
},
|
|
1309
|
+
{
|
|
1310
|
+
provide: CategoryHasuraGraphQLRepository,
|
|
1311
|
+
useFactory: (hasuraConfig, productRepository) => {
|
|
1312
|
+
return new CategoryHasuraGraphQLRepository(hasuraConfig, productRepository);
|
|
1313
|
+
},
|
|
1314
|
+
deps: ['HasuraConfig', ProductHasuraGraphQLRepository],
|
|
1315
|
+
},
|
|
1316
|
+
{
|
|
1317
|
+
provide: 'ProductRepository',
|
|
1318
|
+
useExisting: ProductHasuraGraphQLRepository,
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
provide: ProductHasuraGraphQLRepository,
|
|
1322
|
+
useFactory: (hasuraConfig) => {
|
|
1323
|
+
return new ProductHasuraGraphQLRepository(hasuraConfig);
|
|
1324
|
+
},
|
|
1325
|
+
deps: ['HasuraConfig'],
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
provide: 'VariantRepository',
|
|
1329
|
+
useExisting: VariantHasuraGraphQLRepository,
|
|
1330
|
+
},
|
|
1331
|
+
{
|
|
1332
|
+
provide: VariantHasuraGraphQLRepository,
|
|
1333
|
+
useFactory: (hasuraConfig) => {
|
|
1334
|
+
return new VariantHasuraGraphQLRepository(hasuraConfig);
|
|
1335
|
+
},
|
|
1336
|
+
deps: ['HasuraConfig'],
|
|
1337
|
+
},
|
|
1338
|
+
],
|
|
1339
|
+
}]
|
|
1340
|
+
}] });
|
|
2099
1341
|
|
|
2100
1342
|
class AngularConnectModule {
|
|
2101
1343
|
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
2102
1344
|
return {
|
|
2103
1345
|
ngModule: AngularConnectModule,
|
|
2104
1346
|
providers: [
|
|
2105
|
-
{
|
|
2106
|
-
provide: CATEGORY_STRUCTURE,
|
|
2107
|
-
useClass: isNil(options === null || options === void 0 ? void 0 : options.oldCategoryStructure) || (options === null || options === void 0 ? void 0 : options.oldCategoryStructure)
|
|
2108
|
-
? OldCategoryStructureAdapter
|
|
2109
|
-
: NewCategoryStructureAdapter,
|
|
2110
|
-
},
|
|
2111
1347
|
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2112
1348
|
...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
|
|
2113
1349
|
...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
2114
1350
|
...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
|
|
2115
1351
|
...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
|
|
2116
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
|
|
2117
1352
|
],
|
|
2118
1353
|
};
|
|
2119
1354
|
}
|
|
@@ -2123,15 +1358,11 @@ AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", ve
|
|
|
2123
1358
|
AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, providers: [
|
|
2124
1359
|
AuthService,
|
|
2125
1360
|
CartService,
|
|
2126
|
-
CatalogService,
|
|
2127
|
-
CategoryService,
|
|
2128
1361
|
CheckoutService,
|
|
2129
1362
|
CheckoutSubscriptionService,
|
|
2130
1363
|
CouponService,
|
|
2131
1364
|
HomeShopService,
|
|
2132
1365
|
OrderService,
|
|
2133
|
-
ShippingService,
|
|
2134
|
-
WishlistService,
|
|
2135
1366
|
], imports: [AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
|
|
2136
1367
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
2137
1368
|
type: NgModule,
|
|
@@ -2140,15 +1371,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2140
1371
|
providers: [
|
|
2141
1372
|
AuthService,
|
|
2142
1373
|
CartService,
|
|
2143
|
-
CatalogService,
|
|
2144
|
-
CategoryService,
|
|
2145
1374
|
CheckoutService,
|
|
2146
1375
|
CheckoutSubscriptionService,
|
|
2147
1376
|
CouponService,
|
|
2148
1377
|
HomeShopService,
|
|
2149
1378
|
OrderService,
|
|
2150
|
-
ShippingService,
|
|
2151
|
-
WishlistService,
|
|
2152
1379
|
],
|
|
2153
1380
|
}]
|
|
2154
1381
|
}] });
|
|
@@ -2157,5 +1384,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2157
1384
|
* Generated bundle index. Do not edit.
|
|
2158
1385
|
*/
|
|
2159
1386
|
|
|
2160
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService,
|
|
1387
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService };
|
|
2161
1388
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|