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