simpo-component-library 2.0.14 → 2.0.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -100,7 +100,11 @@ export class StorageServiceService {
100
100
  if (this.router.url.includes('cart'))
101
101
  return;
102
102
  const userDetails = this.getUser();
103
- console.log(this.getCartProduct(userDetails?.userId));
103
+ this.getCartProduct(userDetails?.userId).then((products) => {
104
+ console.log("Merged products:", products);
105
+ }).catch((error) => {
106
+ console.error("Error:", error);
107
+ });
104
108
  if (!!userDetails) {
105
109
  this.eventService.showLoadingScreen.emit(true);
106
110
  const request = forkJoin([
@@ -160,46 +164,45 @@ export class StorageServiceService {
160
164
  const transaction = this.database.transaction(this.cartCollectionName, "readwrite");
161
165
  return await transaction.objectStore(this.cartCollectionName).getAll();
162
166
  }
163
- getCartProduct(userId) {
164
- // const request = forkJoin([
165
- // this.getUserCart(),
166
- // this.restService.getUserItems(userId, "CART")
167
- // ]);
168
- // request.subscribe((response: any) => {
169
- // const serverDBProduct = response?.[1].data?.[0]?.orderedItems ?? []
170
- // response[0].onsuccess = (cartData: any) => {
171
- // const indexDBProduct = cartData.target.result as unknown as OrderedItems[];
172
- // console.log("cart product is", serverDBProduct, indexDBProduct);
173
- // }
174
- // })
175
- this.getUserCart().then((cartResponse) => {
176
- cartResponse.onsuccess = (cartData) => {
177
- const indexDBProduct = cartData.target.result;
178
- if (userId) {
179
- return this.restService.getUserItems(userId, "CART").toPromise().then((response) => {
180
- const serverDBProduct = response?.data?.[0]?.orderedItems ?? [];
181
- for (let localProduct of indexDBProduct) {
182
- let productFound = false;
183
- for (let serverProduct of serverDBProduct) {
184
- if (serverProduct.varientId === localProduct.varientId) {
185
- serverProduct.quantity += localProduct.quantity;
186
- productFound = true;
167
+ async getCartProduct(userId) {
168
+ try {
169
+ const cartResponse = await this.getUserCart();
170
+ return new Promise((resolve, reject) => {
171
+ cartResponse.onsuccess = async (cartData) => {
172
+ const indexDBProduct = cartData.target.result;
173
+ if (userId) {
174
+ try {
175
+ const response = await this.restService.getUserItems(userId, "CART").toPromise();
176
+ const serverDBProduct = response?.data?.[0]?.orderedItems ?? [];
177
+ for (let localProduct of indexDBProduct) {
178
+ let productFound = false;
179
+ for (let serverProduct of serverDBProduct) {
180
+ if (serverProduct.varientId === localProduct.varientId) {
181
+ serverProduct.quantity += localProduct.quantity;
182
+ productFound = true;
183
+ }
184
+ }
185
+ if (!productFound) {
186
+ serverDBProduct.push(localProduct);
187
187
  }
188
188
  }
189
- if (!productFound) {
190
- serverDBProduct.push(localProduct);
191
- }
189
+ resolve(serverDBProduct);
192
190
  }
193
- return serverDBProduct;
194
- });
195
- }
196
- else {
197
- return indexDBProduct;
198
- }
199
- };
200
- }).catch((error) => {
191
+ catch (error) {
192
+ console.error("Error in API call:", error);
193
+ reject(error);
194
+ }
195
+ }
196
+ else {
197
+ resolve(indexDBProduct);
198
+ }
199
+ };
200
+ });
201
+ }
202
+ catch (error) {
201
203
  console.error("Error retrieving cart:", error);
202
- });
204
+ throw error;
205
+ }
203
206
  }
204
207
  addProductToCart(product) {
205
208
  const transaction = this.database.transaction(this.cartCollectionName, "readwrite");
@@ -291,4 +294,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImpor
291
294
  providedIn: 'root'
292
295
  }]
293
296
  }], ctorParameters: () => [{ type: i1.EventsService }, { type: i2.CookieService }, { type: i3.RestService }, { type: i4.Router }] });
294
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmFnZS5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvc2ltcG8tdWkvc3JjL2xpYi9zZXJ2aWNlcy9zdG9yYWdlLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBVSxNQUFNLGVBQWUsQ0FBQztBQUtuRCxPQUFPLEVBQUUsUUFBUSxF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AgY2FydFJlc3BvbnNlLm9uc3VjY2VzcyA9IChjYXJ0RGF0YTogYW55KSA9PiB7XHJcbiAgICAgICAgY29uc3QgaW5kZXhEQlByb2R1Y3QgPSBjYXJ0RGF0YS50YXJnZXQucmVzdWx0IGFzIHVua25vd24gYXMgT3JkZXJlZEl0ZW1zW107XHJcblxyXG4gICAgICAgIGlmICh1c2VySWQpIHtcclxuICAgICAgICAgIHJldHVybiB0aGlzLnJlc3RTZXJ2aWNlLmdldFVzZXJJdGVtcyh1c2VySWQsIFwiQ0FSVFwiKS50b1Byb21pc2UoKS50aGVuKChyZXNwb25zZTogYW55KSA9PiB7XHJcbiAgICAgICAgICAgIGNvbnN0IHNlcnZlckRCUHJvZHVjdCA9IHJlc3BvbnNlPy5kYXRhPy5bMF0/Lm9yZGVyZWRJdGVtcyA/PyBbXTtcclxuXHJcbiAgICAgICAgICAgIGZvciAobGV0IGxvY2FsUHJvZHVjdCBvZiBpbmRleERCUHJvZHVjdCkge1xyXG4gICAgICAgICAgICAgIGxldCBwcm9kdWN0Rm91bmQgPSBmYWxzZTtcclxuICAgICAgICAgICAgICBmb3IgKGxldCBzZXJ2ZXJQcm9kdWN0IG9mIHNlcnZlckRCUHJvZHVjdCkge1xyXG4gICAgICAgICAgICAgICAgaWYgKHNlcnZlclByb2R1Y3QudmFyaWVudElkID09PSBsb2NhbFByb2R1Y3QudmFyaWVudElkKSB7XHJcbiAgICAgICAgICAgICAgICAgIHNlcnZlclByb2R1Y3QucXVhbnRpdHkgKz0gbG9jYWxQcm9kdWN0LnF1YW50aXR5O1xyXG4gICAgICAgICAgICAgICAgICBwcm9kdWN0Rm91bmQgPSB0cnVlO1xyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICBpZiAoIXByb2R1Y3RGb3VuZCkge1xyXG4gICAgICAgICAgICAgICAgc2VydmVyREJQcm9kdWN0LnB1c2gobG9jYWxQcm9kdWN0KTtcclxuICAgICAgICA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REJQcm9kdWN0KSB7XHJcbiAgICAgICAgICAgICAgICAgIGlmIChzZXJ2ZXJQcm9kdWN0LnZhcmllbnRJZCA9PT0gbG9jYWxQcm9kdWN0LnZhcmllbnRJZCkge1xyXG4gICAgICAgICAgICAgICAgICAgIHNlcnZlclByb2R1Y3QucXVhbnRpdHkgKz0gbG9jYWxQcm9kdWN0LnF1YW50aXR5O1xyXG4gICAgICAgICAgICAgICAgICAgIHByb2R1Y3RGb3VuZCA9IHRydWU7XHJcbiAgICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIH1cclxuICAgICAgICAgICAgICAgIGlmICghcHJvZHVjdEZvdW5kKSB7XHJcbiAgICAgICAgICAgICAgICAgIHNlcnZlckRCUHJvZHVjdC5wdXNoKGxvY2FsUHJvZHVjdCk7XHJcbiAgICAgICAgICAgICAgICB9XHJcbiAgICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgICByZXNvbHZlKHNlcnZlckRCUHJvZHVjdCk7XHJcbiAgICAgICAgICAgIH0gY2F0Y2ggKGVycm9yKSB7XHJcbiAgICAgICAgICAgICAgY29uc29sZS5lcnJvcihcIkVycm9yIGluIEFQSSBjYWxsOlwiLCBlcnJvcik7XHJcbiAgICAgICAgICAgICAgcmVqZWN0KGVycm9yKTtcclxuICAgICAgICAgICAgfVxyXG4gICAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgcmVzb2x2ZShpbmRleERCUHJvZHVjdCk7XHJcbiAgICAgICAgICB9XHJcbiAgICAgICAgfTtcclxuICAgICAgfSk7XHJcbiAgICB9IGNhdGNoIChlcnJvcikge1xyXG4gICAgICBjb25zb2xlLmVycm9yKFwiRXJyb3IgcmV0cmlldmluZyBjYXJ0OlwiLCBlcnJvcik7XHJcbiAgICAgIHRocm93IGVycm9yO1xyXG4gICAgfVxyXG4gIH1cclxuXHJcblxyXG4gIGFkZFByb2R1Y3RUb0NhcnQocHJvZHVjdDogT3JkZXJlZEl0ZW1zKSB7X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hbWUsICdyZWFkd3JpdGUnKVxyXG4gIC8vICAgICAgICAgLm9iamVjdFN0b3JlKHRoaXMub2JqZWN0U3RvcmFnZU5hbWUpXHJcbiAgLy8gICAgICAgICAuY2xlYXIoKTtcclxuXHJcbiAgLy8gICAgICAgcmVxdWVzdC5vbnN1Y2Nlc3MgPSBhd2FpdCBmdW5jdGlvbiAoZXZlbnQ6IGFueSkge1xyXG5cclxuICAvLyAgICAgICAgIGlmIChldmVudC50YXJnZXQucmVzdWx0KSB7XHJcbiAgLy8gICAgICAgICAgIHJlc29sdmUoZXZlbnQucmVzdWx0KTtcclxuICAvLyAgICAgICAgIH0gZWxzZSB7XHJcbiAgLy8gICAgICAgICAgIHJlc29sdmUoJ1NVQ0NFU1MnKTtcclxuICAvLyAgICAgICAgIH1cclxuICAvLyAgICAgICB9O1xyXG4gIC8vICAgICAgIHJlcXVlc3Qub25lcnJvciA9IGF3YWl0IGZ1bmN0aW9uIChfZXZlbnQpIHtcclxuICAvLyAgICAgICAgIHJlamVjdChcIk5vIGRhdGFcIik7XHJcbiAgLy8gICAgICAgfVxyXG4gIC8vICAgICB9XHJcbiAgLy8gICB9KTtcclxuICAvLyB9XHJcbn1cclxuIl19
@@ -3696,7 +3696,11 @@ class StorageServiceService {
3696
3696
  if (this.router.url.includes('cart'))
3697
3697
  return;
3698
3698
  const userDetails = this.getUser();
3699
- console.log(this.getCartProduct(userDetails?.userId));
3699
+ this.getCartProduct(userDetails?.userId).then((products) => {
3700
+ console.log("Merged products:", products);
3701
+ }).catch((error) => {
3702
+ console.error("Error:", error);
3703
+ });
3700
3704
  if (!!userDetails) {
3701
3705
  this.eventService.showLoadingScreen.emit(true);
3702
3706
  const request = forkJoin([
@@ -3756,46 +3760,45 @@ class StorageServiceService {
3756
3760
  const transaction = this.database.transaction(this.cartCollectionName, "readwrite");
3757
3761
  return await transaction.objectStore(this.cartCollectionName).getAll();
3758
3762
  }
3759
- getCartProduct(userId) {
3760
- // const request = forkJoin([
3761
- // this.getUserCart(),
3762
- // this.restService.getUserItems(userId, "CART")
3763
- // ]);
3764
- // request.subscribe((response: any) => {
3765
- // const serverDBProduct = response?.[1].data?.[0]?.orderedItems ?? []
3766
- // response[0].onsuccess = (cartData: any) => {
3767
- // const indexDBProduct = cartData.target.result as unknown as OrderedItems[];
3768
- // console.log("cart product is", serverDBProduct, indexDBProduct);
3769
- // }
3770
- // })
3771
- this.getUserCart().then((cartResponse) => {
3772
- cartResponse.onsuccess = (cartData) => {
3773
- const indexDBProduct = cartData.target.result;
3774
- if (userId) {
3775
- return this.restService.getUserItems(userId, "CART").toPromise().then((response) => {
3776
- const serverDBProduct = response?.data?.[0]?.orderedItems ?? [];
3777
- for (let localProduct of indexDBProduct) {
3778
- let productFound = false;
3779
- for (let serverProduct of serverDBProduct) {
3780
- if (serverProduct.varientId === localProduct.varientId) {
3781
- serverProduct.quantity += localProduct.quantity;
3782
- productFound = true;
3763
+ async getCartProduct(userId) {
3764
+ try {
3765
+ const cartResponse = await this.getUserCart();
3766
+ return new Promise((resolve, reject) => {
3767
+ cartResponse.onsuccess = async (cartData) => {
3768
+ const indexDBProduct = cartData.target.result;
3769
+ if (userId) {
3770
+ try {
3771
+ const response = await this.restService.getUserItems(userId, "CART").toPromise();
3772
+ const serverDBProduct = response?.data?.[0]?.orderedItems ?? [];
3773
+ for (let localProduct of indexDBProduct) {
3774
+ let productFound = false;
3775
+ for (let serverProduct of serverDBProduct) {
3776
+ if (serverProduct.varientId === localProduct.varientId) {
3777
+ serverProduct.quantity += localProduct.quantity;
3778
+ productFound = true;
3779
+ }
3780
+ }
3781
+ if (!productFound) {
3782
+ serverDBProduct.push(localProduct);
3783
3783
  }
3784
3784
  }
3785
- if (!productFound) {
3786
- serverDBProduct.push(localProduct);
3787
- }
3785
+ resolve(serverDBProduct);
3788
3786
  }
3789
- return serverDBProduct;
3790
- });
3791
- }
3792
- else {
3793
- return indexDBProduct;
3794
- }
3795
- };
3796
- }).catch((error) => {
3787
+ catch (error) {
3788
+ console.error("Error in API call:", error);
3789
+ reject(error);
3790
+ }
3791
+ }
3792
+ else {
3793
+ resolve(indexDBProduct);
3794
+ }
3795
+ };
3796
+ });
3797
+ }
3798
+ catch (error) {
3797
3799
  console.error("Error retrieving cart:", error);
3798
- });
3800
+ throw error;
3801
+ }
3799
3802
  }
3800
3803
  addProductToCart(product) {
3801
3804
  const transaction = this.database.transaction(this.cartCollectionName, "readwrite");