@infrab4a/connect-angular 3.4.0-beta.0 → 3.4.0-beta.10

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.
@@ -11,7 +11,7 @@ export declare class AngularConnectModule {
11
11
  firebase: FirebaseOptions;
12
12
  elasticSearch: AxiosElasticSearchConfig;
13
13
  hasura: HasuraGraphQLOptions;
14
- apiUrl: string;
14
+ backendUrl: string;
15
15
  }, nameOrConfig?: string | FirebaseAppConfig): ModuleWithProviders<AngularFireModule>;
16
16
  static ɵfac: i0.ɵɵFactoryDeclaration<AngularConnectModule, never>;
17
17
  static ɵmod: i0.ɵɵNgModuleDeclaration<AngularConnectModule, never, [typeof i1.AngularFireModule, typeof i2.AngularFirestoreModule, typeof i3.AngularHasuraGraphQLModule], never>;
@@ -390,7 +390,7 @@
390
390
  }] }];
391
391
  } });
392
392
 
393
- var API_URL = 'API_URL';
393
+ var BACKEND_URL = 'BACKEND_URL';
394
394
 
395
395
  var DEFAULT_SHOP = 'DEFAULT_SHOP';
396
396
 
@@ -1223,49 +1223,101 @@
1223
1223
  } });
1224
1224
 
