@colijnit/catalog 255.1.7 → 255.1.8

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.
@@ -30,8 +30,8 @@
30
30
  function Version() {
31
31
  this.name = "@colijnit/catalog";
32
32
  this.description = "iOne Catalog module based on Angular 12";
33
- this.symVer = "255.1.7";
34
- this.publishDate = "4-9-2024 12:05:35";
33
+ this.symVer = "255.1.8";
34
+ this.publishDate = "16-9-2024 17:31:10";
35
35
  }
36
36
  return Version;
37
37
  }());
@@ -5852,14 +5852,82 @@
5852
5852
  }
5853
5853
  };
5854
5854
  CatalogExternalSourceComponent.prototype.receiveMessage = function (event) {
5855
- //if(event.origin === this.externalSource.url) {
5856
- if (typeof event.data === 'string') {
5857
- this.iFrameFeedbackReceived.emit(event.data);
5858
- }
5855
+ if (this._externalSource.type !== '3DIMERCE')
5856
+ if (typeof event.data === 'string') {
5857
+ this.iFrameFeedbackReceived.emit(event.data);
5858
+ }
5859
+ else {
5860
+ this.iFrameFeedbackReceived.emit(JSON.stringify(event.data));
5861
+ }
5859
5862
  else {
5860
- this.iFrameFeedbackReceived.emit(JSON.stringify(event.data));
5863
+ if (typeof event.data && event.data['hash'] !== undefined) {
5864
+ this.fetchAndCombineThreeDimerseData(event.data['hash']);
5865
+ }
5861
5866
  }
5862
- //}
5867
+ };
5868
+ CatalogExternalSourceComponent.prototype.fetchAndCombineThreeDimerseData = function (hash) {
5869
+ return __awaiter(this, void 0, void 0, function () {
5870
+ var customerName, configurationUrl, priceDataUrl, apiResponses, configurationResponse, priceDataResponse, configurationData_1, priceData_1, resultObject, error_1;
5871
+ return __generator(this, function (_a) {
5872
+ switch (_a.label) {
5873
+ case 0:
5874
+ customerName = 'Linteloo';
5875
+ configurationUrl = this._externalSource.domain + '/configurationData/' + hash;
5876
+ console.log('configurationUrl');
5877
+ priceDataUrl = this._externalSource.domain + '/rules/api/' + customerName.toLowerCase() + '/' + hash;
5878
+ console.log('priceDataUrl');
5879
+ _a.label = 1;
5880
+ case 1:
5881
+ _a.trys.push([1, 3, , 4]);
5882
+ return [4 /*yield*/, Promise.all([
5883
+ this.fetchJsonFile(configurationUrl),
5884
+ this.fetchJsonFile(priceDataUrl)
5885
+ ])];
5886
+ case 2:
5887
+ apiResponses = _a.sent();
5888
+ configurationResponse = apiResponses[0];
5889
+ priceDataResponse = apiResponses[1];
5890
+ if (configurationResponse && configurationResponse.ok) {
5891
+ configurationResponse.json().then(function (result) {
5892
+ console.log(result);
5893
+ configurationData_1 = result;
5894
+ }).catch(function (e) {
5895
+ console.log(e);
5896
+ configurationData_1 = {};
5897
+ });
5898
+ }
5899
+ if (priceDataResponse && priceDataResponse.ok) {
5900
+ priceDataResponse.json().then(function (result) {
5901
+ console.log(result);
5902
+ priceData_1 = result;
5903
+ }).catch(function (e) {
5904
+ console.log(e);
5905
+ priceData_1 = {};
5906
+ });
5907
+ }
5908
+ resultObject = {};
5909
+ resultObject['configuratie-data'] = configurationData_1;
5910
+ resultObject['prijs-data'] = priceData_1;
5911
+ this.iFrameFeedbackReceived.emit(JSON.stringify(resultObject));
5912
+ return [3 /*break*/, 4];
5913
+ case 3:
5914
+ error_1 = _a.sent();
5915
+ console.error('Error fetching data:', error_1);
5916
+ return [3 /*break*/, 4];
5917
+ case 4: return [2 /*return*/];
5918
+ }
5919
+ });
5920
+ });
5921
+ };
5922
+ CatalogExternalSourceComponent.prototype.fetchJsonFile = function (url) {
5923
+ return __awaiter(this, void 0, void 0, function () {
5924
+ return __generator(this, function (_a) {
5925
+ switch (_a.label) {
5926
+ case 0: return [4 /*yield*/, fetch(url)];
5927
+ case 1: return [2 /*return*/, _a.sent()];
5928
+ }
5929
+ });
5930
+ });
5863
5931
  };
5864
5932
  CatalogExternalSourceComponent.prototype.iframeLoaded = function (event) {
5865
5933
  if (this.username && this.password) {
@@ -5905,7 +5973,7 @@
5905
5973
  this.showCatalog = true;
5906
5974
  return [3 /*break*/, 3];
5907
5975
  case 2:
5908
- if (this._externalSource.type !== externalCatalogTypes_enum.ExternalCatalogTypes.Webshop) {
5976
+ if (this._externalSource.type !== externalCatalogTypes_enum.ExternalCatalogTypes.Webshop && this._externalSource.type !== externalCatalogTypes_enum.ExternalCatalogTypes.ThreeDimerse) {
5909
5977
  this.externalUrl = this._externalCatalogStartupInfo.apiUrl;
5910
5978
  if (this._externalSource.type === externalCatalogTypes_enum.ExternalCatalogTypes.Vadain) {
5911
5979
  this.username = this._externalCatalogStartupInfo.username;