@infrab4a/connect-angular 0.13.0-beta.9 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/infrab4a-connect-angular.umd.js +1390 -1269
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/esm2015/infrab4a-connect-angular.js +4 -4
- package/esm2015/lib/angular-connect.module.js +46 -47
- package/esm2015/lib/angular-firebase-auth.module.js +113 -103
- package/esm2015/lib/angular-firestore.module.js +337 -343
- package/esm2015/lib/consts/default-shop.const.js +2 -2
- package/esm2015/lib/consts/index.js +2 -2
- package/esm2015/lib/index.js +5 -7
- package/esm2015/lib/services/auth.service.js +42 -45
- package/esm2015/lib/services/cart.service.js +166 -162
- package/esm2015/lib/services/checkout-subscription.service.js +68 -37
- package/esm2015/lib/services/checkout.service.js +79 -79
- package/esm2015/lib/services/coupon.service.js +70 -51
- package/esm2015/lib/services/errors/group-invalid-coupon.error.js +7 -0
- package/esm2015/lib/services/errors/index.js +3 -2
- package/esm2015/lib/services/errors/invalid-coupon.error.js +7 -7
- package/esm2015/lib/services/home-shop.service.js +107 -0
- package/esm2015/lib/services/index.js +8 -7
- package/esm2015/lib/services/order.service.js +32 -30
- package/esm2015/lib/services/types/index.js +3 -3
- package/esm2015/lib/services/types/required-checkout-data.type.js +2 -2
- package/esm2015/lib/services/types/required-checkout-subscription-data.type.js +2 -2
- package/esm2015/public-api.js +2 -2
- package/fesm2015/infrab4a-connect-angular.js +986 -878
- package/fesm2015/infrab4a-connect-angular.js.map +1 -1
- package/infrab4a-connect-angular.d.ts +5 -5
- package/lib/angular-connect.module.d.ts +12 -12
- package/lib/angular-firebase-auth.module.d.ts +10 -10
- package/lib/angular-firestore.module.d.ts +10 -9
- package/lib/consts/default-shop.const.d.ts +1 -1
- package/lib/consts/index.d.ts +1 -1
- package/lib/index.d.ts +4 -6
- package/lib/services/auth.service.d.ts +19 -21
- package/lib/services/cart.service.d.ts +41 -41
- package/lib/services/checkout-subscription.service.d.ts +18 -13
- package/lib/services/checkout.service.d.ts +22 -22
- package/lib/services/coupon.service.d.ts +14 -13
- package/lib/services/errors/group-invalid-coupon.error.d.ts +5 -0
- package/lib/services/errors/index.d.ts +2 -1
- package/lib/services/errors/invalid-coupon.error.d.ts +4 -4
- package/lib/services/home-shop.service.d.ts +24 -0
- package/lib/services/index.d.ts +7 -6
- package/lib/services/order.service.d.ts +13 -13
- package/lib/services/types/index.d.ts +2 -2
- package/lib/services/types/required-checkout-data.type.d.ts +2 -2
- package/lib/services/types/required-checkout-subscription-data.type.d.ts +2 -2
- package/package.json +4 -3
- package/public-api.d.ts +1 -1
- package/esm2015/lib/factories/firebase-app.factory.js +0 -18
- package/esm2015/lib/factories/firebase-auth.factory.js +0 -2
- package/esm2015/lib/factories/firebase-firestore.factory.js +0 -2
- package/esm2015/lib/factories/index.js +0 -4
- package/esm2015/lib/providers/firebase-app.provider.js +0 -12
- package/esm2015/lib/providers/firebase-auth.provider.js +0 -15
- package/esm2015/lib/providers/firebase-firestore.provider.js +0 -14
- package/esm2015/lib/providers/index.js +0 -4
- package/lib/factories/firebase-app.factory.d.ts +0 -4
- package/lib/factories/firebase-auth.factory.d.ts +0 -2
- package/lib/factories/firebase-firestore.factory.d.ts +0 -2
- package/lib/factories/index.d.ts +0 -3
- package/lib/providers/firebase-app.provider.d.ts +0 -17
- package/lib/providers/firebase-auth.provider.d.ts +0 -11
- package/lib/providers/firebase-firestore.provider.d.ts +0 -10
- package/lib/providers/index.d.ts +0 -3
|
@@ -1,910 +1,1018 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { Injectable, Inject, NgModule } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/fire/auth';
|
|
4
|
+
import { AngularFireAuth } from '@angular/fire/auth';
|
|
5
|
+
import { of, combineLatest, from, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
4
6
|
import { catchError, map, mergeMap, concatMap, tap } from 'rxjs/operators';
|
|
5
|
-
import firebase$1 from 'firebase';
|
|
6
7
|
import * as i2 from '@infrab4a/connect';
|
|
7
|
-
import {
|
|
8
|
-
import firebase from 'firebase/app';
|
|
8
|
+
import { FinancialCoupon, Where, NotFoundError, Exclusivities, isNil, Checkout, CheckoutTypes, pick, LineItem, CouponTypes, CouponSubtypes, CheckoutSubscription, Order, Category, Product, Shops, RequiredArgumentError, add, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository } from '@infrab4a/connect';
|
|
9
9
|
import { __awaiter } from 'tslib';
|
|
10
10
|
import cookie from 'js-cookie';
|
|
11
|
+
import * as i1$1 from '@angular/fire/firestore';
|
|
12
|
+
import { AngularFirestore } from '@angular/fire/firestore';
|
|
13
|
+
import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, AngularFireModule } from '@angular/fire';
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
provide: ConnectAngularFirebaseAuth,
|
|
48
|
-
useFactory: FirebaseAuthFactory,
|
|
49
|
-
deps: [ConnectAngularFirebaseApp],
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const fromCallback = (cb, zone) => new Observable((subscriber) => ({ unsubscribe: zone.runOutsideAngular(() => cb(subscriber)) }));
|
|
53
|
-
class AuthService {
|
|
54
|
-
constructor(firebaseAuth, userRepository, zone) {
|
|
55
|
-
this.firebaseAuth = firebaseAuth;
|
|
56
|
-
this.userRepository = userRepository;
|
|
57
|
-
this.zone = zone;
|
|
58
|
-
}
|
|
59
|
-
getAuthstate() {
|
|
60
|
-
this.firebaseAuth.onAuthStateChanged((user) => user);
|
|
61
|
-
const observables = [
|
|
62
|
-
fromCallback(this.firebaseAuth.onAuthStateChanged, this.zone).pipe(catchError(() => of(null))),
|
|
63
|
-
this.getUser().pipe(catchError(() => of(null))),
|
|
64
|
-
];
|
|
65
|
-
return combineLatest(observables).pipe(map(([fireUser, user]) => {
|
|
66
|
-
return {
|
|
67
|
-
user,
|
|
68
|
-
isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
|
|
69
|
-
};
|
|
70
|
-
}));
|
|
71
|
-
}
|
|
72
|
-
getUser() {
|
|
73
|
-
return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? this.userRepository.get({ id }) : of(null))));
|
|
74
|
-
}
|
|
75
|
-
getTokenId() {
|
|
76
|
-
return from(this.firebaseAuth.currentUser.getIdToken());
|
|
77
|
-
}
|
|
78
|
-
getFireUser() {
|
|
79
|
-
return of(this.firebaseAuth.currentUser).pipe(catchError(() => of(null)));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, deps: [{ token: ConnectAngularFirebaseAuth }, { token: 'UserRepository' }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
83
|
-
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService });
|
|
84
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, decorators: [{
|
|
85
|
-
type: Injectable
|
|
86
|
-
}], ctorParameters: function () { return [{ type: ConnectAngularFirebaseAuth }, { type: undefined, decorators: [{
|
|
87
|
-
type: Inject,
|
|
88
|
-
args: ['UserRepository']
|
|
89
|
-
}] }, { type: i0.NgZone }]; } });
|
|
15
|
+
class AuthService {
|
|
16
|
+
constructor(angularFireAuth, userRepository) {
|
|
17
|
+
this.angularFireAuth = angularFireAuth;
|
|
18
|
+
this.userRepository = userRepository;
|
|
19
|
+
}
|
|
20
|
+
getAuthstate() {
|
|
21
|
+
const observables = [
|
|
22
|
+
this.angularFireAuth.authState.pipe(catchError(() => of(null))),
|
|
23
|
+
this.getUser().pipe(catchError(() => of(null))),
|
|
24
|
+
];
|
|
25
|
+
return combineLatest(observables).pipe(map(([fireUser, user]) => {
|
|
26
|
+
return {
|
|
27
|
+
user,
|
|
28
|
+
isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
|
|
29
|
+
};
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
getUser() {
|
|
33
|
+
return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? this.userRepository.get({ id }) : of(null))));
|
|
34
|
+
}
|
|
35
|
+
getTokenId() {
|
|
36
|
+
return this.angularFireAuth.idToken;
|
|
37
|
+
}
|
|
38
|
+
getFireUser() {
|
|
39
|
+
return this.angularFireAuth.user.pipe(catchError(() => of(null)));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
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 });
|
|
43
|
+
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService });
|
|
44
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, decorators: [{
|
|
45
|
+
type: Injectable
|
|
46
|
+
}], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
|
|
47
|
+
type: Inject,
|
|
48
|
+
args: ['UserRepository']
|
|
49
|
+
}] }]; } });
|
|
90
50
|
|
|
91
51
|
const DEFAULT_SHOP = 'DEFAULT_SHOP';
|
|
92
52
|
|
|
93
|
-
class InvalidCouponError extends Error {
|
|
94
|
-
constructor(message) {
|
|
95
|
-
super(message);
|
|
96
|
-
this.message = message;
|
|
97
|
-
}
|
|
53
|
+
class InvalidCouponError extends Error {
|
|
54
|
+
constructor(message) {
|
|
55
|
+
super(message);
|
|
56
|
+
this.message = message;
|
|
57
|
+
}
|
|
98
58
|
}
|
|
99
59
|
|
|
100
|
-
class
|
|
101
|
-
constructor(
|
|
102
|
-
|
|
103
|
-
this.
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
checkCoupon(nickname, userEmail) {
|
|
107
|
-
return from(this.couponRepository.find([
|
|
108
|
-
{
|
|
109
|
-
nickname: { operator: Where.EQUALS, value: nickname },
|
|
110
|
-
shopAvailability: { operator: Where.EQUALS, value: this.defaultShop },
|
|
111
|
-
},
|
|
112
|
-
])).pipe(concatMap((coupons) => coupons.count < 1 ? throwError(() => new NotFoundError('Coupon not found')) : of(coupons.data[0])), concatMap((coupon) => FinancialCoupon.isFinancialCoupon(coupon) && this.isValidCoupon(coupon, userEmail)
|
|
113
|
-
? of(coupon)
|
|
114
|
-
: throwError(() => new InvalidCouponError('Coupon is not valid'))));
|
|
115
|
-
}
|
|
116
|
-
isValidCoupon(coupon, userEmail) {
|
|
117
|
-
if (coupon.checkoutType !== CheckoutTypes.ECOMMERCE)
|
|
118
|
-
throw new InvalidCouponError('Coupon is not ecommerce valid');
|
|
119
|
-
if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
|
|
120
|
-
throw new InvalidCouponError('User is not a collaborator');
|
|
121
|
-
if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.recipient !== userEmail)
|
|
122
|
-
throw new InvalidCouponError('Coupon is not valid for user');
|
|
123
|
-
if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
|
|
124
|
-
throw new InvalidCouponError('Coupon is expired');
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
60
|
+
class GroupInvalidCouponError extends Error {
|
|
61
|
+
constructor(errors) {
|
|
62
|
+
super('Many coupon errors throw');
|
|
63
|
+
this.errors = errors;
|
|
64
|
+
}
|
|
127
65
|
}
|
|
128
|
-
CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
129
|
-
CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
|
|
130
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
|
|
131
|
-
type: Injectable,
|
|
132
|
-
args: [{
|
|
133
|
-
providedIn: 'root',
|
|
134
|
-
}]
|
|
135
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
136
|
-
type: Inject,
|
|
137
|
-
args: ['CouponRepository']
|
|
138
|
-
}] }, { type: i2.Shops, decorators: [{
|
|
139
|
-
type: Inject,
|
|
140
|
-
args: [DEFAULT_SHOP]
|
|
141
|
-
}] }]; } });
|
|
142
66
|
|
|
143
|
-
class
|
|
144
|
-
constructor(
|
|
145
|
-
this.
|
|
146
|
-
this.
|
|
147
|
-
this.
|
|
148
|
-
this.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}], ctorParameters: function () { return [{ type:
|
|
198
|
-
type: Inject,
|
|
199
|
-
args: ['
|
|
200
|
-
}] }, { type:
|
|
201
|
-
type: Inject,
|
|
202
|
-
args: [
|
|
203
|
-
}] }, { type: undefined, decorators: [{
|
|
204
|
-
type: Inject,
|
|
205
|
-
args: ['UserRepository']
|
|
206
|
-
}] }, { type: i2.Shops, decorators: [{
|
|
207
|
-
type: Inject,
|
|
208
|
-
args: [DEFAULT_SHOP]
|
|
67
|
+
class CouponService {
|
|
68
|
+
constructor(couponRepository, defaultShop) {
|
|
69
|
+
this.couponRepository = couponRepository;
|
|
70
|
+
this.defaultShop = defaultShop;
|
|
71
|
+
this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
|
|
72
|
+
this.separateValidCoupons = (coupons, userEmail) => coupons
|
|
73
|
+
.map((coupon) => {
|
|
74
|
+
try {
|
|
75
|
+
if (!FinancialCoupon.isFinancialCoupon(coupon))
|
|
76
|
+
throw new InvalidCouponError('Coupon is not valid');
|
|
77
|
+
if (this.isValidCoupon(coupon, userEmail))
|
|
78
|
+
return coupon;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return error;
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
.reduce((current, coupon) => (Object.assign(Object.assign({}, current), (FinancialCoupon.isFinancialCoupon(coupon)
|
|
85
|
+
? { valids: [...current.valids, coupon] }
|
|
86
|
+
: { invalids: [...current.invalids, coupon] }))), {
|
|
87
|
+
valids: [],
|
|
88
|
+
invalids: [],
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
checkCoupon(nickname, userEmail, checkoutType) {
|
|
92
|
+
return from(this.couponRepository.find([
|
|
93
|
+
{
|
|
94
|
+
nickname: { operator: Where.EQUALS, value: nickname },
|
|
95
|
+
shopAvailability: { operator: Where.EQUALS, value: this.defaultShop },
|
|
96
|
+
checkoutType: { operator: Where.EQUALS, value: checkoutType },
|
|
97
|
+
},
|
|
98
|
+
])).pipe(concatMap((coupons) => coupons.count < 1 ? throwError(() => new NotFoundError('Coupon not found')) : of(coupons.data)), map((coupons) => this.separateValidCoupons(coupons, userEmail)), map(({ valids, invalids }) => {
|
|
99
|
+
if (!valids.length)
|
|
100
|
+
throw new GroupInvalidCouponError(invalids);
|
|
101
|
+
return valids;
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
isValidCoupon(coupon, userEmail) {
|
|
105
|
+
if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
|
|
106
|
+
throw new InvalidCouponError('User is not a collaborator');
|
|
107
|
+
if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.recipient !== userEmail)
|
|
108
|
+
throw new InvalidCouponError('Coupon is not valid for user');
|
|
109
|
+
if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
|
|
110
|
+
throw new InvalidCouponError('Coupon is expired');
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
115
|
+
CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
|
|
116
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
|
|
117
|
+
type: Injectable,
|
|
118
|
+
args: [{
|
|
119
|
+
providedIn: 'root',
|
|
120
|
+
}]
|
|
121
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
122
|
+
type: Inject,
|
|
123
|
+
args: ['CouponRepository']
|
|
124
|
+
}] }, { type: i2.Shops, decorators: [{
|
|
125
|
+
type: Inject,
|
|
126
|
+
args: [DEFAULT_SHOP]
|
|
209
127
|
}] }]; } });
|
|
210
128
|
|
|
211
|
-
class
|
|
212
|
-
constructor(
|
|
213
|
-
this.
|
|
214
|
-
this.
|
|
215
|
-
this.
|
|
216
|
-
this.
|
|
217
|
-
this.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
this.
|
|
240
|
-
var _a
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const currentItemAmount = item.quantity || 0;
|
|
278
|
-
return currentItemAmount + quantity > maxStock;
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
addItem(item, quantity = 1) {
|
|
282
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => ({ checkout, lineItem: this.buildLineItem({ checkout, item, quantity: quantity || 1 }) })), concatMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
|
|
283
|
-
}
|
|
284
|
-
decreaseItem(item) {
|
|
285
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
286
|
-
var _a;
|
|
287
|
-
const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
|
|
288
|
-
if (!isNil(checkoutItem))
|
|
289
|
-
checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
|
|
290
|
-
return checkout;
|
|
291
|
-
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
292
|
-
}
|
|
293
|
-
getCart(checkout) {
|
|
294
|
-
this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
|
|
295
|
-
return this.cartSubject;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* @deprecated The method should not be used
|
|
299
|
-
*/
|
|
300
|
-
getDiscount(coupon) {
|
|
301
|
-
switch (coupon.type) {
|
|
302
|
-
case CouponTypes.FINANCIAL:
|
|
303
|
-
return this.getFinancialDiscount(coupon);
|
|
304
|
-
case CouponTypes.PRODUCT:
|
|
305
|
-
return (subTotalPrice) => subTotalPrice;
|
|
306
|
-
case CouponTypes.GIFTCARD:
|
|
307
|
-
return this.getFinancialDiscount(coupon);
|
|
308
|
-
case CouponTypes.VOUCHER:
|
|
309
|
-
return (subTotalPrice) => subTotalPrice;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* @deprecated The method should not be used
|
|
314
|
-
*/
|
|
315
|
-
getVariantPriceDiscount(item, shop) {
|
|
316
|
-
return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.getInfoByShop(shop).subscriberPrice, of(item.getInfoByShop(shop).subscriberPrice), of(item.getInfoByShop(shop).price))), catchError(() => of(item.getInfoByShop(shop).price)));
|
|
317
|
-
}
|
|
318
|
-
removeItem(item) {
|
|
319
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
320
|
-
const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
|
|
321
|
-
if (index >= 0)
|
|
322
|
-
checkout.lineItems.splice(index, 1);
|
|
323
|
-
return checkout;
|
|
324
|
-
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
325
|
-
}
|
|
326
|
-
updateUserCart(user) {
|
|
327
|
-
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => {
|
|
328
|
-
var _a;
|
|
329
|
-
return this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.map((item) => this.buildLineItem({ checkout, item }))) || [] })));
|
|
330
|
-
}), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
331
|
-
}
|
|
332
|
-
clearCart() {
|
|
333
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
334
|
-
this.checkoutService.clearCheckoutFromSession();
|
|
335
|
-
return checkout;
|
|
336
|
-
}), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
|
|
337
|
-
}
|
|
338
|
-
buildCartFromCheckout(checkoutData) {
|
|
339
|
-
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
340
|
-
}
|
|
341
|
-
getFinancialDiscount(coupon) {
|
|
342
|
-
return (subTotalPrice) => {
|
|
343
|
-
if (FinancialCoupon.isFinancialCoupon(coupon))
|
|
344
|
-
switch (coupon.subtype) {
|
|
345
|
-
case CouponSubtypes.ABSOLUTE:
|
|
346
|
-
return subTotalPrice - coupon.discount * 100;
|
|
347
|
-
case CouponSubtypes.PERCENTAGE:
|
|
348
|
-
return subTotalPrice * (1 - coupon.discount / 100);
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
354
|
-
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
|
|
355
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
|
|
356
|
-
type: Injectable
|
|
357
|
-
}], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i2.Shops, decorators: [{
|
|
358
|
-
type: Inject,
|
|
359
|
-
args: [DEFAULT_SHOP]
|
|
129
|
+
class CheckoutService {
|
|
130
|
+
constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
|
|
131
|
+
this.couponService = couponService;
|
|
132
|
+
this.checkoutRepository = checkoutRepository;
|
|
133
|
+
this.orderRepository = orderRepository;
|
|
134
|
+
this.userRepository = userRepository;
|
|
135
|
+
this.defaultShop = defaultShop;
|
|
136
|
+
}
|
|
137
|
+
getCheckout(checkoutData) {
|
|
138
|
+
const checkoutId = cookie.get('checkoutId');
|
|
139
|
+
if (!isNil(checkoutId))
|
|
140
|
+
return from(this.checkoutRepository.get({ id: checkoutId }));
|
|
141
|
+
return from(this.createCheckout(checkoutData));
|
|
142
|
+
}
|
|
143
|
+
getUserByCheckout(checkoutId) {
|
|
144
|
+
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'))));
|
|
145
|
+
}
|
|
146
|
+
updateCheckoutLineItems(checkout) {
|
|
147
|
+
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
|
|
148
|
+
}
|
|
149
|
+
updateCheckoutUser(checkout) {
|
|
150
|
+
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
151
|
+
}
|
|
152
|
+
clearCheckoutFromSession() {
|
|
153
|
+
cookie.remove('checkoutId');
|
|
154
|
+
return of();
|
|
155
|
+
}
|
|
156
|
+
checkCoupon(nickname) {
|
|
157
|
+
return this.getCheckout().pipe(concatMap((checkout) => {
|
|
158
|
+
var _a;
|
|
159
|
+
return this.couponService.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, CheckoutTypes.ECOMMERCE).pipe(concatMap((coupons) => of(coupons.shift())), concatMap((coupon) => {
|
|
160
|
+
var _a, _b;
|
|
161
|
+
return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email)
|
|
162
|
+
? from(this.orderRepository.find([{ user: { email: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email }, coupon: { id: coupon.id } }])).pipe(concatMap((orders) => {
|
|
163
|
+
if (orders.data.length >= (coupon.useLimit || Infinity))
|
|
164
|
+
return throwError(() => new Error('Coupon is already applied'));
|
|
165
|
+
return of(coupon);
|
|
166
|
+
}))
|
|
167
|
+
: of(coupon);
|
|
168
|
+
}));
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
createCheckout(checkoutData) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
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 }));
|
|
174
|
+
cookie.set('checkoutId', checkout.id);
|
|
175
|
+
return checkout;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
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 });
|
|
180
|
+
CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService });
|
|
181
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, decorators: [{
|
|
182
|
+
type: Injectable
|
|
183
|
+
}], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
|
|
184
|
+
type: Inject,
|
|
185
|
+
args: ['CheckoutRepository']
|
|
186
|
+
}] }, { type: undefined, decorators: [{
|
|
187
|
+
type: Inject,
|
|
188
|
+
args: ['OrderRepository']
|
|
189
|
+
}] }, { type: undefined, decorators: [{
|
|
190
|
+
type: Inject,
|
|
191
|
+
args: ['UserRepository']
|
|
192
|
+
}] }, { type: i2.Shops, decorators: [{
|
|
193
|
+
type: Inject,
|
|
194
|
+
args: [DEFAULT_SHOP]
|
|
360
195
|
}] }]; } });
|
|
361
196
|
|
|
362
|
-
class
|
|
363
|
-
constructor(
|
|
364
|
-
this.
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
197
|
+
class CartService {
|
|
198
|
+
constructor(authService, checkoutService, defaultShop) {
|
|
199
|
+
this.authService = authService;
|
|
200
|
+
this.checkoutService = checkoutService;
|
|
201
|
+
this.defaultShop = defaultShop;
|
|
202
|
+
this.cartSubject = new Subject();
|
|
203
|
+
this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
|
|
204
|
+
var _a;
|
|
205
|
+
const items = [];
|
|
206
|
+
const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
|
|
207
|
+
if (index > -1) {
|
|
208
|
+
checkoutLoaded.lineItems[index].quantity += quantity;
|
|
209
|
+
checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
|
|
210
|
+
}
|
|
211
|
+
else
|
|
212
|
+
checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
|
|
213
|
+
return this.checkoutService
|
|
214
|
+
.updateCheckoutLineItems(checkoutLoaded)
|
|
215
|
+
.pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
|
|
216
|
+
}));
|
|
217
|
+
this.generateCartObject = (items) => {
|
|
218
|
+
const cart = {};
|
|
219
|
+
items === null || items === void 0 ? void 0 : items.forEach((item) => {
|
|
220
|
+
var _a;
|
|
221
|
+
return (cart[item.sku] = LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.sku] || item)), { quantity: (((_a = cart[item.sku]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })));
|
|
222
|
+
});
|
|
223
|
+
return cart;
|
|
224
|
+
};
|
|
225
|
+
this.buildLineItem = ({ checkout, item, quantity, }) => {
|
|
226
|
+
var _a, _b, _c, _d, _e;
|
|
227
|
+
item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
|
|
228
|
+
if (this.checkMaxStock(item, quantity || 0))
|
|
229
|
+
throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
|
|
230
|
+
const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
|
|
231
|
+
const { id, name, brand, slug, stock, price, weight, categories, sku } = item;
|
|
232
|
+
const isGift = item.isGift || null;
|
|
233
|
+
const pricePaid = this.getProductPrice({
|
|
234
|
+
product: item,
|
|
235
|
+
shop: checkout.shop || this.defaultShop,
|
|
236
|
+
isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
|
|
237
|
+
});
|
|
238
|
+
return LineItem.toInstance({
|
|
239
|
+
id,
|
|
240
|
+
name,
|
|
241
|
+
brand,
|
|
242
|
+
slug,
|
|
243
|
+
sku,
|
|
244
|
+
stock,
|
|
245
|
+
price,
|
|
246
|
+
image,
|
|
247
|
+
weight,
|
|
248
|
+
quantity: (item.quantity || 0) + (quantity || 0),
|
|
249
|
+
pricePaid,
|
|
250
|
+
categories,
|
|
251
|
+
isGift,
|
|
252
|
+
costPrice: item === null || item === void 0 ? void 0 : item.costPrice,
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
this.getProductPrice = ({ product, shop, isSubscriber, }) => {
|
|
256
|
+
const info = product.getInfoByShop(shop);
|
|
257
|
+
if (product.isGift)
|
|
258
|
+
return 0;
|
|
259
|
+
return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
|
|
260
|
+
};
|
|
261
|
+
this.checkMaxStock = (item, quantity) => {
|
|
262
|
+
var _a;
|
|
263
|
+
const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
|
|
264
|
+
const currentItemAmount = item.quantity || 0;
|
|
265
|
+
return currentItemAmount + quantity > maxStock;
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
addItem(item, quantity = 1) {
|
|
269
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => ({
|
|
270
|
+
checkout,
|
|
271
|
+
lineItem: this.buildLineItem({ checkout, item, quantity: quantity || 1 }),
|
|
272
|
+
})), concatMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
|
|
273
|
+
}
|
|
274
|
+
decreaseItem(item) {
|
|
275
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
276
|
+
var _a;
|
|
277
|
+
const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
|
|
278
|
+
if (!isNil(checkoutItem))
|
|
279
|
+
checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
|
|
280
|
+
return checkout;
|
|
281
|
+
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
282
|
+
}
|
|
283
|
+
getCart(checkout) {
|
|
284
|
+
this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
|
|
285
|
+
return this.cartSubject;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* @deprecated The method should not be used
|
|
289
|
+
*/
|
|
290
|
+
getDiscount(coupon) {
|
|
291
|
+
switch (coupon.type) {
|
|
292
|
+
case CouponTypes.FINANCIAL:
|
|
293
|
+
return this.getFinancialDiscount(coupon);
|
|
294
|
+
case CouponTypes.PRODUCT:
|
|
295
|
+
return (subTotalPrice) => subTotalPrice;
|
|
296
|
+
case CouponTypes.GIFTCARD:
|
|
297
|
+
return this.getFinancialDiscount(coupon);
|
|
298
|
+
case CouponTypes.VOUCHER:
|
|
299
|
+
return (subTotalPrice) => subTotalPrice;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* @deprecated The method should not be used
|
|
304
|
+
*/
|
|
305
|
+
getVariantPriceDiscount(item, shop) {
|
|
306
|
+
return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.getInfoByShop(shop).subscriberPrice, of(item.getInfoByShop(shop).subscriberPrice), of(item.getInfoByShop(shop).price))), catchError(() => of(item.getInfoByShop(shop).price)));
|
|
307
|
+
}
|
|
308
|
+
removeItem(item) {
|
|
309
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
310
|
+
const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
|
|
311
|
+
if (index >= 0)
|
|
312
|
+
checkout.lineItems.splice(index, 1);
|
|
313
|
+
return checkout;
|
|
314
|
+
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
315
|
+
}
|
|
316
|
+
updateUserCart(user) {
|
|
317
|
+
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => {
|
|
318
|
+
var _a;
|
|
319
|
+
return this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.map((item) => this.buildLineItem({ checkout, item }))) || [] })));
|
|
320
|
+
}), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
321
|
+
}
|
|
322
|
+
clearCart() {
|
|
323
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
324
|
+
this.checkoutService.clearCheckoutFromSession();
|
|
325
|
+
return checkout;
|
|
326
|
+
}), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
|
|
327
|
+
}
|
|
328
|
+
buildCartFromCheckout(checkoutData) {
|
|
329
|
+
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
330
|
+
}
|
|
331
|
+
getFinancialDiscount(coupon) {
|
|
332
|
+
return (subTotalPrice) => {
|
|
333
|
+
if (FinancialCoupon.isFinancialCoupon(coupon))
|
|
334
|
+
switch (coupon.subtype) {
|
|
335
|
+
case CouponSubtypes.ABSOLUTE:
|
|
336
|
+
return subTotalPrice - coupon.discount * 100;
|
|
337
|
+
case CouponSubtypes.PERCENTAGE:
|
|
338
|
+
return subTotalPrice * (1 - coupon.discount / 100);
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
344
|
+
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
|
|
345
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
|
|
346
|
+
type: Injectable
|
|
347
|
+
}], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i2.Shops, decorators: [{
|
|
348
|
+
type: Inject,
|
|
349
|
+
args: [DEFAULT_SHOP]
|
|
391
350
|
}] }]; } });
|
|
392
351
|
|
|
393
|
-
|
|
352
|
+
class CheckoutSubscriptionService {
|
|
353
|
+
constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
354
|
+
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
355
|
+
this.subscriptionRepository = subscriptionRepository;
|
|
356
|
+
this.couponService = couponService;
|
|
357
|
+
this.checkCouponsWithCheckout = (coupons, checkout) => forkJoin(coupons.map((coupon) => {
|
|
358
|
+
var _a;
|
|
359
|
+
return from(this.subscriptionRepository.find([{ user: { email: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email }, coupon: { id: coupon.id } }])).pipe(map((subscriptions) => ({ coupon, subscriptions })));
|
|
360
|
+
})).pipe(map((results) => results.map(({ coupon, subscriptions }) => {
|
|
361
|
+
if (subscriptions.data.length >= (coupon.useLimit || Infinity))
|
|
362
|
+
return new InvalidCouponError('Coupon is already applied');
|
|
363
|
+
return coupon;
|
|
364
|
+
})), map((validatedCoupons) => ({
|
|
365
|
+
valids: validatedCoupons.filter((coupon) => FinancialCoupon.isFinancialCoupon(coupon)),
|
|
366
|
+
invalids: validatedCoupons.filter((coupon) => coupon instanceof InvalidCouponError),
|
|
367
|
+
})), concatMap(({ valids, invalids }) => valids.length ? of(valids) : throwError(new GroupInvalidCouponError(invalids))));
|
|
368
|
+
}
|
|
369
|
+
getCheckoutSubscription(checkoutData) {
|
|
370
|
+
const checkoutId = cookie.get('checkoutSubscriptionId');
|
|
371
|
+
if (!isNil(checkoutId))
|
|
372
|
+
return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
|
|
373
|
+
return from(this.createCheckoutSubscription(checkoutData));
|
|
374
|
+
}
|
|
375
|
+
createCheckoutSubscription(checkoutData) {
|
|
376
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
377
|
+
const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
|
|
378
|
+
cookie.set('checkoutSubscriptionId', checkout.id);
|
|
379
|
+
return checkout;
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
clearCheckoutSubscriptionFromSession() {
|
|
383
|
+
cookie.remove('checkoutSubscriptionId');
|
|
384
|
+
return of();
|
|
385
|
+
}
|
|
386
|
+
checkCoupon(nickname, userEmail) {
|
|
387
|
+
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION).pipe(concatMap((coupons) => {
|
|
388
|
+
const couponsWithSamePlan = coupons.filter((coupon) => checkout.subscriptionPlan.name === coupon.plan);
|
|
389
|
+
const couponsWithNoPlan = coupons.filter((coupon) => !coupon.plan);
|
|
390
|
+
if (couponsWithSamePlan.length > 0)
|
|
391
|
+
return of(couponsWithSamePlan);
|
|
392
|
+
if (couponsWithNoPlan.length > 0)
|
|
393
|
+
return of(couponsWithNoPlan);
|
|
394
|
+
throw new Error(`Coupon subscription plan is invalid.`);
|
|
395
|
+
}), concatMap((coupons) => { var _a; return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email) ? this.checkCouponsWithCheckout(coupons, checkout) : of(coupons); }), map((validatedCoupons) => validatedCoupons.shift()))));
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
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 });
|
|
399
|
+
CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService });
|
|
400
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
401
|
+
type: Injectable
|
|
402
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
403
|
+
type: Inject,
|
|
404
|
+
args: ['CheckoutSubscriptionRepository']
|
|
405
|
+
}] }, { type: undefined, decorators: [{
|
|
406
|
+
type: Inject,
|
|
407
|
+
args: ['SubscriptionRepository']
|
|
408
|
+
}] }, { type: CouponService }]; } });
|
|
394
409
|
|
|
395
|
-
class
|
|
396
|
-
constructor() {
|
|
397
|
-
this.
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
410
|
+
class OrderService {
|
|
411
|
+
constructor(angularFirestore, orderRepository) {
|
|
412
|
+
this.angularFirestore = angularFirestore;
|
|
413
|
+
this.orderRepository = orderRepository;
|
|
414
|
+
this.orderSubject = new Subject();
|
|
415
|
+
}
|
|
416
|
+
getOrder(id) {
|
|
417
|
+
this.angularFirestore
|
|
418
|
+
.doc(`${this.orderRepository.collectionName}/${id}`)
|
|
419
|
+
.valueChanges()
|
|
420
|
+
.pipe(map((doc) => Order.toInstance(doc)))
|
|
421
|
+
.subscribe((doc) => this.orderSubject.next(doc));
|
|
422
|
+
return this.orderSubject;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$1.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
426
|
+
OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
|
|
427
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
|
|
428
|
+
type: Injectable
|
|
429
|
+
}], ctorParameters: function () { return [{ type: i1$1.AngularFirestore }, { type: i2.OrderFirestoreRepository, decorators: [{
|
|
430
|
+
type: Inject,
|
|
431
|
+
args: ['OrderRepository']
|
|
432
|
+
}] }]; } });
|
|
405
433
|
|
|
406
|
-
class
|
|
407
|
-
constructor(
|
|
408
|
-
this.
|
|
409
|
-
this.
|
|
410
|
-
this.
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
434
|
+
class HomeShopService {
|
|
435
|
+
constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
436
|
+
this.categoryRepository = categoryRepository;
|
|
437
|
+
this.homeRepository = homeRepository;
|
|
438
|
+
this.productRepository = productRepository;
|
|
439
|
+
this.defaultShop = defaultShop;
|
|
440
|
+
this.buildCategoryGroupWithRequiredData = (group) => ({
|
|
441
|
+
category: Category.toInstance(pick(group.category.toPlain(), ['id', 'name', 'slug', 'conditions'])),
|
|
442
|
+
products: group.products.map((product) => Product.toInstance(pick(product.toPlain(), [
|
|
443
|
+
'id',
|
|
444
|
+
'price',
|
|
445
|
+
'reviews',
|
|
446
|
+
'hasVariants',
|
|
447
|
+
'slug',
|
|
448
|
+
'sku',
|
|
449
|
+
'stock',
|
|
450
|
+
'costPrice',
|
|
451
|
+
'images',
|
|
452
|
+
'miniatures',
|
|
453
|
+
'name',
|
|
454
|
+
]))),
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
get homeId() {
|
|
458
|
+
if (this.defaultShop === Shops.GLAMSHOP)
|
|
459
|
+
return 'glamshop';
|
|
460
|
+
if (this.defaultShop === Shops.MENSMARKET)
|
|
461
|
+
return 'mens_market';
|
|
462
|
+
return null;
|
|
463
|
+
}
|
|
464
|
+
getHomeData() {
|
|
465
|
+
return this.getHomeConfiguration().pipe(tap((home) => { var _a; return console.log((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt); }), 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
|
|
466
|
+
? of(home)
|
|
467
|
+
: forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
|
|
468
|
+
discoverProducts,
|
|
469
|
+
featuredProducts,
|
|
470
|
+
verticalProducts,
|
|
471
|
+
})), concatMap((data) => this.saveHomeData(data)))));
|
|
472
|
+
}
|
|
473
|
+
getBanners(type) {
|
|
474
|
+
return this.getHomeConfiguration().pipe(map((home) => {
|
|
475
|
+
if (type === 'brand')
|
|
476
|
+
return home.brandsCarousel;
|
|
477
|
+
if (type === 'buyToWin')
|
|
478
|
+
return [home.buyToWinBanner];
|
|
479
|
+
if (type === 'block')
|
|
480
|
+
return home.blockBanners;
|
|
481
|
+
if (type === 'blog')
|
|
482
|
+
return [home.blogBanner];
|
|
483
|
+
}));
|
|
484
|
+
}
|
|
485
|
+
getDiscoverProducts() {
|
|
486
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
487
|
+
}
|
|
488
|
+
getFeaturedProducts() {
|
|
489
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
490
|
+
}
|
|
491
|
+
getVerticalProducts() {
|
|
492
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.map((id) => forkJoin([
|
|
493
|
+
this.categoryRepository.get({ id }),
|
|
494
|
+
this.productRepository.find([{ categories: { operator: Where.LIKE, value: [id] } }], { limit: 12 }),
|
|
495
|
+
]).pipe(map(([category, products]) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
|
|
496
|
+
}
|
|
497
|
+
getHomeConfiguration() {
|
|
498
|
+
return of(this.homeConfiguration).pipe(concatMap((home) => home
|
|
499
|
+
? of(home)
|
|
500
|
+
: !this.homeId
|
|
501
|
+
? throwError(new RequiredArgumentError(['homeId']))
|
|
502
|
+
: from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
|
|
503
|
+
}
|
|
504
|
+
saveHomeData(homeData) {
|
|
505
|
+
const data = {
|
|
506
|
+
createdAt: new Date(),
|
|
507
|
+
expiresAt: add(new Date(), { hours: 1 }),
|
|
508
|
+
data: homeData,
|
|
509
|
+
};
|
|
510
|
+
return from(this.homeRepository.update({
|
|
511
|
+
id: this.homeId,
|
|
512
|
+
data,
|
|
513
|
+
})).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
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 });
|
|
517
|
+
HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService });
|
|
518
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, decorators: [{
|
|
519
|
+
type: Injectable
|
|
520
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
521
|
+
type: Inject,
|
|
522
|
+
args: ['CategoryRepository']
|
|
523
|
+
}] }, { type: undefined, decorators: [{
|
|
524
|
+
type: Inject,
|
|
525
|
+
args: ['HomeRepository']
|
|
526
|
+
}] }, { type: undefined, decorators: [{
|
|
527
|
+
type: Inject,
|
|
528
|
+
args: ['ProductRepository']
|
|
529
|
+
}] }, { type: i2.Shops, decorators: [{
|
|
530
|
+
type: Inject,
|
|
531
|
+
args: [DEFAULT_SHOP]
|
|
427
532
|
}] }]; } });
|
|
428
533
|
|
|
429
|
-
class
|
|
430
|
-
static initializeApp(options, nameOrConfig) {
|
|
431
|
-
return {
|
|
432
|
-
ngModule:
|
|
433
|
-
providers: [
|
|
434
|
-
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
435
|
-
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
436
|
-
],
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
},
|
|
536
|
-
{
|
|
537
|
-
provide: 'ProductRepository',
|
|
538
|
-
useFactory: (firestore) => {
|
|
539
|
-
return new ProductFirestoreRepository(firestore);
|
|
540
|
-
},
|
|
541
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
542
|
-
},
|
|
543
|
-
{
|
|
544
|
-
provide: 'SubscriptionPaymentRepository',
|
|
545
|
-
useFactory: (firestore, subscriptionRepository) => {
|
|
546
|
-
return new SubscriptionPaymentFirestoreRepository(firestore, subscriptionRepository);
|
|
547
|
-
},
|
|
548
|
-
deps: [ConnectAngularFirebaseFirestore, 'SubscriptionRepository'],
|
|
549
|
-
},
|
|
550
|
-
{
|
|
551
|
-
provide: 'SubscriptionPlanRepository',
|
|
552
|
-
useFactory: (firestore) => {
|
|
553
|
-
return new SubscriptionPlanFirestoreRepository(firestore);
|
|
554
|
-
},
|
|
555
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
556
|
-
},
|
|
557
|
-
{
|
|
558
|
-
provide: 'SubscriptionProductRepository',
|
|
559
|
-
useFactory: (firestore) => {
|
|
560
|
-
return new SubscriptionProductFirestoreRepository(firestore);
|
|
561
|
-
},
|
|
562
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
563
|
-
},
|
|
564
|
-
{
|
|
565
|
-
provide: 'SubscriptionRepository',
|
|
566
|
-
useFactory: (firestore) => {
|
|
567
|
-
return new SubscriptionFirestoreRepository(firestore);
|
|
568
|
-
},
|
|
569
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
570
|
-
},
|
|
571
|
-
{
|
|
572
|
-
provide: 'UserRepository',
|
|
573
|
-
useFactory: (firestore) => {
|
|
574
|
-
console.log('teste');
|
|
575
|
-
console.log(firestore);
|
|
576
|
-
return new UserFirestoreRepository(firestore);
|
|
577
|
-
},
|
|
578
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
provide: 'UserAddressRepository',
|
|
582
|
-
useFactory: (firestore, userRepository) => {
|
|
583
|
-
return new UserAddressFirestoreRepository(firestore, userRepository);
|
|
584
|
-
},
|
|
585
|
-
deps: [ConnectAngularFirebaseFirestore, 'UserRepository'],
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
provide: 'UserPaymentMethodRepository',
|
|
589
|
-
useFactory: (firestore, userRepository) => {
|
|
590
|
-
return new UserPaymentMethodFirestoreRepository(firestore, userRepository);
|
|
591
|
-
},
|
|
592
|
-
deps: [ConnectAngularFirebaseFirestore, 'UserRepository'],
|
|
593
|
-
},
|
|
594
|
-
{
|
|
595
|
-
provide: 'VariantRepository',
|
|
596
|
-
useFactory: (firestore, productRepository) => {
|
|
597
|
-
return new ProductVariantFirestoreRepository(firestore, productRepository);
|
|
598
|
-
},
|
|
599
|
-
deps: [ConnectAngularFirebaseFirestore, 'ProductRepository'],
|
|
600
|
-
},
|
|
601
|
-
] });
|
|
602
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
603
|
-
type: NgModule,
|
|
604
|
-
args: [{
|
|
605
|
-
providers: [
|
|
606
|
-
FirebaseAppProvider,
|
|
607
|
-
FirebaseFirestoreProvider,
|
|
608
|
-
{
|
|
609
|
-
provide: 'BeautyProfileRepository',
|
|
610
|
-
useFactory: (firestore, userRepository) => {
|
|
611
|
-
return new UserBeautyProfileFirestoreRepository(firestore, userRepository);
|
|
612
|
-
},
|
|
613
|
-
deps: [ConnectAngularFirebaseFirestore, 'UserRepository'],
|
|
614
|
-
},
|
|
615
|
-
{
|
|
616
|
-
provide: 'Buy2WinRepository',
|
|
617
|
-
useFactory: (firestore) => {
|
|
618
|
-
return new Buy2WinFirestoreRepository(firestore);
|
|
619
|
-
},
|
|
620
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
621
|
-
},
|
|
622
|
-
{
|
|
623
|
-
provide: 'CategoryRepository',
|
|
624
|
-
useFactory: (firestore) => {
|
|
625
|
-
return new CategoryFirestoreRepository(firestore);
|
|
626
|
-
},
|
|
627
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
628
|
-
},
|
|
629
|
-
{
|
|
630
|
-
provide: 'CheckoutRepository',
|
|
631
|
-
useFactory: (firestore) => {
|
|
632
|
-
return new CheckoutFirestoreRepository(firestore);
|
|
633
|
-
},
|
|
634
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
635
|
-
},
|
|
636
|
-
{
|
|
637
|
-
provide: 'CheckoutSubscriptionRepository',
|
|
638
|
-
useFactory: (firestore) => {
|
|
639
|
-
return new CheckoutSubscriptionFirestoreRepository(firestore);
|
|
640
|
-
},
|
|
641
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
642
|
-
},
|
|
643
|
-
{
|
|
644
|
-
provide: 'CouponRepository',
|
|
645
|
-
useFactory: (firestore) => {
|
|
646
|
-
return new CouponFirestoreRepository(firestore);
|
|
647
|
-
},
|
|
648
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
649
|
-
},
|
|
650
|
-
{
|
|
651
|
-
provide: 'EditionRepository',
|
|
652
|
-
useFactory: (firestore, subscriptionRepository) => {
|
|
653
|
-
return new SubscriptionEditionFirestoreRepository(firestore, subscriptionRepository);
|
|
654
|
-
},
|
|
655
|
-
deps: [ConnectAngularFirebaseFirestore, 'SubscriptionRepository'],
|
|
656
|
-
},
|
|
657
|
-
{
|
|
658
|
-
provide: 'HomeRepository',
|
|
659
|
-
useFactory: (firestore) => {
|
|
660
|
-
return new HomeFirestoreRepository(firestore);
|
|
661
|
-
},
|
|
662
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
663
|
-
},
|
|
664
|
-
{
|
|
665
|
-
provide: 'LeadRepository',
|
|
666
|
-
useFactory: (firestore) => {
|
|
667
|
-
return new LeadFirestoreRepository(firestore);
|
|
668
|
-
},
|
|
669
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
670
|
-
},
|
|
671
|
-
{
|
|
672
|
-
provide: 'LegacyOrderRepository',
|
|
673
|
-
useFactory: (firestore) => {
|
|
674
|
-
return new LegacyOrderFirestoreRepository(firestore);
|
|
675
|
-
},
|
|
676
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
677
|
-
},
|
|
678
|
-
{
|
|
679
|
-
provide: 'ShopMenuRepository',
|
|
680
|
-
useFactory: (firestore) => {
|
|
681
|
-
return new ShopMenuFirestoreRepository(firestore);
|
|
682
|
-
},
|
|
683
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
684
|
-
},
|
|
685
|
-
{
|
|
686
|
-
provide: 'OrderRepository',
|
|
687
|
-
useFactory: (firestore) => {
|
|
688
|
-
return new OrderFirestoreRepository(firestore);
|
|
689
|
-
},
|
|
690
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
691
|
-
},
|
|
692
|
-
{
|
|
693
|
-
provide: 'PaymentRepository',
|
|
694
|
-
useFactory: (firestore) => {
|
|
695
|
-
return new PaymentFirestoreRepository(firestore);
|
|
696
|
-
},
|
|
697
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
698
|
-
},
|
|
699
|
-
{
|
|
700
|
-
provide: 'ProductRepository',
|
|
701
|
-
useFactory: (firestore) => {
|
|
702
|
-
return new ProductFirestoreRepository(firestore);
|
|
703
|
-
},
|
|
704
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
705
|
-
},
|
|
706
|
-
{
|
|
707
|
-
provide: 'SubscriptionPaymentRepository',
|
|
708
|
-
useFactory: (firestore, subscriptionRepository) => {
|
|
709
|
-
return new SubscriptionPaymentFirestoreRepository(firestore, subscriptionRepository);
|
|
710
|
-
},
|
|
711
|
-
deps: [ConnectAngularFirebaseFirestore, 'SubscriptionRepository'],
|
|
712
|
-
},
|
|
713
|
-
{
|
|
714
|
-
provide: 'SubscriptionPlanRepository',
|
|
715
|
-
useFactory: (firestore) => {
|
|
716
|
-
return new SubscriptionPlanFirestoreRepository(firestore);
|
|
717
|
-
},
|
|
718
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
719
|
-
},
|
|
720
|
-
{
|
|
721
|
-
provide: 'SubscriptionProductRepository',
|
|
722
|
-
useFactory: (firestore) => {
|
|
723
|
-
return new SubscriptionProductFirestoreRepository(firestore);
|
|
724
|
-
},
|
|
725
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
726
|
-
},
|
|
727
|
-
{
|
|
728
|
-
provide: 'SubscriptionRepository',
|
|
729
|
-
useFactory: (firestore) => {
|
|
730
|
-
return new SubscriptionFirestoreRepository(firestore);
|
|
731
|
-
},
|
|
732
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
733
|
-
},
|
|
734
|
-
{
|
|
735
|
-
provide: 'UserRepository',
|
|
736
|
-
useFactory: (firestore) => {
|
|
737
|
-
console.log('teste');
|
|
738
|
-
console.log(firestore);
|
|
739
|
-
return new UserFirestoreRepository(firestore);
|
|
740
|
-
},
|
|
741
|
-
deps: [ConnectAngularFirebaseFirestore],
|
|
742
|
-
},
|
|
743
|
-
{
|
|
744
|
-
provide: 'UserAddressRepository',
|
|
745
|
-
useFactory: (firestore, userRepository) => {
|
|
746
|
-
return new UserAddressFirestoreRepository(firestore, userRepository);
|
|
747
|
-
},
|
|
748
|
-
deps: [ConnectAngularFirebaseFirestore, 'UserRepository'],
|
|
749
|
-
},
|
|
750
|
-
{
|
|
751
|
-
provide: 'UserPaymentMethodRepository',
|
|
752
|
-
useFactory: (firestore, userRepository) => {
|
|
753
|
-
return new UserPaymentMethodFirestoreRepository(firestore, userRepository);
|
|
754
|
-
},
|
|
755
|
-
deps: [ConnectAngularFirebaseFirestore, 'UserRepository'],
|
|
756
|
-
},
|
|
757
|
-
{
|
|
758
|
-
provide: 'VariantRepository',
|
|
759
|
-
useFactory: (firestore, productRepository) => {
|
|
760
|
-
return new ProductVariantFirestoreRepository(firestore, productRepository);
|
|
761
|
-
},
|
|
762
|
-
deps: [ConnectAngularFirebaseFirestore, 'ProductRepository'],
|
|
763
|
-
},
|
|
764
|
-
],
|
|
765
|
-
}]
|
|
534
|
+
class AngularFirebaseAuthModule {
|
|
535
|
+
static initializeApp(options, nameOrConfig) {
|
|
536
|
+
return {
|
|
537
|
+
ngModule: AngularFirebaseAuthModule,
|
|
538
|
+
providers: [
|
|
539
|
+
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
540
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
541
|
+
],
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
546
|
+
AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
|
|
547
|
+
AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
|
|
548
|
+
{
|
|
549
|
+
provide: 'Authentication',
|
|
550
|
+
useFactory: (authenticationService, userRepository) => {
|
|
551
|
+
return new Authentication(authenticationService, userRepository);
|
|
552
|
+
},
|
|
553
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
provide: 'AuthenticationService',
|
|
557
|
+
useFactory: (angularFireAuth) => {
|
|
558
|
+
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
559
|
+
},
|
|
560
|
+
deps: [AngularFireAuth],
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
provide: 'Register',
|
|
564
|
+
useFactory: (registerService, userRepository) => {
|
|
565
|
+
return new Register(registerService, userRepository);
|
|
566
|
+
},
|
|
567
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
provide: 'RegisterService',
|
|
571
|
+
useFactory: (angularFireAuth) => {
|
|
572
|
+
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
573
|
+
},
|
|
574
|
+
deps: [AngularFireAuth],
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
provide: 'SignOut',
|
|
578
|
+
useFactory: (authenticationService) => {
|
|
579
|
+
return new SignOut(authenticationService);
|
|
580
|
+
},
|
|
581
|
+
deps: ['AuthenticationService'],
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
provide: 'RecoveryPassword',
|
|
585
|
+
useFactory: (authenticationService) => {
|
|
586
|
+
return new RecoveryPassword(authenticationService);
|
|
587
|
+
},
|
|
588
|
+
deps: ['AuthenticationService'],
|
|
589
|
+
},
|
|
590
|
+
], imports: [[AngularFireModule]] });
|
|
591
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
|
|
592
|
+
type: NgModule,
|
|
593
|
+
args: [{
|
|
594
|
+
imports: [AngularFireModule],
|
|
595
|
+
providers: [
|
|
596
|
+
{
|
|
597
|
+
provide: 'Authentication',
|
|
598
|
+
useFactory: (authenticationService, userRepository) => {
|
|
599
|
+
return new Authentication(authenticationService, userRepository);
|
|
600
|
+
},
|
|
601
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
provide: 'AuthenticationService',
|
|
605
|
+
useFactory: (angularFireAuth) => {
|
|
606
|
+
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
607
|
+
},
|
|
608
|
+
deps: [AngularFireAuth],
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
provide: 'Register',
|
|
612
|
+
useFactory: (registerService, userRepository) => {
|
|
613
|
+
return new Register(registerService, userRepository);
|
|
614
|
+
},
|
|
615
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
provide: 'RegisterService',
|
|
619
|
+
useFactory: (angularFireAuth) => {
|
|
620
|
+
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
621
|
+
},
|
|
622
|
+
deps: [AngularFireAuth],
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
provide: 'SignOut',
|
|
626
|
+
useFactory: (authenticationService) => {
|
|
627
|
+
return new SignOut(authenticationService);
|
|
628
|
+
},
|
|
629
|
+
deps: ['AuthenticationService'],
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
provide: 'RecoveryPassword',
|
|
633
|
+
useFactory: (authenticationService) => {
|
|
634
|
+
return new RecoveryPassword(authenticationService);
|
|
635
|
+
},
|
|
636
|
+
deps: ['AuthenticationService'],
|
|
637
|
+
},
|
|
638
|
+
],
|
|
639
|
+
}]
|
|
766
640
|
}] });
|
|
767
641
|
|
|
768
|
-
class
|
|
769
|
-
static initializeApp(options, nameOrConfig) {
|
|
770
|
-
return {
|
|
771
|
-
ngModule:
|
|
772
|
-
providers: [
|
|
773
|
-
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
774
|
-
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
775
|
-
],
|
|
776
|
-
};
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
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
|
-
|
|
642
|
+
class AngularFirestoreModule {
|
|
643
|
+
static initializeApp(options, nameOrConfig) {
|
|
644
|
+
return {
|
|
645
|
+
ngModule: AngularFirestoreModule,
|
|
646
|
+
providers: [
|
|
647
|
+
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
648
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
649
|
+
],
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
654
|
+
AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule] });
|
|
655
|
+
AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
|
|
656
|
+
{
|
|
657
|
+
provide: 'BeautyProfileRepository',
|
|
658
|
+
useFactory: (firestore, userRepository) => {
|
|
659
|
+
return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
660
|
+
},
|
|
661
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
provide: 'Buy2WinRepository',
|
|
665
|
+
useFactory: (firestore) => {
|
|
666
|
+
return new Buy2WinFirestoreRepository(firestore.firestore);
|
|
667
|
+
},
|
|
668
|
+
deps: [AngularFirestore],
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
provide: 'CategoryRepository',
|
|
672
|
+
useFactory: (firestore) => {
|
|
673
|
+
return new CategoryFirestoreRepository(firestore.firestore);
|
|
674
|
+
},
|
|
675
|
+
deps: [AngularFirestore],
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
provide: 'CheckoutRepository',
|
|
679
|
+
useFactory: (firestore) => {
|
|
680
|
+
return new CheckoutFirestoreRepository(firestore.firestore);
|
|
681
|
+
},
|
|
682
|
+
deps: [AngularFirestore],
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
686
|
+
useFactory: (firestore) => {
|
|
687
|
+
return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
688
|
+
},
|
|
689
|
+
deps: [AngularFirestore],
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
provide: 'CouponRepository',
|
|
693
|
+
useFactory: (firestore) => {
|
|
694
|
+
return new CouponFirestoreRepository(firestore.firestore);
|
|
695
|
+
},
|
|
696
|
+
deps: [AngularFirestore],
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
provide: 'EditionRepository',
|
|
700
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
701
|
+
return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
702
|
+
},
|
|
703
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
provide: 'HomeRepository',
|
|
707
|
+
useFactory: (firestore) => {
|
|
708
|
+
return new HomeFirestoreRepository(firestore.firestore);
|
|
709
|
+
},
|
|
710
|
+
deps: [AngularFirestore],
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
provide: 'LeadRepository',
|
|
714
|
+
useFactory: (firestore) => {
|
|
715
|
+
return new LeadFirestoreRepository(firestore.firestore);
|
|
716
|
+
},
|
|
717
|
+
deps: [AngularFirestore],
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
provide: 'LegacyOrderRepository',
|
|
721
|
+
useFactory: (firestore) => {
|
|
722
|
+
return new LegacyOrderFirestoreRepository(firestore.firestore);
|
|
723
|
+
},
|
|
724
|
+
deps: [AngularFirestore],
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
provide: 'ShopMenuRepository',
|
|
728
|
+
useFactory: (firestore) => {
|
|
729
|
+
return new ShopMenuFirestoreRepository(firestore.firestore);
|
|
730
|
+
},
|
|
731
|
+
deps: [AngularFirestore],
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
provide: 'OrderRepository',
|
|
735
|
+
useFactory: (firestore) => {
|
|
736
|
+
return new OrderFirestoreRepository(firestore.firestore);
|
|
737
|
+
},
|
|
738
|
+
deps: [AngularFirestore],
|
|
739
|
+
},
|
|
740
|
+
{
|
|
741
|
+
provide: 'PaymentRepository',
|
|
742
|
+
useFactory: (firestore) => {
|
|
743
|
+
return new PaymentFirestoreRepository(firestore.firestore);
|
|
744
|
+
},
|
|
745
|
+
deps: [AngularFirestore],
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
provide: 'ProductRepository',
|
|
749
|
+
useFactory: (firestore) => {
|
|
750
|
+
return new ProductFirestoreRepository(firestore.firestore);
|
|
751
|
+
},
|
|
752
|
+
deps: [AngularFirestore],
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
provide: 'SubscriptionPaymentRepository',
|
|
756
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
757
|
+
return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
758
|
+
},
|
|
759
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
provide: 'SubscriptionPlanRepository',
|
|
763
|
+
useFactory: (firestore) => {
|
|
764
|
+
return new SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
765
|
+
},
|
|
766
|
+
deps: [AngularFirestore],
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
provide: 'SubscriptionProductRepository',
|
|
770
|
+
useFactory: (firestore) => {
|
|
771
|
+
return new SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
772
|
+
},
|
|
773
|
+
deps: [AngularFirestore],
|
|
774
|
+
},
|
|
775
|
+
{
|
|
776
|
+
provide: 'SubscriptionRepository',
|
|
777
|
+
useFactory: (firestore) => {
|
|
778
|
+
return new SubscriptionFirestoreRepository(firestore.firestore);
|
|
779
|
+
},
|
|
780
|
+
deps: [AngularFirestore],
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
provide: 'UserRepository',
|
|
784
|
+
useFactory: (firestore) => {
|
|
785
|
+
return new UserFirestoreRepository(firestore.firestore);
|
|
786
|
+
},
|
|
787
|
+
deps: [AngularFirestore],
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
provide: 'UserAddressRepository',
|
|
791
|
+
useFactory: (firestore, userRepository) => {
|
|
792
|
+
return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
793
|
+
},
|
|
794
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
provide: 'UserPaymentMethodRepository',
|
|
798
|
+
useFactory: (firestore, userRepository) => {
|
|
799
|
+
return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
800
|
+
},
|
|
801
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
provide: 'VariantRepository',
|
|
805
|
+
useFactory: (firestore, productRepository) => {
|
|
806
|
+
return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
807
|
+
},
|
|
808
|
+
deps: [AngularFirestore, 'ProductRepository'],
|
|
809
|
+
},
|
|
810
|
+
], imports: [[AngularFireModule]] });
|
|
811
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
812
|
+
type: NgModule,
|
|
813
|
+
args: [{
|
|
814
|
+
imports: [AngularFireModule],
|
|
815
|
+
providers: [
|
|
816
|
+
{
|
|
817
|
+
provide: 'BeautyProfileRepository',
|
|
818
|
+
useFactory: (firestore, userRepository) => {
|
|
819
|
+
return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
820
|
+
},
|
|
821
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
provide: 'Buy2WinRepository',
|
|
825
|
+
useFactory: (firestore) => {
|
|
826
|
+
return new Buy2WinFirestoreRepository(firestore.firestore);
|
|
827
|
+
},
|
|
828
|
+
deps: [AngularFirestore],
|
|
829
|
+
},
|
|
830
|
+
{
|
|
831
|
+
provide: 'CategoryRepository',
|
|
832
|
+
useFactory: (firestore) => {
|
|
833
|
+
return new CategoryFirestoreRepository(firestore.firestore);
|
|
834
|
+
},
|
|
835
|
+
deps: [AngularFirestore],
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
provide: 'CheckoutRepository',
|
|
839
|
+
useFactory: (firestore) => {
|
|
840
|
+
return new CheckoutFirestoreRepository(firestore.firestore);
|
|
841
|
+
},
|
|
842
|
+
deps: [AngularFirestore],
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
846
|
+
useFactory: (firestore) => {
|
|
847
|
+
return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
848
|
+
},
|
|
849
|
+
deps: [AngularFirestore],
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
provide: 'CouponRepository',
|
|
853
|
+
useFactory: (firestore) => {
|
|
854
|
+
return new CouponFirestoreRepository(firestore.firestore);
|
|
855
|
+
},
|
|
856
|
+
deps: [AngularFirestore],
|
|
857
|
+
},
|
|
858
|
+
{
|
|
859
|
+
provide: 'EditionRepository',
|
|
860
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
861
|
+
return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
862
|
+
},
|
|
863
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
provide: 'HomeRepository',
|
|
867
|
+
useFactory: (firestore) => {
|
|
868
|
+
return new HomeFirestoreRepository(firestore.firestore);
|
|
869
|
+
},
|
|
870
|
+
deps: [AngularFirestore],
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
provide: 'LeadRepository',
|
|
874
|
+
useFactory: (firestore) => {
|
|
875
|
+
return new LeadFirestoreRepository(firestore.firestore);
|
|
876
|
+
},
|
|
877
|
+
deps: [AngularFirestore],
|
|
878
|
+
},
|
|
879
|
+
{
|
|
880
|
+
provide: 'LegacyOrderRepository',
|
|
881
|
+
useFactory: (firestore) => {
|
|
882
|
+
return new LegacyOrderFirestoreRepository(firestore.firestore);
|
|
883
|
+
},
|
|
884
|
+
deps: [AngularFirestore],
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
provide: 'ShopMenuRepository',
|
|
888
|
+
useFactory: (firestore) => {
|
|
889
|
+
return new ShopMenuFirestoreRepository(firestore.firestore);
|
|
890
|
+
},
|
|
891
|
+
deps: [AngularFirestore],
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
provide: 'OrderRepository',
|
|
895
|
+
useFactory: (firestore) => {
|
|
896
|
+
return new OrderFirestoreRepository(firestore.firestore);
|
|
897
|
+
},
|
|
898
|
+
deps: [AngularFirestore],
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
provide: 'PaymentRepository',
|
|
902
|
+
useFactory: (firestore) => {
|
|
903
|
+
return new PaymentFirestoreRepository(firestore.firestore);
|
|
904
|
+
},
|
|
905
|
+
deps: [AngularFirestore],
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
provide: 'ProductRepository',
|
|
909
|
+
useFactory: (firestore) => {
|
|
910
|
+
return new ProductFirestoreRepository(firestore.firestore);
|
|
911
|
+
},
|
|
912
|
+
deps: [AngularFirestore],
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
provide: 'SubscriptionPaymentRepository',
|
|
916
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
917
|
+
return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
918
|
+
},
|
|
919
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
920
|
+
},
|
|
921
|
+
{
|
|
922
|
+
provide: 'SubscriptionPlanRepository',
|
|
923
|
+
useFactory: (firestore) => {
|
|
924
|
+
return new SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
925
|
+
},
|
|
926
|
+
deps: [AngularFirestore],
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
provide: 'SubscriptionProductRepository',
|
|
930
|
+
useFactory: (firestore) => {
|
|
931
|
+
return new SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
932
|
+
},
|
|
933
|
+
deps: [AngularFirestore],
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
provide: 'SubscriptionRepository',
|
|
937
|
+
useFactory: (firestore) => {
|
|
938
|
+
return new SubscriptionFirestoreRepository(firestore.firestore);
|
|
939
|
+
},
|
|
940
|
+
deps: [AngularFirestore],
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
provide: 'UserRepository',
|
|
944
|
+
useFactory: (firestore) => {
|
|
945
|
+
return new UserFirestoreRepository(firestore.firestore);
|
|
946
|
+
},
|
|
947
|
+
deps: [AngularFirestore],
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
provide: 'UserAddressRepository',
|
|
951
|
+
useFactory: (firestore, userRepository) => {
|
|
952
|
+
return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
953
|
+
},
|
|
954
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
955
|
+
},
|
|
956
|
+
{
|
|
957
|
+
provide: 'UserPaymentMethodRepository',
|
|
958
|
+
useFactory: (firestore, userRepository) => {
|
|
959
|
+
return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
960
|
+
},
|
|
961
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
962
|
+
},
|
|
963
|
+
{
|
|
964
|
+
provide: 'VariantRepository',
|
|
965
|
+
useFactory: (firestore, productRepository) => {
|
|
966
|
+
return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
967
|
+
},
|
|
968
|
+
deps: [AngularFirestore, 'ProductRepository'],
|
|
969
|
+
},
|
|
970
|
+
],
|
|
971
|
+
}]
|
|
864
972
|
}] });
|
|
865
973
|
|
|
866
|
-
class AngularConnectModule {
|
|
867
|
-
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
868
|
-
return {
|
|
869
|
-
ngModule: AngularConnectModule,
|
|
870
|
-
providers: [
|
|
871
|
-
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
872
|
-
...(isNil(options) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options }]),
|
|
873
|
-
...(isNil(options) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
874
|
-
],
|
|
875
|
-
};
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
879
|
-
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [
|
|
880
|
-
AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
|
|
881
|
-
AuthService,
|
|
882
|
-
CartService,
|
|
883
|
-
CheckoutService,
|
|
884
|
-
CheckoutSubscriptionService,
|
|
885
|
-
CouponService,
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
], imports: [[
|
|
889
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
890
|
-
type: NgModule,
|
|
891
|
-
args: [{
|
|
892
|
-
imports: [
|
|
893
|
-
providers: [
|
|
894
|
-
AuthService,
|
|
895
|
-
CartService,
|
|
896
|
-
CheckoutService,
|
|
897
|
-
CheckoutSubscriptionService,
|
|
898
|
-
CouponService,
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
],
|
|
902
|
-
}]
|
|
974
|
+
class AngularConnectModule {
|
|
975
|
+
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
976
|
+
return {
|
|
977
|
+
ngModule: AngularConnectModule,
|
|
978
|
+
providers: [
|
|
979
|
+
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
980
|
+
...(isNil(options) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options }]),
|
|
981
|
+
...(isNil(options) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
982
|
+
],
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
987
|
+
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule] });
|
|
988
|
+
AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
|
|
989
|
+
AuthService,
|
|
990
|
+
CartService,
|
|
991
|
+
CheckoutService,
|
|
992
|
+
CheckoutSubscriptionService,
|
|
993
|
+
CouponService,
|
|
994
|
+
HomeShopService,
|
|
995
|
+
OrderService,
|
|
996
|
+
], imports: [[AngularFireModule, AngularFirestoreModule]] });
|
|
997
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
998
|
+
type: NgModule,
|
|
999
|
+
args: [{
|
|
1000
|
+
imports: [AngularFireModule, AngularFirestoreModule],
|
|
1001
|
+
providers: [
|
|
1002
|
+
AuthService,
|
|
1003
|
+
CartService,
|
|
1004
|
+
CheckoutService,
|
|
1005
|
+
CheckoutSubscriptionService,
|
|
1006
|
+
CouponService,
|
|
1007
|
+
HomeShopService,
|
|
1008
|
+
OrderService,
|
|
1009
|
+
],
|
|
1010
|
+
}]
|
|
903
1011
|
}] });
|
|
904
1012
|
|
|
905
|
-
/**
|
|
906
|
-
* Generated bundle index. Do not edit.
|
|
1013
|
+
/**
|
|
1014
|
+
* Generated bundle index. Do not edit.
|
|
907
1015
|
*/
|
|
908
1016
|
|
|
909
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AuthService, CartService, CheckoutService, CheckoutSubscriptionService,
|
|
1017
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService };
|
|
910
1018
|
//# sourceMappingURL=infrab4a-connect-angular.js.map
|