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