simpo-component-library 1.4.15 → 1.4.16

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.
Files changed (30) hide show
  1. package/esm2022/lib/ecommerce/json/user-cart.json +1 -14
  2. package/esm2022/lib/ecommerce/sections/authenticate-user/authenticate-user.component.mjs +13 -10
  3. package/esm2022/lib/ecommerce/sections/cart/cart.component.mjs +2 -2
  4. package/esm2022/lib/ecommerce/sections/featured-products/featured-products.component.mjs +3 -3
  5. package/esm2022/lib/ecommerce/sections/product-desc/product-desc.component.mjs +10 -4
  6. package/esm2022/lib/ecommerce/sections/whislist/whislist.component.mjs +3 -3
  7. package/esm2022/lib/ecommerce/styles/OrderedItems.modal.mjs +3 -8
  8. package/esm2022/lib/ecommerce/styles/cart.modal.mjs +2 -1
  9. package/esm2022/lib/ecommerce/styles/user.modal.mjs +11 -0
  10. package/esm2022/lib/services/cart.service.mjs +86 -69
  11. package/esm2022/lib/services/storage.service.mjs +80 -0
  12. package/fesm2022/simpo-component-library.mjs +188 -99
  13. package/fesm2022/simpo-component-library.mjs.map +1 -1
  14. package/lib/directive/background-directive.d.ts +1 -1
  15. package/lib/directive/button-directive.directive.d.ts +1 -1
  16. package/lib/directive/color.directive.d.ts +1 -1
  17. package/lib/ecommerce/sections/authenticate-user/authenticate-user.component.d.ts +4 -2
  18. package/lib/ecommerce/sections/featured-products/featured-products.component.d.ts +1 -1
  19. package/lib/ecommerce/styles/OrderedItems.modal.d.ts +10 -14
  20. package/lib/ecommerce/styles/cart.modal.d.ts +3 -18
  21. package/lib/ecommerce/styles/user.modal.d.ts +38 -0
  22. package/lib/sections/pricing-section/pricing-section.component.d.ts +1 -1
  23. package/lib/services/cart.service.d.ts +9 -9
  24. package/lib/services/storage.service.d.ts +28 -0
  25. package/package.json +1 -1
  26. package/simpo-component-library-1.4.16.tgz +0 -0
  27. package/simpo-component-library-1.4.12.tgz +0 -0
  28. package/simpo-component-library-1.4.13.tgz +0 -0
  29. package/simpo-component-library-1.4.14.tgz +0 -0
  30. package/simpo-component-library-1.4.15.tgz +0 -0
@@ -14,10 +14,12 @@ import * as i1 from '@angular/platform-browser';
14
14
  import { map } from 'rxjs';
15
15
  import * as i1$1 from '@angular/common/http';
16
16
  import * as i2$2 from '@angular/router';
17
+ import * as i4 from '@simpo-ui/services/storage.service';
17
18
  import * as i2$3 from '@angular/material/snack-bar';
18
19
  import * as i2$4 from 'ngx-skeleton-loader';
19
20
  import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
20
21
  import * as mapboxgl from 'mapbox-gl';
22
+ import { v1 } from 'uuid';
21
23
  import * as i8 from 'ngx-image-zoom';
22
24
  import { NgxImageZoomModule } from 'ngx-image-zoom';
23
25
  import * as i8$1 from '@angular/material/slider';
@@ -2985,18 +2987,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImpor
2985
2987
  }] } });
2986
2988
 
2987
2989
  var orderedItems$1 = [
2988
- {
2989
- itemId: "1ef50089-2cf0-6bdf-8ea9-b51e0a912f33",
2990
- businessId: "21",
2991
- itemName: "Anime T-Shirt",
2992
- brandName: "Excee",
2993
- imgUrl: "https://dev-beeos.s3.amazonaws.com/library-media/291611c1707983189501product-details-2.jpg.jpg",
2994
- price: 120,
2995
- itemTax: 10,
2996
- quantity: 2,
2997
- discountedPrice: 20,
2998
- taxAfterDiscount: 10
2999
- }
3000
2990
  ];
3001
2991
  var cartType$1 = "CART";
3002
2992
  var billdetails$1 = {
@@ -3234,11 +3224,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImpor
3234
3224
  }], ctorParameters: () => [{ type: RestService }, { type: i2$2.Router }, { type: i3.MatDialogRef }] });
3235
3225
 