1225
1225
  var ShippingService = /** @class */ (function () {
1226
- function ShippingService(http) {
1226
+ function ShippingService(http, apiUrl, homeService) {
1227
1227
  this.http = http;
1228
+ this.apiUrl = apiUrl;
1229
+ this.homeService = homeService;
1228
1230
  }
1229
- ShippingService.prototype.getMensShippingMethods = function (zip, weightGrams, totalPrice, personId, subscriptionPlan) {
1230
- return this.http.get(API_URL + "/open/checkshippingcompany?personId=" + personId + "&postalCode=" + zip + "&weightGrams=" + weightGrams)
1231
- .pipe(operators.map(function (data) { return data.result; }), operators.map(function (shippingMethods) {
1232
- var shippingMethodsResponse = [];
1231
+ ShippingService.prototype.getShippingMethods = function (shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
1232
+ var _this = this;
1233
+ return rxjs.combineLatest([
1234
+ this.homeService.getHomeData(),
1235
+ this.http.get(this.apiUrl + "open/checkshippingcompany?personId=" + personId + "&postalCode=" + zip + "&weightGrams=" + weightGrams)
1236
+ ])
1237
+ .pipe(operators.map(function (_a) {
1238
+ var _b = __read(_a, 2), datas = _b[0], shippingMethodsResponse = _b[1];
1239
+ var shippingMethods = shippingMethodsResponse.result;
1233
1240
  if (!shippingMethods.length)
1234
1241
  return [];
1242
+ shippingMethods = shippingMethods.map(function (s) {
1243
+ if (s.ShippingCompanyName == 'Same Day EG')
1244
+ s.ShippingCompanyName = 'Same Day';
1245
+ else
1246
+ return s;
1247
+ });
1248
+ var datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
1249
+ if (_this.isHolidays(datasSameDayNotAvaliable)) {
1250
+ shippingMethods = shippingMethods.filter(function (method) { return method.ShippingCompanyName !== 'Same Day'; });
1251
+ }
1235
1252
  if (totalPrice >= 200) {
1236
- return shippingMethods.map(function (s) {
1253
+ shippingMethods = shippingMethods.map(function (s) {
1237
1254
  if (s.serviceName !== 'Same Day')
1238
1255
  return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1239
1256
  else
1240
1257
  return s;
1241
1258
  });
1242
1259
  }
1243
- if (subscriptionPlan && subscriptionPlan == 'SELECT') {
1244
- return shippingMethods.map(function (s) {
1245
- if (s.serviceName !== 'Same Day')
1246
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1260
+ if (shop == i1$1.Shops.GLAMSHOP)
1261
+ return shippingMethods;
1262
+ if (_this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
1263
+ shippingMethods = shippingMethods.map(function (s) {
1264
+ if (s.serviceName == 'Same Day')
1265
+ return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
1247
1266
  else
1248
- return s;
1267
+ return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1249
1268
  });
1250
1269
  }
1251
- if (subscriptionPlan && subscriptionPlan == 'PRIME') {
1252
- return shippingMethods.map(function (s) {
1253
- if (s.serviceName !== 'Same Day')
1254
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
1255
- else
1256
- return s;
1270
+ if (_this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
1271
+ shippingMethods = shippingMethods.map(function (s) {
1272
+ return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
1257
1273
  });
1258
1274
  }
1259
- return shippingMethodsResponse;
1275
+ return shippingMethods;
1260
1276
  }));
1261
1277
  };
1278
+ ShippingService.prototype.isFreeShippingBySubscription = function (shop, subscriptionPlan) {
1279
+ if (!subscriptionPlan)
1280
+ return false;
1281
+ if (shop == i1$1.Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
1282
+ return true;
1283
+ }
1284
+ return false;
1285
+ };
1286
+ ShippingService.prototype.isHalfShippingBySubscription = function (shop, subscriptionPlan) {
1287
+ if (!subscriptionPlan)
1288
+ return false;
1289
+ if (shop == i1$1.Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
1290
+ return true;
1291
+ }
1292
+ if (shop == i1$1.Shops.GLAMSHOP && subscriptionPlan) {
1293
+ return true;
1294
+ }
1295
+ return false;
1296
+ };
1297
+ ShippingService.prototype.isHolidays = function (datas) {
1298
+ var today = new Date();
1299
+ for (var key in datas) {
1300
+ var start = new Date(today.getFullYear() + "-" + datas[key].beginDate);
1301
+ var end = new Date(today.getFullYear() + "-" + datas[key].endDate);
1302
+ if (start > end)
1303
+ end = new Date(today.getFullYear() + 1 + "-" + datas[key].endDate);
1304
+ if (today >= start && today <= end)
1305
+ return true;
1306
+ }
1307
+ return false;
1308
+ };
1262
1309
  return ShippingService;
1263
1310
  }());
1264
- ShippingService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, deps: [{ token: i1__namespace$3.HttpClient }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1311
+ ShippingService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, deps: [{ token: i1__namespace$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1265
1312
  ShippingService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService });
1266
1313
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, decorators: [{
1267
1314
  type: i0.Injectable
1268
- }], ctorParameters: function () { return [{ type: i1__namespace$3.HttpClient }]; } });
1315
+ }], ctorParameters: function () {
1316
+ return [{ type: i1__namespace$3.HttpClient }, { type: undefined, decorators: [{
1317
+ type: i0.Inject,
1318
+ args: [BACKEND_URL]
1319
+ }] }, { type: HomeShopService }];
1320
+ } });
1269
1321
 
1270
1322
  var AngularFirebaseAuthModule = /** @class */ (function () {
1271
1323
  function AngularFirebaseAuthModule() {
@@ -1858,7 +1910,7 @@
1858
1910
  AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
1859
1911
  return {
1860
1912
  ngModule: AngularConnectModule,
1861
- providers: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((i1$1.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i1$1.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]))), __read((i1$1.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig }]))), __read((i1$1.isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]))), __read((i1$1.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]))), __read((i1$1.isNil(options === null || options === void 0 ? void 0 : options.apiUrl) ? [] : [{ provide: API_URL, useValue: options.apiUrl }]))),
1913
+ providers: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((i1$1.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i1$1.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]))), __read((i1$1.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig }]))), __read((i1$1.isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]))), __read((i1$1.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]))), __read((i1$1.isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]))),
1862
1914
  };
1863
1915
  };
1864
1916
  return AngularConnectModule;