simpo-component-library 1.4.14 → 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.
- package/esm2022/lib/ecommerce/json/user-cart.json +1 -14
- package/esm2022/lib/ecommerce/sections/address/address.component.mjs +3 -2
- package/esm2022/lib/ecommerce/sections/authenticate-user/authenticate-user.component.mjs +13 -10
- package/esm2022/lib/ecommerce/sections/cart/cart.component.mjs +2 -2
- package/esm2022/lib/ecommerce/sections/featured-products/featured-products.component.mjs +3 -3
- package/esm2022/lib/ecommerce/sections/product-desc/product-desc.component.mjs +10 -4
- package/esm2022/lib/ecommerce/sections/whislist/whislist.component.mjs +3 -3
- package/esm2022/lib/ecommerce/styles/OrderedItems.modal.mjs +3 -8
- package/esm2022/lib/ecommerce/styles/cart.modal.mjs +2 -1
- package/esm2022/lib/ecommerce/styles/user.modal.mjs +11 -0
- package/esm2022/lib/services/cart.service.mjs +86 -69
- package/esm2022/lib/services/storage.service.mjs +80 -0
- package/fesm2022/simpo-component-library.mjs +190 -100
- package/fesm2022/simpo-component-library.mjs.map +1 -1
- package/lib/ecommerce/sections/authenticate-user/authenticate-user.component.d.ts +4 -2
- package/lib/ecommerce/sections/featured-products/featured-products.component.d.ts +1 -1
- package/lib/ecommerce/styles/OrderedItems.modal.d.ts +10 -14
- package/lib/ecommerce/styles/cart.modal.d.ts +3 -18
- package/lib/ecommerce/styles/user.modal.d.ts +38 -0
- package/lib/services/cart.service.d.ts +9 -9
- package/lib/services/storage.service.d.ts +28 -0
- package/package.json +1 -1
- package/simpo-component-library-1.4.16.tgz +0 -0
- package/simpo-component-library-1.4.12.tgz +0 -0
- package/simpo-component-library-1.4.13.tgz +0 -0
- package/simpo-component-library-1.4.14.tgz +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export class StorageServiceService {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.databaseName = "USER";
|
|
6
|
+
this.databaseVersion = 1;
|
|
7
|
+
this.cartCollectionName = "USER_CART";
|
|
8
|
+
this.favouriteCollectionName = "USER_FAVOURITE";
|
|
9
|
+
this.userCollectionName = "USER";
|
|
10
|
+
this.cartCollectionRef = null;
|
|
11
|
+
this.favouriteCollectionRef = null;
|
|
12
|
+
this.userCollectionRef = null;
|
|
13
|
+
this.createDataBase();
|
|
14
|
+
}
|
|
15
|
+
async createDataBase() {
|
|
16
|
+
const request = window.indexedDB.open(this.databaseName, 1);
|
|
17
|
+
request.onerror = () => { };
|
|
18
|
+
request.onsuccess = async (event) => {
|
|
19
|
+
this.database = await event.target.result;
|
|
20
|
+
};
|
|
21
|
+
request.onupgradeneeded = (event) => {
|
|
22
|
+
this.database = event.target.result;
|
|
23
|
+
this.cartCollectionRef = this.database.createObjectStore(this.cartCollectionName, { keyPath: "itemId" });
|
|
24
|
+
this.favouriteCollectionRef = this.database.createObjectStore(this.favouriteCollectionName, { keyPath: "itemId" });
|
|
25
|
+
this.userCollectionRef = this.database.createObjectStore(this.userCollectionName, { keyPath: "userId" });
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// CART SERVICE
|
|
29
|
+
async getUserCart() {
|
|
30
|
+
const request = await this.cartCollectionRef?.getAll();
|
|
31
|
+
return request;
|
|
32
|
+
}
|
|
33
|
+
addProductToCart(product) {
|
|
34
|
+
const transaction = this.database.transaction(this.cartCollectionName, "readwrite");
|
|
35
|
+
return transaction.objectStore(this.cartCollectionName).put(product);
|
|
36
|
+
}
|
|
37
|
+
removeProductFromCart(productId) {
|
|
38
|
+
const transaction = this.database.transaction(this.cartCollectionName, "readwrite");
|
|
39
|
+
return transaction.objectStore(this.cartCollectionName).delete(productId);
|
|
40
|
+
}
|
|
41
|
+
async getProductFromCart(productId) {
|
|
42
|
+
const transaction = this.database.transaction(this.cartCollectionName, "readwrite");
|
|
43
|
+
return await transaction.objectStore(this.cartCollectionName).get(productId);
|
|
44
|
+
}
|
|
45
|
+
// WISHLIST SERVICE
|
|
46
|
+
async getUserWhishlist() {
|
|
47
|
+
const request = await this.cartCollectionRef?.getAll();
|
|
48
|
+
return request;
|
|
49
|
+
}
|
|
50
|
+
addProductToWishlist(product) {
|
|
51
|
+
const transaction = this.database.transaction(this.favouriteCollectionName, "readwrite");
|
|
52
|
+
return transaction.objectStore(this.favouriteCollectionName).put(product);
|
|
53
|
+
}
|
|
54
|
+
removeProductFromWishlist(productId) {
|
|
55
|
+
const transaction = this.database.transaction(this.favouriteCollectionName, "readwrite");
|
|
56
|
+
return transaction.objectStore(this.favouriteCollectionName).delete(productId);
|
|
57
|
+
}
|
|
58
|
+
async getProductFromWishlist(productId) {
|
|
59
|
+
const transaction = this.database.transaction(this.favouriteCollectionName, "readwrite");
|
|
60
|
+
return await transaction.objectStore(this.favouriteCollectionName).get(productId);
|
|
61
|
+
}
|
|
62
|
+
// USER SERVICE
|
|
63
|
+
addUser(user) {
|
|
64
|
+
localStorage.setItem("user", JSON.stringify(user));
|
|
65
|
+
return user;
|
|
66
|
+
}
|
|
67
|
+
getUser() {
|
|
68
|
+
const user = localStorage.getItem("user") ?? "{}";
|
|
69
|
+
return JSON.parse(user);
|
|
70
|
+
}
|
|
71
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: StorageServiceService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
72
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: StorageServiceService, providedIn: 'root' }); }
|
|
73
|
+
}
|
|
74
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: StorageServiceService, decorators: [{
|
|
75
|
+
type: Injectable,
|
|
76
|
+
args: [{
|
|
77
|
+
providedIn: 'root'
|
|
78
|
+
}]
|
|
79
|
+
}], ctorParameters: () => [] });
|
|
80
|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OiBhbnkpIHtcclxuXHJcbiAgLy8gICAgICAgICBpZiAoZXZlbnQudGFyZ2V0LnJlc3VsdCkge1xyXG4gIC8vICAgICAgICAgICByZXNvbHZlKGV2ZW50LnJlc3VsdCk7XHJcbiAgLy8gICAgICAgICB9IGVsc2Uge1xyXG4gIC8vICAgICAgICAgICByZXNvbHZlKCdTVUNDRVNTJyk7XHJcbiAgLy8gICAgICAgICB9XHJcbiAgLy8gICAgICAgfTtcclxuICAvLyAgICAgICByZXF1ZXN0Lm9uZXJyb3IgPSBhd2FpdCBmdW5jdGlvbiAoX2V2ZW50KSB7XHJcbiAgLy8gICAgICAgICByZWplY3QoXCJObyBkYXRhXCIpO1xyXG4gIC8vICAgICAgIH1cclxuICAvLyAgICAgfVxyXG4gIC8vICAgfSk7XHJcbiAgLy8gfVxyXG59XHJcbiJdfQ==
|
|
@@ -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
|
-
|
|
3278
|
-
if (
|
|
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
|
-
|
|
4693
|
-
|
|
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
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
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.
|
|
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.
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
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
|
-
|
|
4718
|
-
const index = this.getItemIdxJSON(product.
|
|
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
|
-
|
|
4725
|
-
const index = this.getItemIdxJSON(product.
|
|
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
|
-
|
|
4807
|
+
UserCart.orderedItems.push(item);
|
|
4808
|
+
this.storageService.removeProductFromCart(product.itemId);
|
|
4729
4809
|
}
|
|
4730
4810
|
}
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
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
|
-
|
|
4745
|
-
|
|
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
|
-
|
|
4755
|
-
|
|
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
|
-
|
|
4780
|
-
this.restService.addItemToDB(UserCart).subscribe((response)
|
|
4781
|
-
this.restService.addItemToDB(
|
|
4861
|
+
storeDataToServer() {
|
|
4862
|
+
// this.restService.addItemToDB(UserCart).subscribe((response)=> {});
|
|
4863
|
+
// this.restService.addItemToDB(UserFavourites).subscribe((response)=> {});
|
|
4782
4864
|
}
|
|
4783
4865
|
storeDBToJSON() {
|
|
4784
|
-
const userId =
|
|
4785
|
-
if (!userId)
|
|
4786
|
-
|
|
4787
|
-
this.restService.getUserItems(userId, "CART").subscribe((response)
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
})
|
|
4792
|
-
this.restService.getUserItems(userId, "WISHLIST").subscribe((response)
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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.
|
|
5145
|
+
this.cartService.removeItemFromFavourite(this.responseData);
|
|
5058
5146
|
}
|
|
5059
5147
|
get isItemAsFavorite() {
|
|
5060
|
-
return
|
|
5148
|
+
return false;
|
|
5061
5149
|
}
|
|
5062
5150
|
get getFeatureProductData() {
|
|
5063
5151
|
return this.data;
|
|
@@ -5426,13 +5514,14 @@ class AddressComponent {
|
|
|
5426
5514
|
updateAddress() {
|
|
5427
5515
|
const userId = UserInfo.user.userId;
|
|
5428
5516
|
const payload = {
|
|
5429
|
-
"userId":
|
|
5517
|
+
"userId": userId,
|
|
5430
5518
|
"addressDetailsList": [...(UserInfo.user?.addressDetailsList ?? []), this.address],
|
|
5431
5519
|
"contact": UserInfo.user?.contact ?? {},
|
|
5432
5520
|
"gender": UserInfo.user?.gender?.length > 0 ? UserInfo.user?.gender : null
|
|
5433
5521
|
};
|
|
5434
5522
|
this.restService.addUserAddress(payload).subscribe((response) => {
|
|
5435
5523
|
this.addNewAddress = false;
|
|
5524
|
+
UserInfo.user.addressDetailsList.push(this.address);
|
|
5436
5525
|
});
|
|
5437
5526
|
}
|
|
5438
5527
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.4", ngImport: i0, type: AddressComponent, deps: [{ token: i0.NgZone }, { token: RestService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
@@ -5465,7 +5554,7 @@ class CartComponent extends BaseSection {
|
|
|
5465
5554
|
this.currentTab = "BAG";
|
|
5466
5555
|
}
|
|
5467
5556
|
ngOnInit() {
|
|
5468
|
-
this.cartService.storeDBToJSON();
|
|
5557
|
+
// this.cartService.storeDBToJSON();
|
|
5469
5558
|
this.responseData = UserCart;
|
|
5470
5559
|
console.log("a: ", UserCart, this.responseData);
|
|
5471
5560
|
this.styles = this.data?.styles;
|
|
@@ -5611,10 +5700,10 @@ class WhislistComponent {
|
|
|
5611
5700
|
this.styles = this.data?.styles;
|
|
5612
5701
|
}
|
|
5613
5702
|
moveToCart(item) {
|
|
5614
|
-
this.cartService.convertFavToCart(item);
|
|
5703
|
+
// this.cartService.convertFavToCart(item);
|
|
5615
5704
|
}
|
|
5616
5705
|
deleteFromWhislist(item) {
|
|
5617
|
-
this.cartService.removeItemToFavourite(item);
|
|
5706
|
+
// this.cartService.removeItemToFavourite(item);
|
|
5618
5707
|
}
|
|
5619
5708
|
addToFav(item, type) {
|
|
5620
5709
|
if (type == 'ADD')
|
|
@@ -5773,6 +5862,7 @@ class Cart {
|
|
|
5773
5862
|
this.platform = json?.["platform"];
|
|
5774
5863
|
this.locationDetails = json?.["locationDetails"];
|
|
5775
5864
|
this.userDetails = json?.["userDetails"];
|
|
5865
|
+
this.totalAmount = 0;
|
|
5776
5866
|
}
|
|
5777
5867
|
}
|
|
5778
5868
|
|