3236
3226
  class AuthenticateUserComponent {
3237
- constructor(matData, restService, router, matDialog, dialogRef) {
3227
+ constructor(matData, restService, router, matDialog, storageService, dialogRef) {
3238
3228
  this.matData = matData;
3239
3229
  this.restService = restService;
3240
3230
  this.router = router;
3241
3231
  this.matDialog = matDialog;
3232
+ this.storageService = storageService;
3242
3233
  this.dialogRef = dialogRef;
3243
3234
  // @Input() index? : number;
3244
3235
  // @Input() edit? : boolean;
@@ -3274,14 +3265,16 @@ class AuthenticateUserComponent {
3274
3265
  verifyOTP() {
3275
3266
  this.restService.verifyOTP(this.mobile ?? "", this.otpString).subscribe((response) => {
3276
3267
  // localStorage.setItem("userId", response.userId);
3277
- UserInfo.user = response.data;
3278
- if (UserInfo.user?.contact?.name?.length > 0) {
3268
+ const userDetails = this.storageService.addUser(response.data);
3269
+ if (userDetails.contact?.name?.length > 0) {
3279
3270
  if (this.dialogRef)
3280
3271
  this.dialogRef.close();
3281
3272
  else
3282
3273
  this.router.navigate(['/']);
3283
3274
  }
3284
3275
  else {
3276
+ if (this.dialogRef)
3277
+ this.dialogRef.close();
3285
3278
  this.matDialog.open(UserBasicInfoComponent, {
3286
3279
  height: '50vh',
3287
3280
  width: '40vw',
@@ -3298,7 +3291,7 @@ class AuthenticateUserComponent {
3298
3291
  get isMobile() {
3299
3292
  return window.innerWidth <= 475;
3300
3293
  }
3301
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: AuthenticateUserComponent, deps: [{ token: MAT_DIALOG_DATA, optional: true }, { token: RestService }, { token: i2$2.Router }, { token: i3.MatDialog }, { token: i3.MatDialogRef, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
3294
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: AuthenticateUserComponent, deps: [{ token: MAT_DIALOG_DATA, optional: true }, { token: RestService }, { token: i2$2.Router }, { token: i3.MatDialog }, { token: i4.StorageServiceService }, { token: i3.MatDialogRef, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
3302
3295
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.1.4", type: AuthenticateUserComponent, isStandalone: true, selector: "simpo-authenticate-user", inputs: { data: "data", responseData: "responseData" }, ngImport: i0, template: "<div [style.height.vh]=\"isMobile ? '90' : ''\">\r\n <ng-container [ngSwitch]=\"screen\">\r\n <section style=\"padding: 15px;\"\r\n class=\"d-flex flex-column align-item-center justify-content-center position-relative h-100\"\r\n *ngSwitchCase=\"'LOGIN'\"[ngClass]=\"{'fullSection': isMobile}\">\r\n <h5 class=\"text-center onlyDesktop\">Excee Fashion</h5>\r\n <h2 class=\"text-center\">Welcome</h2>\r\n <p class=\"text-center\">Log or Signup in to your account</p>\r\n <input type=\"number\" placeholder=\"Mobile Number\" [(ngModel)]=\"mobile\">\r\n <p class=\"text-center\">You will receive an SMS verification</p>\r\n\r\n <div class=\"action-btn d-flex flex-column align-item-center justify-content-center\">\r\n <button class=\"btn\" simpoButtonDirective [buttonStyle]=\"data?.action?.buttons[0]?.styles\"\r\n [color]=\"styles?.background?.accentColor\" (click)=\"generateOTP()\">Continue</button>\r\n <div class=\"alternate-opt text-center\" [style.color]=\"data?.styles.background?.accentColor\">Use email\r\n instead</div>\r\n </div>\r\n <div class=\"close-btn onlyDesktop\" (click)=\"close()\">\r\n <mat-icon>close</mat-icon>\r\n </div>\r\n </section>\r\n <section *ngSwitchCase=\"'OTP'\" style=\"padding: 15px;\"\r\n class=\"d-flex flex-column align-item-center justify-content-center position-relative h-100\" [ngClass]=\"{'fullSection': isMobile}\">\r\n <h5 class=\"text-center onlyDesktop\">Excee Fashion</h5>\r\n <h2 class=\"text-center\">Verify OTP</h2>\r\n <p class=\"text-center\">Enter the 6-digit that we have sent via the phone number +{{ countryCode }}{{ mobile\r\n }}</p>\r\n <div class=\"otpContainer\">\r\n <ng-container *ngFor=\"let _ of [].constructor(6); let idx = index\">\r\n <input type=\"number\" class=\"otp\" max=\"1\" [id]=\"'otp_'+idx\" (keyup)=\"move($event, idx)\">\r\n </ng-container>\r\n </div>\r\n\r\n <div class=\"action-btn d-flex flex-column align-item-center justify-content-center\">\r\n <button class=\"btn\" simpoButtonDirective [buttonStyle]=\"data?.action?.buttons[0]?.styles\"\r\n [color]=\"styles?.background?.accentColor\" (click)=\"verifyOTP()\">Continue</button>\r\n <div class=\"alternate-opt text-center\" [style.color]=\"data?.styles.background?.accentColor\"\r\n (click)=\"resendOTP()\">Resend code</div>\r\n </div>\r\n\r\n <div class=\"close-btn onlyDesktop\" (click)=\"close()\">\r\n <mat-icon>close</mat-icon>\r\n </div>\r\n <div class=\"back-btn\" (click)=\"goBack()\">\r\n <mat-icon>keyboard_backspace</mat-icon>\r\n </div>\r\n </section>\r\n </ng-container>\r\n</div>", styles: ["input,button{width:80%!important;margin:10px auto}input{padding:10px}.alternate-opt:hover{text-decoration:underline;cursor:pointer}.close-btn{position:absolute;top:10px;right:10px;cursor:pointer}.otpContainer{display:flex;gap:4px;margin:auto}.otpContainer .otp{border-radius:50%;padding:5px;height:50px;width:50px!important;margin:5px!important;text-align:center}input::-webkit-outer-spin-button,input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}input[type=number]{-moz-appearance:textfield}.back-btn{position:absolute;top:10px;left:10px;cursor:pointer}@media screen and (max-width: 475px){.onlyDesktop{display:none}.text-center{text-align:left!important}button,input{width:100%!important}.fullSection{justify-content:start!important}.action-btn{position:absolute;bottom:50px;width:95%}.action-btn .text-center{text-align:center!important}.otpContainer{margin-top:20px;position:relative;right:10px}}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i5.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i5.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i5.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i2.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: ButtonDirectiveDirective, selector: "[simpoButtonDirective]", inputs: ["buttonStyle", "color", "scrollValue"] }] }); }
3303
3296
  }
3304
3297
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: AuthenticateUserComponent, decorators: [{
@@ -3314,7 +3307,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImpor
3314
3307
  }, {
3315
3308
  type: Inject,
3316
3309
  args: [MAT_DIALOG_DATA]
3317
- }] }, { type: RestService }, { type: i2$2.Router }, { type: i3.MatDialog }, { type: i3.MatDialogRef, decorators: [{
3310
+ }] }, { type: RestService }, { type: i2$2.Router }, { type: i3.MatDialog }, { type: i4.StorageServiceService }, { type: i3.MatDialogRef, decorators: [{
3318
3311
  type: Optional
3319
3312
  }] }], propDecorators: { data: [{
3320
3313
  type: Input
@@ -4678,7 +4671,7 @@ var UserFavourite = {
4678
4671
 
4679
4672
  class OrderedItems {
4680
4673
  constructor(json) {
4681
- this.itemId = json?.["itemId"];
4674
+ this.itemId = json?.["itemId"] ?? v1();
4682
4675
  this.businessId = json?.["businessId"];
4683
4676
  this.itemName = json?.["name"];
4684
4677
  this.brandName = json?.["brandName"];
@@ -4689,83 +4682,164 @@ class OrderedItems {
4689
4682
  this.discountedPrice = json?.["price"]?.["discountedPrice"];
4690
4683
  this.taxAfterDiscount = json?.["taxAfterDiscount"];
4691
4684
  }
4692
- set setQuantity(quantity) {
4693
- this.quantity = quantity;
4685
+ }
4686
+
4687
+ class StorageServiceService {
4688
+ constructor() {
4689
+ this.databaseName = "USER";
4690
+ this.databaseVersion = 1;
4691
+ this.cartCollectionName = "USER_CART";
4692
+ this.favouriteCollectionName = "USER_FAVOURITE";
4693
+ this.userCollectionName = "USER";
4694
+ this.cartCollectionRef = null;
4695
+ this.favouriteCollectionRef = null;
4696
+ this.userCollectionRef = null;
4697
+ this.createDataBase();
4698
+ }
4699
+ async createDataBase() {
4700
+ const request = window.indexedDB.open(this.databaseName, 1);
4701
+ request.onerror = () => { };
4702
+ request.onsuccess = async (event) => {
4703
+ this.database = await event.target.result;
4704
+ };
4705
+ request.onupgradeneeded = (event) => {
4706
+ this.database = event.target.result;
4707
+ this.cartCollectionRef = this.database.createObjectStore(this.cartCollectionName, { keyPath: "itemId" });
4708
+ this.favouriteCollectionRef = this.database.createObjectStore(this.favouriteCollectionName, { keyPath: "itemId" });
4709
+ this.userCollectionRef = this.database.createObjectStore(this.userCollectionName, { keyPath: "userId" });
4710
+ };
4711
+ }
4712
+ // CART SERVICE
4713
+ async getUserCart() {
4714
+ const request = await this.cartCollectionRef?.getAll();
4715
+ return request;
4716
+ }
4717
+ addProductToCart(product) {
4718
+ const transaction = this.database.transaction(this.cartCollectionName, "readwrite");
4719
+ return transaction.objectStore(this.cartCollectionName).put(product);
4720
+ }
4721
+ removeProductFromCart(productId) {
4722
+ const transaction = this.database.transaction(this.cartCollectionName, "readwrite");
4723
+ return transaction.objectStore(this.cartCollectionName).delete(productId);
4724
+ }
4725
+ async getProductFromCart(productId) {
4726
+ const transaction = this.database.transaction(this.cartCollectionName, "readwrite");
4727
+ return await transaction.objectStore(this.cartCollectionName).get(productId);
4728
+ }
4729
+ // WISHLIST SERVICE
4730
+ async getUserWhishlist() {
4731
+ const request = await this.cartCollectionRef?.getAll();
4732
+ return request;
4694
4733
  }
4695
- get getQuantity() { return this.quantity; }
4696
- get getItemId() { return this.itemId; }
4697
- get getPrice() { return this.price; }
4734
+ addProductToWishlist(product) {
4735
+ const transaction = this.database.transaction(this.favouriteCollectionName, "readwrite");
4736
+ return transaction.objectStore(this.favouriteCollectionName).put(product);
4737
+ }
4738
+ removeProductFromWishlist(productId) {
4739
+ const transaction = this.database.transaction(this.favouriteCollectionName, "readwrite");
4740
+ return transaction.objectStore(this.favouriteCollectionName).delete(productId);
4741
+ }
4742
+ async getProductFromWishlist(productId) {
4743
+ const transaction = this.database.transaction(this.favouriteCollectionName, "readwrite");
4744
+ return await transaction.objectStore(this.favouriteCollectionName).get(productId);
4745
+ }
4746
+ // USER SERVICE
4747
+ addUser(user) {
4748
+ localStorage.setItem("user", JSON.stringify(user));
4749
+ return user;
4750
+ }
4751
+ getUser() {
4752
+ const user = localStorage.getItem("user") ?? "{}";
4753
+ return JSON.parse(user);
4754
+ }
4755
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: StorageServiceService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4756
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: StorageServiceService, providedIn: 'root' }); }
4698
4757
  }
4758
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: StorageServiceService, decorators: [{
4759
+ type: Injectable,
4760
+ args: [{
4761
+ providedIn: 'root'
4762
+ }]
4763
+ }], ctorParameters: () => [] });
4699
4764
 
4700
4765
  class CartService {
4701
- constructor(restService) {
4766
+ constructor(restService, storageService) {
4702
4767
  this.restService = restService;
4768
+ this.storageService = storageService;
4703
4769
  }
4704
4770
  addItemToCart(product) {
4705
- this.storeItemToJSON(UserCart, product, "CART");
4771
+ const orderedItem = this.objectMapper(product);
4772
+ let productIdx = -1;
4773
+ UserCart.orderedItems.forEach((item, idx) => productIdx = (item.itemId == product.itemId) ? idx : -1);
4774
+ if (productIdx >= 0) {
4775
+ UserCart.orderedItems[productIdx].quantity = product.quantity;
4776
+ }
4777
+ else {
4778
+ UserCart.orderedItems.push(product);
4779
+ }
4780
+ console.log(UserCart);
4781
+ this.storageService.addProductToCart(orderedItem);
4706
4782
  }
4707
4783
  addItemToFavourite(product) {
4708
- this.storeItemToJSON(UserFavourite, product, "WISHLIST");
4709
- }
4710
- removeItemToFavourite(product) {
4711
- const index = this.getItemIdxJSON(product.itemId, UserFavourite);
4712
- console.log("index: ", index);
4713
- if (index >= 0)
4714
- UserFavourite.orderedItems.splice(index, 1);
4715
- console.log(UserFavourite);
4784
+ const orderedItem = this.objectMapper(product);
4785
+ let productIdx = -1;
4786
+ UserFavourite.orderedItems.forEach((item, idx) => productIdx = (item.itemId == product.itemId) ? idx : -1);
4787
+ if (productIdx >= 0) {
4788
+ UserFavourite.orderedItems[productIdx].quantity = product.quantity;
4789
+ }
4790
+ else {
4791
+ UserFavourite.orderedItems.push(product);
4792
+ }
4793
+ this.storageService.addProductToWishlist(orderedItem);
4716
4794
  }
4717
- convertFavToCart(product) {
4718
- const index = this.getItemIdxJSON(product.getItemId, UserFavourite);
4795
+ removeItemFromFavourite(product) {
4796
+ const index = this.getItemIdxJSON(product.itemId, 'FAVOURITE');
4719
4797
  if (index >= 0) {
4720
4798
  const item = UserFavourite.orderedItems.splice(index, 1)[0];
4721
4799
  UserCart.orderedItems.push(item);
4800
+ this.storageService.removeProductFromWishlist(product.itemId);
4722
4801
  }
4723
4802
  }
4724
- convertCartToFav(product) {
4725
- const index = this.getItemIdxJSON(product.getItemId, UserCart);
4803
+ removeItemFromCart(product) {
4804
+ const index = this.getItemIdxJSON(product.itemId, 'CART');
4726
4805
  if (index >= 0) {
4727
4806
  const item = UserCart.orderedItems.splice(index, 1)[0];
4728
- UserFavourite.orderedItems.push(item);
4807
+ UserCart.orderedItems.push(item);
4808
+ this.storageService.removeProductFromCart(product.itemId);
4729
4809
  }
4730
4810
  }
4731
- storeItemToJSON(json, product, type) {
4732
- const orderProduct = this.objectMapper(product);
4733
- let productIndex = -1;
4734
- json.orderedItems.forEach((p, idx) => {
4735
- if (p.itemId == product.itemId)
4736
- productIndex = idx;
4737
- });
4738
- if (productIndex == -1)
4739
- json.orderedItems.push(orderProduct);
4740
- else {
4741
- if (product.quantity > 0) {
4742
- json.orderedItems[productIndex].quantity = orderProduct.getQuantity;
4811
+ // public convertFavToCart(product: OrderedItems) {
4812
+ // const index = this.getItemIdxJSON(product.getItemId, UserFavourites);
4813
+ // if (index >= 0) {
4814
+ // const item = UserFavourites.orderedItems.splice(index, 1)[0];
4815
+ // UserCart.orderedItems.push(item as never);
4816
+ // }
4817
+ // }
4818
+ // public convertCartToFav(product: OrderedItems) {
4819
+ // const index = this.getItemIdxJSON(product.getItemId, UserCart);
4820
+ // if (index >= 0) {
4821
+ // const item = UserCart.orderedItems.splice(index, 1)[0];
4822
+ // UserFavourites.orderedItems.push(item as never);
4823
+ // }
4824
+ // }
4825
+ storeItemToDB(product, type) {
4826
+ if (type == "CART") {
4827
+ const orderProduct = this.objectMapper(this.storageService.getProductFromCart(product.itemId));
4828
+ if (orderProduct) {
4829
+ this.storageService.addProductToCart(orderProduct);
4830
+ UserCart.orderedItems.push(orderProduct);
4743
4831
  }
4744
- else {
4745
- json.orderedItems.splice(productIndex, 1);
4832
+ }
4833
+ else {
4834
+ const orderProduct = this.objectMapper(this.storageService.getProductFromWishlist(product.itemId));
4835
+ if (orderProduct) {
4836
+ this.storageService.addProductToWishlist(orderProduct);
4837
+ UserFavourite.orderedItems.push(orderProduct);
4746
4838
  }
4747
- json.billdetails.totalNetValue = 0;
4748
- json.billdetails.totalTax = 0;
4749
- json.orderedItems.forEach((item) => json.billdetails.totalNetValue += (item.price * item.quantity));
4750
- json.orderedItems.forEach((item) => json.billdetails.totalTax += (item.itemTax));
4751
- json.totalAmount = json.billdetails.totalTax + json.billdetails.totalNetValue;
4752
4839
  }
4753
4840
  }
4754
- getItemQuantity(itemId) {
4755
- let productIndex = -1;
4756
- UserCart.orderedItems.forEach((p, idx) => {
4757
- if (p.itemId == itemId)
4758
- productIndex = idx;
4759
- });
4760
- if (productIndex == -1)
4761
- return 0;
4762
- else
4763
- return UserCart.orderedItems[productIndex].getQuantity;
4764
- }
4765
- getIsItemPresent(itemId, type) {
4766
- return type == "FAVOURITE" ? this.getItemIdxJSON(itemId, UserFavourite) >= 0 : this.getItemIdxJSON(itemId, UserCart) >= 0;
4767
- }
4768
- getItemIdxJSON(itemId, json) {
4841
+ getItemIdxJSON(itemId, type) {
4842
+ const json = type == "FAVOURITE" ? UserFavourite : UserCart;
4769
4843
  let productIndex = -1;
4770
4844
  json.orderedItems.forEach((p, idx) => {
4771
4845
  if (p.itemId == itemId)
@@ -4773,29 +4847,37 @@ class CartService {
4773
4847
  });
4774
4848
  return productIndex;
4775
4849
  }
4850
+ getItemByIdx(itemId, type) {
4851
+ const productIdx = this.getItemIdxJSON(itemId, type);
4852
+ const json = (type == "FAVOURITE") ? UserFavourite : UserCart;
4853
+ if (productIdx >= 0)
4854
+ return json.orderedItems[productIdx];
4855
+ return null;
4856
+ }
4776
4857
  objectMapper(product) {
4858
+ debugger;
4777
4859
  return new OrderedItems(product);
4778
4860
  }
4779
- storeJSONToDB() {
4780
- this.restService.addItemToDB(UserCart).subscribe((response) => { });
4781
- this.restService.addItemToDB(UserFavourite).subscribe((response) => { });
4861
+ storeDataToServer() {
4862
+ // this.restService.addItemToDB(UserCart).subscribe((response)=> {});
4863
+ // this.restService.addItemToDB(UserFavourites).subscribe((response)=> {});
4782
4864
  }
4783
4865
  storeDBToJSON() {
4784
- const userId = UserInfo.user?.userId;
4785
- if (!userId)
4786
- return;
4787
- this.restService.getUserItems(userId, "CART").subscribe((response) => {
4788
- UserCart.orderedItems = response.data.orderedItems;
4789
- UserCart.billdetails = response.data.billdetails;
4790
- UserCart.totalAmount = response.totalAmount;
4791
- });
4792
- this.restService.getUserItems(userId, "WISHLIST").subscribe((response) => {
4793
- UserFavourite.orderedItems = response.data.orderedItems;
4794
- UserFavourite.billdetails = response.data.billdetails;
4795
- UserFavourite.totalAmount = response.totalAmount;
4796
- });
4797
- }
4798
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: CartService, deps: [{ token: RestService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4866
+ // const userId = UserDetails.user?.userId;
4867
+ // if (!userId)
4868
+ // return;
4869
+ // this.restService.getUserItems(userId, "CART").subscribe((response: any)=> {
4870
+ // UserCart.orderedItems = response.data.orderedItems;
4871
+ // UserCart.billdetails = response.data.billdetails;
4872
+ // UserCart.totalAmount = response.totalAmount;
4873
+ // })
4874
+ // this.restService.getUserItems(userId, "WISHLIST").subscribe((response: any)=> {
4875
+ // UserFavourites.orderedItems = response.data.orderedItems;
4876
+ // UserFavourites.billdetails = response.data.billdetails;
4877
+ // UserFavourites.totalAmount = response.totalAmount;
4878
+ // })
4879
+ }
4880
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: CartService, deps: [{ token: RestService }, { token: StorageServiceService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4799
4881
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: CartService, providedIn: 'root' }); }
4800
4882
  }
4801
4883
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: CartService, decorators: [{
@@ -4803,7 +4885,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImpor
4803
4885
  args: [{
4804
4886
  providedIn: 'root',
4805
4887
  }]
4806
- }], ctorParameters: () => [{ type: RestService }] });
4888
+ }], ctorParameters: () => [{ type: RestService }, { type: StorageServiceService }] });
4807
4889
 
4808
4890
  class FeaturedProductsComponent extends BaseSection {
4809
4891
  constructor(platformId, _eventService, restService, router, cartService) {
@@ -4864,14 +4946,14 @@ class FeaturedProductsComponent extends BaseSection {
4864
4946
  if (type == 'ADD')
4865
4947
  this.cartService.addItemToFavourite(product);
4866
4948
  else
4867
- this.cartService.removeItemToFavourite(product);
4949
+ this.cartService.removeItemFromFavourite(product);
4868
4950
  }
4869
4951
  proceedToProductDesc(productId) {
4870
4952
  this.router.navigate([`details`], { queryParams: { id: productId } });
4871
4953
  // this._eventService.redirectToPage.emit({redirectTo: '/details', data: {productId: productId}})
4872
4954
  }
4873
4955
  isItemFav(product) {
4874
- return this.cartService.getIsItemPresent(product.itemId, 'FAVOURITE');
4956
+ return this.cartService.getItemIdxJSON(product.itemId, 'FAVOURITE');
4875
4957
  }
4876
4958
  togglePreviewImage(product, idx) {
4877
4959
  const element = document.getElementById('preview_' + idx);
@@ -5018,7 +5100,13 @@ class ProductDescComponent extends BaseSection {
5018
5100
  this.restService.getProductDetails(productId).subscribe((response) => {
5019
5101
  this.responseData = response[0];
5020
5102
  if (this.responseData) {
5021
- this.responseData.quantity = this.cartService.getItemQuantity(this.responseData?.itemId);
5103
+ const cartItem = this.cartService.getItemByIdx(this.responseData?.itemId, "CART");
5104
+ const favItem = this.cartService.getItemByIdx(this.responseData?.itemId, "FAVOURITE");
5105
+ response.quantity = 0;
5106
+ if (cartItem)
5107
+ response.quantity = cartItem.quantity;
5108
+ if (favItem)
5109
+ response.quantity = favItem.quantity;
5022
5110
  this.currentImg = this.responseData?.itemImages[0].imgUrl;
5023
5111
  this.getProductByCategory();
5024
5112
  }
@@ -5054,10 +5142,10 @@ class ProductDescComponent extends BaseSection {
5054
5142
  this.cartService.addItemToFavourite(this.responseData);
5055
5143
  }
5056
5144
  removeToFavourite() {
5057
- this.cartService.removeItemToFavourite(this.responseData);
5145
+ this.cartService.removeItemFromFavourite(this.responseData);
5058
5146
  }
5059
5147
  get isItemAsFavorite() {
5060
- return this.cartService.getIsItemPresent(this.responseData?.itemId, "FAVOURITE");
5148
+ return false;
5061
5149
  }
5062
5150
  get getFeatureProductData() {
5063
5151
  return this.data;
@@ -5466,7 +5554,7 @@ class CartComponent extends BaseSection {
5466
5554
  this.currentTab = "BAG";
5467
5555
  }
5468
5556
  ngOnInit() {
5469
- this.cartService.storeDBToJSON();
5557
+ // this.cartService.storeDBToJSON();
5470
5558
  this.responseData = UserCart;
5471
5559
  console.log("a: ", UserCart, this.responseData);
5472
5560
  this.styles = this.data?.styles;
@@ -5612,10 +5700,10 @@ class WhislistComponent {
5612
5700
  this.styles = this.data?.styles;
5613
5701
  }
5614
5702
  moveToCart(item) {
5615
- this.cartService.convertFavToCart(item);
5703
+ // this.cartService.convertFavToCart(item);
5616
5704
  }
5617
5705
  deleteFromWhislist(item) {
5618
- this.cartService.removeItemToFavourite(item);
5706
+ // this.cartService.removeItemToFavourite(item);
5619
5707
  }
5620
5708
  addToFav(item, type) {
5621
5709
  if (type == 'ADD')
@@ -5774,6 +5862,7 @@ class Cart {
5774
5862
  this.platform = json?.["platform"];
5775
5863
  this.locationDetails = json?.["locationDetails"];
5776
5864
  this.userDetails = json?.["userDetails"];
5865
+ this.totalAmount = 0;
5777
5866
  }
5778
5867
  }
5779
5868