simpo-component-library 2.0.13 → 2.0.14

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