simpo-component-library 3.6.262 → 3.6.263

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.
@@ -6488,263 +6488,15 @@ class checkItemAlreadyAdded {
6488
6488
  }
6489
6489
  }
6490
6490
 
6491
- class Cart {
6492
- constructor(json, type = null) {
6493
- this.cartId = json?.["cartId"];
6494
- this.businessId = json?.["businessId"];
6495
- this.pgOrderId = json?.["pgOrderId"];
6496
- this.orderedItems = json?.["orderedItems"];
6497
- this.billdetails = json?.["billdetails"];
6498
- this.platform = json?.["platform"];
6499
- this.locationDetails = json?.["locationDetails"];
6500
- this.userDetails = json?.["userDetails"];
6501
- this.cartType = json?.["cartType"];
6502
- this.totalAmount = 0;
6503
- }
6504
- }
6505
- var cartType;
6506
- (function (cartType) {
6507
- cartType["CART"] = "CART";
6508
- cartType["WISHLIST"] = "WISHLIST";
6509
- })(cartType || (cartType = {}));
6510
-
6511
- class StorageServiceService {
6512
- constructor(eventService, cookieService, restService, router) {
6513
- this.eventService = eventService;
6514
- this.cookieService = cookieService;
6515
- this.restService = restService;
6516
- this.router = router;
6517
- this.totalCartItems = 0;
6518
- this.databaseName = "USER";
6519
- this.databaseVersion = 1;
6520
- this.cartCollectionName = "USER_CART";
6521
- this.favouriteCollectionName = "USER_FAVOURITE";
6522
- this.trialCartCollectionName = 'TRIAL_CART';
6523
- this.userCollectionName = "USER";
6524
- this.cartCollectionRef = null;
6525
- this.favouriteCollectionRef = null;
6526
- this.userCollectionRef = null;
6527
- this.trialCartCollectionRef = null;
6528
- this.createDataBase();
6529
- const userDetails = this.getUser();
6530
- if (!!userDetails) {
6531
- this.restService.getUserInfo(userDetails.userId).subscribe((response) => {
6532
- this.setUser(response.data);
6533
- });
6534
- }
6535
- }
6536
- get getTotalCartItems() {
6537
- if (this.totalCartItems < 0)
6538
- this.totalCartItems = 0;
6539
- this.eventService.showBagIcon.emit(this.totalCartItems > 0);
6540
- return this.totalCartItems;
6541
- }
6542
- async createDataBase() {
6543
- const request = await window.indexedDB.open(this.databaseName, 1);
6544
- this.eventService.showLoadingScreen.emit(true);
6545
- request.onerror = () => { };
6546
- request.onsuccess = async (event) => {
6547
- this.database = await event.target.result;
6548
- const request = await this.getUserCart();
6549
- request.onsuccess = async (response) => {
6550
- (await this.getUserCart()).onsuccess = (userCartResponse) => {
6551
- this.totalCartItems = userCartResponse.target.result.length;
6552
- try {
6553
- const response = this.addAllProductsToCart(userCartResponse.target.result);
6554
- response.oncomplete = () => {
6555
- this.eventService.showLoadingScreen.emit(false);
6556
- };
6557
- response.onerror = () => {
6558
- this.eventService.showLoadingScreen.emit(false);
6559
- };
6560
- }
6561
- catch (exception) {
6562
- this.eventService.showLoadingScreen.emit(false);
6563
- }
6564
- ;
6565
- };
6566
- // UserCart.orderedItems = await response.target.result;
6567
- };
6568
- };
6569
- request.onupgradeneeded = (event) => {
6570
- this.database = event.target.result;
6571
- this.cartCollectionRef = this.database.createObjectStore(this.cartCollectionName, { keyPath: "varientId" });
6572
- this.trialCartCollectionRef = this.database.createObjectStore(this.trialCartCollectionName, { keyPath: "varientId" });
6573
- this.favouriteCollectionRef = this.database.createObjectStore(this.favouriteCollectionName, { keyPath: "varientId" });
6574
- this.userCollectionRef = this.database.createObjectStore(this.userCollectionName, { keyPath: "userId" });
6575
- };
6576
- }
6577
- setToken(token) {
6578
- this.cookieService.set("passBookToken", token);
6579
- // localStorage.setItem("token", token);
6580
- }
6581
- getToken() {
6582
- this.cookieService.get('passBookToken');
6583
- }
6584
- updateAllData() {
6585
- if (this.router.url.includes('cart'))
6586
- return;
6587
- const userDetails = this.getUser();
6588
- if (!!userDetails) {
6589
- this.eventService.showLoadingScreen.emit(true);
6590
- const request = forkJoin([
6591
- this.restService.getUserItems(userDetails.userId, "CART"),
6592
- this.restService.getUserItems(userDetails.userId, "WISHLIST")
6593
- ]);
6594
- request.subscribe((cartResponse) => {
6595
- const userDetails = this.getUser();
6596
- const userCart = cartResponse?.[0].data[0] ? cartResponse?.[0].data[0] : new Cart({ 'cartType': cartType.CART, 'userDetails': userDetails, 'platform': 'WEB' });
6597
- if (userCart?.cartId)
6598
- localStorage.setItem("cartId", userCart?.cartId);
6599
- this.getUserCart().then((userCartResponse) => {
6600
- userCartResponse.onsuccess = (userCartIndexDB) => {
6601
- userCart.orderedItems = this.mergeAllItems(userCartIndexDB.target.result ?? [], userCart?.orderedItems ?? []);
6602
- this.addAllProductsToCart(userCart.orderedItems);
6603
- // this.restService.addItemToDB(userCart).subscribe((res: any) => {
6604
- // if(res?.data?.cartId && !localStorage.getItem('cartId'))
6605
- // localStorage.setItem('cartId', res.data.cartId);
6606
- // })
6607
- };
6608
- });
6609
- const userWishlist = cartResponse?.[1].data;
6610
- if (userWishlist.cartId)
6611
- localStorage.setItem("wishlistId", userWishlist.cartId);
6612
- this.getUserWhishlist().then((userWishlistResponse) => {
6613
- userWishlistResponse.onsuccess = (userWishlistIndexDB) => {
6614
- userWishlist.orderedItems = [...(userWishlistIndexDB.target.result ?? []), ...(userWishlist.orderedItems ?? [])];
6615
- this.addAllProductToWishlist(userWishlist.orderedItems);
6616
- this.restService.addItemToDB(userWishlist);
6617
- };
6618
- });
6619
- this.eventService.showLoadingScreen.emit(false);
6620
- });
6621
- }
6622
- else {
6623
- // this.storeDataToJSON();
6624
- }
6625
- }
6626
- mergeAllItems(unSyncedItem, syncedItem) {
6627
- for (let product of syncedItem) {
6628
- let itemFound = false;
6629
- for (let cartItem of unSyncedItem) {
6630
- if (cartItem.varientId === product.varientId) {
6631
- itemFound = true;
6632
- // cartItem.quantity = product.quantity;
6633
- }
6634
- }
6635
- if (!itemFound) {
6636
- unSyncedItem.push(product);
6637
- }
6638
- }
6639
- return unSyncedItem;
6640
- }
6641
- // CART SERVICE
6642
- async getUserCart() {
6643
- const transaction = this.database?.transaction(this.cartCollectionName ?? "USER_CART", "readwrite");
6644
- return await transaction.objectStore(this.cartCollectionName).getAll();
6645
- }
6646
- addProductToCart(product) {
6647
- const transaction = this.database?.transaction(this.cartCollectionName ?? "USER_CART", "readwrite");
6648
- const response = transaction.objectStore(this.cartCollectionName).get(product.varientId);
6649
- response.onsuccess = (cartResponse) => {
6650
- if (cartResponse.target.result) { }
6651
- else {
6652
- this.totalCartItems += 1;
6653
- }
6654
- };
6655
- return transaction.objectStore(this.cartCollectionName).put(product);
6656
- }
6657
- addAllProductToWishlist(products) {
6658
- const transaction = this.database?.transaction(this.favouriteCollectionName ?? "USER_FAVOURITE", "readwrite");
6659
- products.forEach((product) => {
6660
- const response = transaction.objectStore(this.favouriteCollectionName).put(product);
6661
- });
6662
- return transaction;
6663
- }
6664
- addAllProductsToCart(products) {
6665
- const transaction = this.database?.transaction(this.cartCollectionName ?? "USER_CART", "readwrite");
6666
- products.forEach((product) => {
6667
- const response = transaction.objectStore(this.cartCollectionName).put(product);
6668
- });
6669
- return transaction;
6670
- }
6671
- removeProductFromCart(productId) {
6672
- this.totalCartItems -= 1;
6673
- const transaction = this.database?.transaction(this.cartCollectionName ?? "USER_CART", "readwrite");
6674
- return transaction.objectStore(this.cartCollectionName).delete(productId);
6675
- }
6676
- async getProductFromCart(productId) {
6677
- const transaction = this.database?.transaction(this.cartCollectionName ?? "USER_CART", "readwrite");
6678
- return await transaction.objectStore(this.cartCollectionName).get(productId);
6679
- }
6680
- // WISHLIST SERVICE
6681
- async getUserWhishlist() {
6682
- const transaction = this.database.transaction(this.favouriteCollectionName, "readwrite");
6683
- return await transaction.objectStore(this.favouriteCollectionName).getAll();
6684
- }
6685
- async getTrialCart() {
6686
- const transaction = this.database.transaction(this.trialCartCollectionName, "readwrite");
6687
- return await transaction.objectStore(this.trialCartCollectionName).getAll();
6688
- }
6689
- addProductToWishlist(product) {
6690
- const transaction = this.database.transaction(this.favouriteCollectionName, "readwrite");
6691
- return transaction.objectStore(this.favouriteCollectionName).put(product);
6692
- }
6693
- addProductToTrial(product) {
6694
- const transaction = this.database.transaction(this.trialCartCollectionName, "readwrite");
6695
- return transaction.objectStore(this.trialCartCollectionName).put(product);
6696
- }
6697
- removeProductFromWishlist(productId) {
6698
- const transaction = this.database.transaction(this.favouriteCollectionName, "readwrite");
6699
- return transaction.objectStore(this.favouriteCollectionName).delete(productId);
6700
- }
6701
- clearUserCart() {
6702
- this.totalCartItems = 0;
6703
- const transaction = this.database?.transaction(this.cartCollectionName ?? "USER_CART", "readwrite");
6704
- return transaction.objectStore(this.cartCollectionName).clear();
6705
- }
6706
- clearTrialCart() {
6707
- this.totalCartItems = 0;
6708
- const transaction = this.database?.transaction(this.trialCartCollectionName, "readwrite");
6709
- return transaction.objectStore(this.trialCartCollectionName).clear();
6710
- }
6711
- removeProductFromTrialCart(productId) {
6712
- const transaction = this.database.transaction(this.trialCartCollectionName, "readwrite");
6713
- return transaction.objectStore(this.trialCartCollectionName).delete(productId);
6714
- }
6715
- // USER SERVICE
6716
- setUser(user) {
6717
- this.cookieService.set("user", JSON.stringify(user ?? "{}"), 7);
6718
- return user;
6719
- }
6720
- getUser() {
6721
- try {
6722
- const user = JSON.parse(this.cookieService.get("user"));
6723
- localStorage.setItem("perId", user?.userId);
6724
- return user;
6725
- }
6726
- catch (exception) { }
6727
- return null;
6728
- }
6729
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: StorageServiceService, deps: [{ token: EventsService }, { token: i2$3.CookieService }, { token: RestService }, { token: i2$2.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
6730
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: StorageServiceService, providedIn: 'root' }); }
6731
- }
6732
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: StorageServiceService, decorators: [{
6733
- type: Injectable,
6734
- args: [{
6735
- providedIn: 'root'
6736
- }]
6737
- }], ctorParameters: () => [{ type: EventsService }, { type: i2$3.CookieService }, { type: RestService }, { type: i2$2.Router }] });
6738
-
6739
6491
  class RestService {
6740
6492
  constructor(http,
6741
6493
  // private readonly eventService: EventsService,
6742
- BASE_URL, ECOMMERCE_URL, CMIS_URL, storageService) {
6494
+ BASE_URL, ECOMMERCE_URL, CMIS_URL, cookieService) {
6743
6495
  this.http = http;
6744
6496
  this.BASE_URL = BASE_URL;
6745
6497
  this.ECOMMERCE_URL = ECOMMERCE_URL;
6746
6498
  this.CMIS_URL = CMIS_URL;
6747
- this.storageService = storageService;
6499
+ this.cookieService = cookieService;
6748
6500
  // private BASE_URL: string = "https://dev-api.simpo.ai/";
6749
6501
  // private ECOMMERCE_URL: string = "https://dev-ecommerce.simpo.ai/";
6750
6502
  // private CMIS_URL: string = "https://api-cmis.tejsoft.com/"; //production
@@ -6796,7 +6548,7 @@ class RestService {
6796
6548
  return this.http.get(this.BASE_URL + `ecommerce/inventory/category/collectionId?collectionId=${collectionId}`).pipe(map((response) => response.data?.map((category) => new Category(category))));
6797
6549
  }
6798
6550
  getPassbookOrderStatus(orderId) {
6799
- const token = this.storageService.getToken();
6551
+ const token = this.getToken();
6800
6552
  const headers = new HttpHeaders({
6801
6553
  'Authorization': `Bearer ${token}`
6802
6554
  });
@@ -7159,7 +6911,7 @@ class RestService {
7159
6911
  return this.http.put(this.passBookUrl + 'ext/connect/simpo/scheme/list', payload);
7160
6912
  }
7161
6913
  enrollScheme(payload, checkCharges) {
7162
- const token = this.storageService.getToken();
6914
+ const token = this.getToken();
7163
6915
  const headers = new HttpHeaders({
7164
6916
  'Authorization': `Bearer ${token}`
7165
6917
  });
@@ -7171,7 +6923,7 @@ class RestService {
7171
6923
  }
7172
6924
  }
7173
6925
  getBenefitSlab(passbookId) {
7174
- const token = this.storageService.getToken();
6926
+ const token = this.getToken();
7175
6927
  const headers = new HttpHeaders({
7176
6928
  'Authorization': `Bearer ${token}`
7177
6929
  });
@@ -7181,7 +6933,7 @@ class RestService {
7181
6933
  return this.http.get(this.BASE_URL + `staff/staff/list/${localStorage.getItem('businessId')}?isPagination=false`);
7182
6934
  }
7183
6935
  requestRedeemption(passbookId) {
7184
- const token = this.storageService.getToken();
6936
+ const token = this.getToken();
7185
6937
  const headers = new HttpHeaders({
7186
6938
  'Authorization': `Bearer ${token}`
7187
6939
  });
@@ -7190,7 +6942,10 @@ class RestService {
7190
6942
  PassbookAppStatus(bId) {
7191
6943
  return this.http.get(this.BASE_URL + `app/app/check-app?businessId=${bId}&appName=Passbook`);
7192
6944
  }
7193
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RestService, deps: [{ token: i1.HttpClient }, { token: API_URL }, { token: ECOMMERCE_URL }, { token: CMIS_URL }, { token: StorageServiceService }], target: i0.ɵɵFactoryTarget.Injectable }); }
6945
+ getToken() {
6946
+ this.cookieService.get('passBookToken');
6947
+ }
6948
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RestService, deps: [{ token: i1.HttpClient }, { token: API_URL }, { token: ECOMMERCE_URL }, { token: CMIS_URL }, { token: i2$3.CookieService }], target: i0.ɵɵFactoryTarget.Injectable }); }
7194
6949
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RestService, providedIn: 'root' }); }
7195
6950
  }
