@infrab4a/connect-angular 0.13.1 → 0.13.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/bundles/infrab4a-connect-angular.umd.js +1381 -1380
- 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 -46
- package/esm2015/lib/angular-firebase-auth.module.js +113 -113
- package/esm2015/lib/angular-firestore.module.js +337 -337
- package/esm2015/lib/consts/default-shop.const.js +2 -2
- package/esm2015/lib/consts/index.js +2 -2
- package/esm2015/lib/index.js +5 -5
- package/esm2015/lib/services/auth.service.js +42 -42
- package/esm2015/lib/services/cart.service.js +166 -166
- package/esm2015/lib/services/checkout-subscription.service.js +68 -68
- package/esm2015/lib/services/checkout.service.js +79 -79
- package/esm2015/lib/services/coupon.service.js +70 -70
- package/esm2015/lib/services/errors/group-invalid-coupon.error.js +7 -7
- package/esm2015/lib/services/errors/index.js +3 -3
- package/esm2015/lib/services/errors/invalid-coupon.error.js +7 -7
- package/esm2015/lib/services/home-shop.service.js +108 -107
- package/esm2015/lib/services/index.js +8 -8
- package/esm2015/lib/services/order.service.js +32 -32
- 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 +975 -974
- 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 -10
- package/lib/consts/default-shop.const.d.ts +1 -1
- package/lib/consts/index.d.ts +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/services/auth.service.d.ts +19 -19
- package/lib/services/cart.service.d.ts +41 -41
- package/lib/services/checkout-subscription.service.d.ts +18 -18
- package/lib/services/checkout.service.d.ts +22 -22
- package/lib/services/coupon.service.d.ts +14 -14
- package/lib/services/errors/group-invalid-coupon.error.d.ts +5 -5
- package/lib/services/errors/index.d.ts +2 -2
- package/lib/services/errors/invalid-coupon.error.d.ts +4 -4
- package/lib/services/home-shop.service.d.ts +24 -24
- package/lib/services/index.d.ts +7 -7
- 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 +1 -1
- package/public-api.d.ts +1 -1
|
@@ -12,1006 +12,1007 @@ import * as i1$1 from '@angular/fire/firestore';
|
|
|
12
12
|
import { AngularFirestore } from '@angular/fire/firestore';
|
|
13
13
|
import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, AngularFireModule } from '@angular/fire';
|
|
14
14
|
|
|
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']
|
|
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
49
|
}] }]; } });
|
|
50
50
|
|
|
51
51
|
const DEFAULT_SHOP = 'DEFAULT_SHOP';
|
|
52
52
|
|
|
53
|
-
class InvalidCouponError extends Error {
|
|
54
|
-
constructor(message) {
|
|
55
|
-
super(message);
|
|
56
|
-
this.message = message;
|
|
57
|
-
}
|
|
53
|
+
class InvalidCouponError extends Error {
|
|
54
|
+
constructor(message) {
|
|
55
|
+
super(message);
|
|
56
|
+
this.message = message;
|
|
57
|
+
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
class GroupInvalidCouponError extends Error {
|
|
61
|
-
constructor(errors) {
|
|
62
|
-
super('Many coupon errors throw');
|
|
63
|
-
this.errors = errors;
|
|
64
|
-
}
|
|
60
|
+
class GroupInvalidCouponError extends Error {
|
|
61
|
+
constructor(errors) {
|
|
62
|
+
super('Many coupon errors throw');
|
|
63
|
+
this.errors = errors;
|
|
64
|
+
}
|
|
65
65
|
}
|
|
66
66
|
|
|
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]
|
|
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]
|
|
127
127
|
}] }]; } });
|
|
128
128
|
|
|
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]
|
|
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]
|
|
195
195
|
}] }]; } });
|
|
196
196
|
|
|
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]
|
|
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]
|
|
350
350
|
}] }]; } });
|
|
351
351
|
|
|
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']
|
|
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
408
|
}] }, { type: CouponService }]; } });
|
|
409
409
|
|
|
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']
|
|
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
432
|
}] }]; } });
|
|
433
433
|
|
|
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
|
-
|
|
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
|
-
this.
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
HomeShopService.ɵ
|
|
518
|
-
i0.ɵɵ
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
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
|
+
'weight',
|
|
455
|
+
]))),
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
get homeId() {
|
|
459
|
+
if (this.defaultShop === Shops.GLAMSHOP)
|
|
460
|
+
return 'glamshop';
|
|
461
|
+
if (this.defaultShop === Shops.MENSMARKET)
|
|
462
|
+
return 'mens_market';
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
getHomeData() {
|
|
466
|
+
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
|
|
467
|
+
? of(home)
|
|
468
|
+
: forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
|
|
469
|
+
discoverProducts,
|
|
470
|
+
featuredProducts,
|
|
471
|
+
verticalProducts,
|
|
472
|
+
})), concatMap((data) => this.saveHomeData(data)))));
|
|
473
|
+
}
|
|
474
|
+
getBanners(type) {
|
|
475
|
+
return this.getHomeConfiguration().pipe(map((home) => {
|
|
476
|
+
if (type === 'brand')
|
|
477
|
+
return home.brandsCarousel;
|
|
478
|
+
if (type === 'buyToWin')
|
|
479
|
+
return [home.buyToWinBanner];
|
|
480
|
+
if (type === 'block')
|
|
481
|
+
return home.blockBanners;
|
|
482
|
+
if (type === 'blog')
|
|
483
|
+
return [home.blogBanner];
|
|
484
|
+
}));
|
|
485
|
+
}
|
|
486
|
+
getDiscoverProducts() {
|
|
487
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
488
|
+
}
|
|
489
|
+
getFeaturedProducts() {
|
|
490
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
491
|
+
}
|
|
492
|
+
getVerticalProducts() {
|
|
493
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.map((id) => forkJoin([
|
|
494
|
+
this.categoryRepository.get({ id }),
|
|
495
|
+
this.productRepository.find([{ categories: { operator: Where.LIKE, value: [id] } }], { limit: 12 }),
|
|
496
|
+
]).pipe(map(([category, products]) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
|
|
497
|
+
}
|
|
498
|
+
getHomeConfiguration() {
|
|
499
|
+
return of(this.homeConfiguration).pipe(concatMap((home) => home
|
|
500
|
+
? of(home)
|
|
501
|
+
: !this.homeId
|
|
502
|
+
? throwError(new RequiredArgumentError(['homeId']))
|
|
503
|
+
: from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
|
|
504
|
+
}
|
|
505
|
+
saveHomeData(homeData) {
|
|
506
|
+
const data = {
|
|
507
|
+
createdAt: new Date(),
|
|
508
|
+
expiresAt: add(new Date(), { hours: 1 }),
|
|
509
|
+
data: homeData,
|
|
510
|
+
};
|
|
511
|
+
return from(this.homeRepository.update({
|
|
512
|
+
id: this.homeId,
|
|
513
|
+
data,
|
|
514
|
+
})).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
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 });
|
|
518
|
+
HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService });
|
|
519
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, decorators: [{
|
|
520
|
+
type: Injectable
|
|
521
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
522
|
+
type: Inject,
|
|
523
|
+
args: ['CategoryRepository']
|
|
524
|
+
}] }, { type: undefined, decorators: [{
|
|
525
|
+
type: Inject,
|
|
526
|
+
args: ['HomeRepository']
|
|
527
|
+
}] }, { type: undefined, decorators: [{
|
|
528
|
+
type: Inject,
|
|
529
|
+
args: ['ProductRepository']
|
|
530
|
+
}] }, { type: i2.Shops, decorators: [{
|
|
531
|
+
type: Inject,
|
|
532
|
+
args: [DEFAULT_SHOP]
|
|
532
533
|
}] }]; } });
|
|
533
534
|
|
|
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
|
-
}]
|
|
535
|
+
class AngularFirebaseAuthModule {
|
|
536
|
+
static initializeApp(options, nameOrConfig) {
|
|
537
|
+
return {
|
|
538
|
+
ngModule: AngularFirebaseAuthModule,
|
|
539
|
+
providers: [
|
|
540
|
+
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
541
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
542
|
+
],
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
547
|
+
AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
|
|
548
|
+
AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
|
|
549
|
+
{
|
|
550
|
+
provide: 'Authentication',
|
|
551
|
+
useFactory: (authenticationService, userRepository) => {
|
|
552
|
+
return new Authentication(authenticationService, userRepository);
|
|
553
|
+
},
|
|
554
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
provide: 'AuthenticationService',
|
|
558
|
+
useFactory: (angularFireAuth) => {
|
|
559
|
+
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
560
|
+
},
|
|
561
|
+
deps: [AngularFireAuth],
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
provide: 'Register',
|
|
565
|
+
useFactory: (registerService, userRepository) => {
|
|
566
|
+
return new Register(registerService, userRepository);
|
|
567
|
+
},
|
|
568
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
provide: 'RegisterService',
|
|
572
|
+
useFactory: (angularFireAuth) => {
|
|
573
|
+
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
574
|
+
},
|
|
575
|
+
deps: [AngularFireAuth],
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
provide: 'SignOut',
|
|
579
|
+
useFactory: (authenticationService) => {
|
|
580
|
+
return new SignOut(authenticationService);
|
|
581
|
+
},
|
|
582
|
+
deps: ['AuthenticationService'],
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
provide: 'RecoveryPassword',
|
|
586
|
+
useFactory: (authenticationService) => {
|
|
587
|
+
return new RecoveryPassword(authenticationService);
|
|
588
|
+
},
|
|
589
|
+
deps: ['AuthenticationService'],
|
|
590
|
+
},
|
|
591
|
+
], imports: [[AngularFireModule]] });
|
|
592
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
|
|
593
|
+
type: NgModule,
|
|
594
|
+
args: [{
|
|
595
|
+
imports: [AngularFireModule],
|
|
596
|
+
providers: [
|
|
597
|
+
{
|
|
598
|
+
provide: 'Authentication',
|
|
599
|
+
useFactory: (authenticationService, userRepository) => {
|
|
600
|
+
return new Authentication(authenticationService, userRepository);
|
|
601
|
+
},
|
|
602
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
provide: 'AuthenticationService',
|
|
606
|
+
useFactory: (angularFireAuth) => {
|
|
607
|
+
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
608
|
+
},
|
|
609
|
+
deps: [AngularFireAuth],
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
provide: 'Register',
|
|
613
|
+
useFactory: (registerService, userRepository) => {
|
|
614
|
+
return new Register(registerService, userRepository);
|
|
615
|
+
},
|
|
616
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
provide: 'RegisterService',
|
|
620
|
+
useFactory: (angularFireAuth) => {
|
|
621
|
+
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
622
|
+
},
|
|
623
|
+
deps: [AngularFireAuth],
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
provide: 'SignOut',
|
|
627
|
+
useFactory: (authenticationService) => {
|
|
628
|
+
return new SignOut(authenticationService);
|
|
629
|
+
},
|
|
630
|
+
deps: ['AuthenticationService'],
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
provide: 'RecoveryPassword',
|
|
634
|
+
useFactory: (authenticationService) => {
|
|
635
|
+
return new RecoveryPassword(authenticationService);
|
|
636
|
+
},
|
|
637
|
+
deps: ['AuthenticationService'],
|
|
638
|
+
},
|
|
639
|
+
],
|
|
640
|
+
}]
|
|
640
641
|
}] });
|
|
641
642
|
|
|
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
|
-
}]
|
|
643
|
+
class AngularFirestoreModule {
|
|
644
|
+
static initializeApp(options, nameOrConfig) {
|
|
645
|
+
return {
|
|
646
|
+
ngModule: AngularFirestoreModule,
|
|
647
|
+
providers: [
|
|
648
|
+
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
649
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
650
|
+
],
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
655
|
+
AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule] });
|
|
656
|
+
AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
|
|
657
|
+
{
|
|
658
|
+
provide: 'BeautyProfileRepository',
|
|
659
|
+
useFactory: (firestore, userRepository) => {
|
|
660
|
+
return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
661
|
+
},
|
|
662
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
provide: 'Buy2WinRepository',
|
|
666
|
+
useFactory: (firestore) => {
|
|
667
|
+
return new Buy2WinFirestoreRepository(firestore.firestore);
|
|
668
|
+
},
|
|
669
|
+
deps: [AngularFirestore],
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
provide: 'CategoryRepository',
|
|
673
|
+
useFactory: (firestore) => {
|
|
674
|
+
return new CategoryFirestoreRepository(firestore.firestore);
|
|
675
|
+
},
|
|
676
|
+
deps: [AngularFirestore],
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
provide: 'CheckoutRepository',
|
|
680
|
+
useFactory: (firestore) => {
|
|
681
|
+
return new CheckoutFirestoreRepository(firestore.firestore);
|
|
682
|
+
},
|
|
683
|
+
deps: [AngularFirestore],
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
687
|
+
useFactory: (firestore) => {
|
|
688
|
+
return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
689
|
+
},
|
|
690
|
+
deps: [AngularFirestore],
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
provide: 'CouponRepository',
|
|
694
|
+
useFactory: (firestore) => {
|
|
695
|
+
return new CouponFirestoreRepository(firestore.firestore);
|
|
696
|
+
},
|
|
697
|
+
deps: [AngularFirestore],
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
provide: 'EditionRepository',
|
|
701
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
702
|
+
return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
703
|
+
},
|
|
704
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
705
|
+
},
|
|
706
|
+
{
|
|
707
|
+
provide: 'HomeRepository',
|
|
708
|
+
useFactory: (firestore) => {
|
|
709
|
+
return new HomeFirestoreRepository(firestore.firestore);
|
|
710
|
+
},
|
|
711
|
+
deps: [AngularFirestore],
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
provide: 'LeadRepository',
|
|
715
|
+
useFactory: (firestore) => {
|
|
716
|
+
return new LeadFirestoreRepository(firestore.firestore);
|
|
717
|
+
},
|
|
718
|
+
deps: [AngularFirestore],
|
|
719
|
+
},
|
|
720
|
+
{
|
|
721
|
+
provide: 'LegacyOrderRepository',
|
|
722
|
+
useFactory: (firestore) => {
|
|
723
|
+
return new LegacyOrderFirestoreRepository(firestore.firestore);
|
|
724
|
+
},
|
|
725
|
+
deps: [AngularFirestore],
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
provide: 'ShopMenuRepository',
|
|
729
|
+
useFactory: (firestore) => {
|
|
730
|
+
return new ShopMenuFirestoreRepository(firestore.firestore);
|
|
731
|
+
},
|
|
732
|
+
deps: [AngularFirestore],
|
|
733
|
+
},
|
|
734
|
+
{
|
|
735
|
+
provide: 'OrderRepository',
|
|
736
|
+
useFactory: (firestore) => {
|
|
737
|
+
return new OrderFirestoreRepository(firestore.firestore);
|
|
738
|
+
},
|
|
739
|
+
deps: [AngularFirestore],
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
provide: 'PaymentRepository',
|
|
743
|
+
useFactory: (firestore) => {
|
|
744
|
+
return new PaymentFirestoreRepository(firestore.firestore);
|
|
745
|
+
},
|
|
746
|
+
deps: [AngularFirestore],
|
|
747
|
+
},
|
|
748
|
+
{
|
|
749
|
+
provide: 'ProductRepository',
|
|
750
|
+
useFactory: (firestore) => {
|
|
751
|
+
return new ProductFirestoreRepository(firestore.firestore);
|
|
752
|
+
},
|
|
753
|
+
deps: [AngularFirestore],
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
provide: 'SubscriptionPaymentRepository',
|
|
757
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
758
|
+
return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
759
|
+
},
|
|
760
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
provide: 'SubscriptionPlanRepository',
|
|
764
|
+
useFactory: (firestore) => {
|
|
765
|
+
return new SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
766
|
+
},
|
|
767
|
+
deps: [AngularFirestore],
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
provide: 'SubscriptionProductRepository',
|
|
771
|
+
useFactory: (firestore) => {
|
|
772
|
+
return new SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
773
|
+
},
|
|
774
|
+
deps: [AngularFirestore],
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
provide: 'SubscriptionRepository',
|
|
778
|
+
useFactory: (firestore) => {
|
|
779
|
+
return new SubscriptionFirestoreRepository(firestore.firestore);
|
|
780
|
+
},
|
|
781
|
+
deps: [AngularFirestore],
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
provide: 'UserRepository',
|
|
785
|
+
useFactory: (firestore) => {
|
|
786
|
+
return new UserFirestoreRepository(firestore.firestore);
|
|
787
|
+
},
|
|
788
|
+
deps: [AngularFirestore],
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
provide: 'UserAddressRepository',
|
|
792
|
+
useFactory: (firestore, userRepository) => {
|
|
793
|
+
return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
794
|
+
},
|
|
795
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
provide: 'UserPaymentMethodRepository',
|
|
799
|
+
useFactory: (firestore, userRepository) => {
|
|
800
|
+
return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
801
|
+
},
|
|
802
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
provide: 'VariantRepository',
|
|
806
|
+
useFactory: (firestore, productRepository) => {
|
|
807
|
+
return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
808
|
+
},
|
|
809
|
+
deps: [AngularFirestore, 'ProductRepository'],
|
|
810
|
+
},
|
|
811
|
+
], imports: [[AngularFireModule]] });
|
|
812
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
813
|
+
type: NgModule,
|
|
814
|
+
args: [{
|
|
815
|
+
imports: [AngularFireModule],
|
|
816
|
+
providers: [
|
|
817
|
+
{
|
|
818
|
+
provide: 'BeautyProfileRepository',
|
|
819
|
+
useFactory: (firestore, userRepository) => {
|
|
820
|
+
return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
821
|
+
},
|
|
822
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
provide: 'Buy2WinRepository',
|
|
826
|
+
useFactory: (firestore) => {
|
|
827
|
+
return new Buy2WinFirestoreRepository(firestore.firestore);
|
|
828
|
+
},
|
|
829
|
+
deps: [AngularFirestore],
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
provide: 'CategoryRepository',
|
|
833
|
+
useFactory: (firestore) => {
|
|
834
|
+
return new CategoryFirestoreRepository(firestore.firestore);
|
|
835
|
+
},
|
|
836
|
+
deps: [AngularFirestore],
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
provide: 'CheckoutRepository',
|
|
840
|
+
useFactory: (firestore) => {
|
|
841
|
+
return new CheckoutFirestoreRepository(firestore.firestore);
|
|
842
|
+
},
|
|
843
|
+
deps: [AngularFirestore],
|
|
844
|
+
},
|
|
845
|
+
{
|
|
846
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
847
|
+
useFactory: (firestore) => {
|
|
848
|
+
return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
849
|
+
},
|
|
850
|
+
deps: [AngularFirestore],
|
|
851
|
+
},
|
|
852
|
+
{
|
|
853
|
+
provide: 'CouponRepository',
|
|
854
|
+
useFactory: (firestore) => {
|
|
855
|
+
return new CouponFirestoreRepository(firestore.firestore);
|
|
856
|
+
},
|
|
857
|
+
deps: [AngularFirestore],
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
provide: 'EditionRepository',
|
|
861
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
862
|
+
return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
863
|
+
},
|
|
864
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
provide: 'HomeRepository',
|
|
868
|
+
useFactory: (firestore) => {
|
|
869
|
+
return new HomeFirestoreRepository(firestore.firestore);
|
|
870
|
+
},
|
|
871
|
+
deps: [AngularFirestore],
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
provide: 'LeadRepository',
|
|
875
|
+
useFactory: (firestore) => {
|
|
876
|
+
return new LeadFirestoreRepository(firestore.firestore);
|
|
877
|
+
},
|
|
878
|
+
deps: [AngularFirestore],
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
provide: 'LegacyOrderRepository',
|
|
882
|
+
useFactory: (firestore) => {
|
|
883
|
+
return new LegacyOrderFirestoreRepository(firestore.firestore);
|
|
884
|
+
},
|
|
885
|
+
deps: [AngularFirestore],
|
|
886
|
+
},
|
|
887
|
+
{
|
|
888
|
+
provide: 'ShopMenuRepository',
|
|
889
|
+
useFactory: (firestore) => {
|
|
890
|
+
return new ShopMenuFirestoreRepository(firestore.firestore);
|
|
891
|
+
},
|
|
892
|
+
deps: [AngularFirestore],
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
provide: 'OrderRepository',
|
|
896
|
+
useFactory: (firestore) => {
|
|
897
|
+
return new OrderFirestoreRepository(firestore.firestore);
|
|
898
|
+
},
|
|
899
|
+
deps: [AngularFirestore],
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
provide: 'PaymentRepository',
|
|
903
|
+
useFactory: (firestore) => {
|
|
904
|
+
return new PaymentFirestoreRepository(firestore.firestore);
|
|
905
|
+
},
|
|
906
|
+
deps: [AngularFirestore],
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
provide: 'ProductRepository',
|
|
910
|
+
useFactory: (firestore) => {
|
|
911
|
+
return new ProductFirestoreRepository(firestore.firestore);
|
|
912
|
+
},
|
|
913
|
+
deps: [AngularFirestore],
|
|
914
|
+
},
|
|
915
|
+
{
|
|
916
|
+
provide: 'SubscriptionPaymentRepository',
|
|
917
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
918
|
+
return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
919
|
+
},
|
|
920
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
921
|
+
},
|
|
922
|
+
{
|
|
923
|
+
provide: 'SubscriptionPlanRepository',
|
|
924
|
+
useFactory: (firestore) => {
|
|
925
|
+
return new SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
926
|
+
},
|
|
927
|
+
deps: [AngularFirestore],
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
provide: 'SubscriptionProductRepository',
|
|
931
|
+
useFactory: (firestore) => {
|
|
932
|
+
return new SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
933
|
+
},
|
|
934
|
+
deps: [AngularFirestore],
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
provide: 'SubscriptionRepository',
|
|
938
|
+
useFactory: (firestore) => {
|
|
939
|
+
return new SubscriptionFirestoreRepository(firestore.firestore);
|
|
940
|
+
},
|
|
941
|
+
deps: [AngularFirestore],
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
provide: 'UserRepository',
|
|
945
|
+
useFactory: (firestore) => {
|
|
946
|
+
return new UserFirestoreRepository(firestore.firestore);
|
|
947
|
+
},
|
|
948
|
+
deps: [AngularFirestore],
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
provide: 'UserAddressRepository',
|
|
952
|
+
useFactory: (firestore, userRepository) => {
|
|
953
|
+
return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
954
|
+
},
|
|
955
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
provide: 'UserPaymentMethodRepository',
|
|
959
|
+
useFactory: (firestore, userRepository) => {
|
|
960
|
+
return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
961
|
+
},
|
|
962
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
provide: 'VariantRepository',
|
|
966
|
+
useFactory: (firestore, productRepository) => {
|
|
967
|
+
return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
968
|
+
},
|
|
969
|
+
deps: [AngularFirestore, 'ProductRepository'],
|
|
970
|
+
},
|
|
971
|
+
],
|
|
972
|
+
}]
|
|
972
973
|
}] });
|
|
973
974
|
|
|
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
|
-
}]
|
|
975
|
+
class AngularConnectModule {
|
|
976
|
+
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
977
|
+
return {
|
|
978
|
+
ngModule: AngularConnectModule,
|
|
979
|
+
providers: [
|
|
980
|
+
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
981
|
+
...(isNil(options) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options }]),
|
|
982
|
+
...(isNil(options) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
983
|
+
],
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
988
|
+
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule] });
|
|
989
|
+
AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
|
|
990
|
+
AuthService,
|
|
991
|
+
CartService,
|
|
992
|
+
CheckoutService,
|
|
993
|
+
CheckoutSubscriptionService,
|
|
994
|
+
CouponService,
|
|
995
|
+
HomeShopService,
|
|
996
|
+
OrderService,
|
|
997
|
+
], imports: [[AngularFireModule, AngularFirestoreModule]] });
|
|
998
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
999
|
+
type: NgModule,
|
|
1000
|
+
args: [{
|
|
1001
|
+
imports: [AngularFireModule, AngularFirestoreModule],
|
|
1002
|
+
providers: [
|
|
1003
|
+
AuthService,
|
|
1004
|
+
CartService,
|
|
1005
|
+
CheckoutService,
|
|
1006
|
+
CheckoutSubscriptionService,
|
|
1007
|
+
CouponService,
|
|
1008
|
+
HomeShopService,
|
|
1009
|
+
OrderService,
|
|
1010
|
+
],
|
|
1011
|
+
}]
|
|
1011
1012
|
}] });
|
|
1012
1013
|
|
|
1013
|
-
/**
|
|
1014
|
-
* Generated bundle index. Do not edit.
|
|
1014
|
+
/**
|
|
1015
|
+
* Generated bundle index. Do not edit.
|
|
1015
1016
|
*/
|
|
1016
1017
|
|
|
1017
1018
|
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService };
|