7196
6951
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RestService, decorators: [{
@@ -7207,7 +6962,255 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImpo
7207
6962
  }] }, { type: undefined, decorators: [{
7208
6963
  type: Inject,
7209
6964
  args: [CMIS_URL]
7210
- }] }, { type: StorageServiceService }] });
6965
+ }] }, { type: i2$3.CookieService }] });
6966
+
6967
+ class Cart {
6968
+ constructor(json, type = null) {
6969
+ this.cartId = json?.["cartId"];
6970
+ this.businessId = json?.["businessId"];
6971
+ this.pgOrderId = json?.["pgOrderId"];
6972
+ this.orderedItems = json?.["orderedItems"];
6973
+ this.billdetails = json?.["billdetails"];
6974
+ this.platform = json?.["platform"];
6975
+ this.locationDetails = json?.["locationDetails"];
6976
+ this.userDetails = json?.["userDetails"];
6977
+ this.cartType = json?.["cartType"];
6978
+ this.totalAmount = 0;
6979
+ }
6980
+ }
6981
+ var cartType;
6982
+ (function (cartType) {
6983
+ cartType["CART"] = "CART";
6984
+ cartType["WISHLIST"] = "WISHLIST";
6985
+ })(cartType || (cartType = {}));
6986
+
6987
+ class StorageServiceService {
6988
+ constructor(eventService, cookieService, restService, router) {
6989
+ this.eventService = eventService;
6990
+ this.cookieService = cookieService;
6991
+ this.restService = restService;
6992
+ this.router = router;
6993
+ this.totalCartItems = 0;
6994
+ this.databaseName = "USER";
6995
+ this.databaseVersion = 1;
6996
+ this.cartCollectionName = "USER_CART";
6997
+ this.favouriteCollectionName = "USER_FAVOURITE";
6998
+ this.trialCartCollectionName = 'TRIAL_CART';
6999
+ this.userCollectionName = "USER";
7000
+ this.cartCollectionRef = null;
7001
+ this.favouriteCollectionRef = null;
7002
+ this.userCollectionRef = null;
7003
+ this.trialCartCollectionRef = null;
7004
+ this.createDataBase();
7005
+ const userDetails = this.getUser();
7006
+ if (!!userDetails) {
7007
+ this.restService.getUserInfo(userDetails.userId).subscribe((response) => {
7008
+ this.setUser(response.data);
7009
+ });
7010
+ }
7011
+ }
7012
+ get getTotalCartItems() {
7013
+ if (this.totalCartItems < 0)
7014
+ this.totalCartItems = 0;
7015
+ this.eventService.showBagIcon.emit(this.totalCartItems > 0);
7016
+ return this.totalCartItems;
7017
+ }
7018
+ async createDataBase() {
7019
+ const request = await window.indexedDB.open(this.databaseName, 1);
7020
+ this.eventService.showLoadingScreen.emit(true);
7021
+ request.onerror = () => { };
7022
+ request.onsuccess = async (event) => {
7023
+ this.database = await event.target.result;
7024
+ const request = await this.getUserCart();
7025
+ request.onsuccess = async (response) => {
7026
+ (await this.getUserCart()).onsuccess = (userCartResponse) => {
7027
+ this.totalCartItems = userCartResponse.target.result.length;
7028
+ try {
7029
+ const response = this.addAllProductsToCart(userCartResponse.target.result);
7030
+ response.oncomplete = () => {
7031
+ this.eventService.showLoadingScreen.emit(false);
7032
+ };
7033
+ response.onerror = () => {
7034
+ this.eventService.showLoadingScreen.emit(false);
7035
+ };
7036
+ }
7037
+ catch (exception) {
7038
+ this.eventService.showLoadingScreen.emit(false);
7039
+ }
7040
+ ;
7041
+ };
7042
+ // UserCart.orderedItems = await response.target.result;
7043
+ };
7044
+ };
7045
+ request.onupgradeneeded = (event) => {
7046
+ this.database = event.target.result;
7047
+ this.cartCollectionRef = this.database.createObjectStore(this.cartCollectionName, { keyPath: "varientId" });
7048
+ this.trialCartCollectionRef = this.database.createObjectStore(this.trialCartCollectionName, { keyPath: "varientId" });
7049
+ this.favouriteCollectionRef = this.database.createObjectStore(this.favouriteCollectionName, { keyPath: "varientId" });
7050
+ this.userCollectionRef = this.database.createObjectStore(this.userCollectionName, { keyPath: "userId" });
7051
+ };
7052
+ }
7053
+ setToken(token) {
7054
+ this.cookieService.set("passBookToken", token);
7055
+ // localStorage.setItem("token", token);
7056
+ }
7057
+ getToken() {
7058
+ this.cookieService.get('passBookToken');
7059
+ }
7060
+ updateAllData() {
7061
+ if (this.router.url.includes('cart'))
7062
+ return;
7063
+ const userDetails = this.getUser();
7064
+ if (!!userDetails) {
7065
+ this.eventService.showLoadingScreen.emit(true);
7066
+ const request = forkJoin([
7067
+ this.restService.getUserItems(userDetails.userId, "CART"),
7068
+ this.restService.getUserItems(userDetails.userId, "WISHLIST")
7069
+ ]);
7070
+ request.subscribe((cartResponse) => {
7071
+ const userDetails = this.getUser();
7072
+ const userCart = cartResponse?.[0].data[0] ? cartResponse?.[0].data[0] : new Cart({ 'cartType': cartType.CART, 'userDetails': userDetails, 'platform': 'WEB' });
7073
+ if (userCart?.cartId)
7074
+ localStorage.setItem("cartId", userCart?.cartId);
7075
+ this.getUserCart().then((userCartResponse) => {
7076
+ userCartResponse.onsuccess = (userCartIndexDB) => {
7077
+ userCart.orderedItems = this.mergeAllItems(userCartIndexDB.target.result ?? [], userCart?.orderedItems ?? []);
7078
+ this.addAllProductsToCart(userCart.orderedItems);
7079
+ // this.restService.addItemToDB(userCart).subscribe((res: any) => {
7080
+ // if(res?.data?.cartId && !localStorage.getItem('cartId'))
7081
+ // localStorage.setItem('cartId', res.data.cartId);
7082
+ // })
7083
+ };
7084
+ });
7085
+ const userWishlist = cartResponse?.[1].data;
7086
+ if (userWishlist.cartId)
7087
+ localStorage.setItem("wishlistId", userWishlist.cartId);
7088
+ this.getUserWhishlist().then((userWishlistResponse) => {
7089
+ userWishlistResponse.onsuccess = (userWishlistIndexDB) => {
7090
+ userWishlist.orderedItems = [...(userWishlistIndexDB.target.result ?? []), ...(userWishlist.orderedItems ?? [])];
7091
+ this.addAllProductToWishlist(userWishlist.orderedItems);
7092
+ this.restService.addItemToDB(userWishlist);
7093
+ };
7094
+ });
7095
+ this.eventService.showLoadingScreen.emit(false);
7096
+ });
7097
+ }
7098
+ else {
7099
+ // this.storeDataToJSON();
7100
+ }
7101
+ }
7102
+ mergeAllItems(unSyncedItem, syncedItem) {
7103
+ for (let product of syncedItem) {
7104
+ let itemFound = false;
7105
+ for (let cartItem of unSyncedItem) {
7106
+ if (cartItem.varientId === product.varientId) {
7107
+ itemFound = true;
7108
+ // cartItem.quantity = product.quantity;
7109
+ }
7110
+ }
7111
+ if (!itemFound) {
7112
+ unSyncedItem.push(product);
7113
+ }
7114
+ }
7115
+ return unSyncedItem;
7116
+ }
7117
+ // CART SERVICE
7118
+ async getUserCart() {
7119
+ const transaction = this.database?.transaction(this.cartCollectionName ?? "USER_CART", "readwrite");
7120
+ return await transaction.objectStore(this.cartCollectionName).getAll();
7121
+ }
7122
+ addProductToCart(product) {
7123
+ const transaction = this.database?.transaction(this.cartCollectionName ?? "USER_CART", "readwrite");
7124
+ const response = transaction.objectStore(this.cartCollectionName).get(product.varientId);
7125
+ response.onsuccess = (cartResponse) => {
7126
+ if (cartResponse.target.result) { }
7127
+ else {
7128
+ this.totalCartItems += 1;
7129
+ }
7130
+ };
7131
+ return transaction.objectStore(this.cartCollectionName).put(product);
7132
+ }
7133
+ addAllProductToWishlist(products) {
7134
+ const transaction = this.database?.transaction(this.favouriteCollectionName ?? "USER_FAVOURITE", "readwrite");
7135
+ products.forEach((product) => {
7136
+ const response = transaction.objectStore(this.favouriteCollectionName).put(product);
7137
+ });
7138
+ return transaction;
7139
+ }
7140
+ addAllProductsToCart(products) {
7141
+ const transaction = this.database?.transaction(this.cartCollectionName ?? "USER_CART", "readwrite");
7142
+ products.forEach((product) => {
7143
+ const response = transaction.objectStore(this.cartCollectionName).put(product);
7144
+ });
7145
+ return transaction;
7146
+ }
7147
+ removeProductFromCart(productId) {
7148
+ this.totalCartItems -= 1;
7149
+ const transaction = this.database?.transaction(this.cartCollectionName ?? "USER_CART", "readwrite");
7150
+ return transaction.objectStore(this.cartCollectionName).delete(productId);
7151
+ }
7152
+ async getProductFromCart(productId) {
7153
+ const transaction = this.database?.transaction(this.cartCollectionName ?? "USER_CART", "readwrite");
7154
+ return await transaction.objectStore(this.cartCollectionName).get(productId);
7155
+ }
7156
+ // WISHLIST SERVICE
7157
+ async getUserWhishlist() {
7158
+ const transaction = this.database.transaction(this.favouriteCollectionName, "readwrite");
7159
+ return await transaction.objectStore(this.favouriteCollectionName).getAll();
7160
+ }
7161
+ async getTrialCart() {
7162
+ const transaction = this.database.transaction(this.trialCartCollectionName, "readwrite");
7163
+ return await transaction.objectStore(this.trialCartCollectionName).getAll();
7164
+ }
7165
+ addProductToWishlist(product) {
7166
+ const transaction = this.database.transaction(this.favouriteCollectionName, "readwrite");
7167
+ return transaction.objectStore(this.favouriteCollectionName).put(product);
7168
+ }
7169
+ addProductToTrial(product) {
7170
+ const transaction = this.database.transaction(this.trialCartCollectionName, "readwrite");
7171
+ return transaction.objectStore(this.trialCartCollectionName).put(product);
7172
+ }
7173
+ removeProductFromWishlist(productId) {
7174
+ const transaction = this.database.transaction(this.favouriteCollectionName, "readwrite");
7175
+ return transaction.objectStore(this.favouriteCollectionName).delete(productId);
7176
+ }
7177
+ clearUserCart() {
7178
+ this.totalCartItems = 0;
7179
+ const transaction = this.database?.transaction(this.cartCollectionName ?? "USER_CART", "readwrite");
7180
+ return transaction.objectStore(this.cartCollectionName).clear();
7181
+ }
7182
+ clearTrialCart() {
7183
+ this.totalCartItems = 0;
7184
+ const transaction = this.database?.transaction(this.trialCartCollectionName, "readwrite");
7185
+ return transaction.objectStore(this.trialCartCollectionName).clear();
7186
+ }
7187
+ removeProductFromTrialCart(productId) {
7188
+ const transaction = this.database.transaction(this.trialCartCollectionName, "readwrite");
7189
+ return transaction.objectStore(this.trialCartCollectionName).delete(productId);
7190
+ }
7191
+ // USER SERVICE
7192
+ setUser(user) {
7193
+ this.cookieService.set("user", JSON.stringify(user ?? "{}"), 7);
7194
+ return user;
7195
+ }
7196
+ getUser() {
7197
+ try {
7198
+ const user = JSON.parse(this.cookieService.get("user"));
7199
+ localStorage.setItem("perId", user?.userId);
7200
+ return user;
7201
+ }
7202
+ catch (exception) { }
7203
+ return null;
7204
+ }
7205
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: StorageServiceService, deps: [{ token: EventsService }, { token: i2$3.CookieService }, { token: RestService }, { token: i2$2.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
7206
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: StorageServiceService, providedIn: 'root' }); }
7207
+ }
7208
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: StorageServiceService, decorators: [{
7209
+ type: Injectable,
7210
+ args: [{
7211
+ providedIn: 'root'
7212
+ }]
7213
+ }], ctorParameters: () => [{ type: EventsService }, { type: i2$3.CookieService }, { type: RestService }, { type: i2$2.Router }] });
7211
7214
 
7212
7215
  class AddressComponent extends BaseSection {
7213
7216
  constructor(ngZone, restService, matDialog, matBottomsheet, router, storageService, _eventService, snackBar, matData, matDialogRef) {