simpo-component-library 3.6.665 → 3.6.666
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/sections/cart/cart.component.mjs +99 -97
- package/fesm2022/simpo-component-library.mjs +98 -96
- package/fesm2022/simpo-component-library.mjs.map +1 -1
- package/package.json +1 -1
- package/simpo-component-library-3.6.666.tgz +0 -0
- package/simpo-component-library-3.6.665.tgz +0 -0
|
@@ -9102,102 +9102,104 @@ class CartComponent extends BaseSection {
|
|
|
9102
9102
|
if (referralDetails && Object.keys(referralDetails).length > 0) {
|
|
9103
9103
|
result = Object.values(referralDetails).find((item) => item.referralEvents?.includes('PRODUCT_PURCHASE')) || "";
|
|
9104
9104
|
}
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
|
|
9117
|
-
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
|
|
9141
|
-
|
|
9142
|
-
|
|
9143
|
-
|
|
9144
|
-
|
|
9145
|
-
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
|
|
9151
|
-
|
|
9152
|
-
|
|
9153
|
-
|
|
9154
|
-
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
|
|
9161
|
-
|
|
9162
|
-
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9167
|
-
|
|
9168
|
-
|
|
9169
|
-
|
|
9170
|
-
|
|
9171
|
-
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
|
|
9185
|
-
|
|
9186
|
-
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9105
|
+
if (!this.storageService.getUser()) {
|
|
9106
|
+
this.messageService.add({ severity: 'info', summary: 'Login', detail: 'Please login with mobile number to order' });
|
|
9107
|
+
return;
|
|
9108
|
+
}
|
|
9109
|
+
const isPaymentGatewayEnabled = localStorage.getItem("isPaymentGatewayEnabled") ? localStorage.getItem("isPaymentGatewayEnabled") == "true" : true;
|
|
9110
|
+
const merchantId = localStorage.getItem('pMId') == "null" || localStorage.getItem('pMId') == "undefined" ? null : localStorage.getItem('pMId');
|
|
9111
|
+
if (isPaymentGatewayEnabled && !merchantId) {
|
|
9112
|
+
this.messageService.add({ severity: 'error', summary: 'Merchant onboarded', detail: 'Merchant is not onboarded' });
|
|
9113
|
+
return;
|
|
9114
|
+
}
|
|
9115
|
+
const userDetail = this.storageService.getUser();
|
|
9116
|
+
const address = userDetail?.addressDetailsList[this.selectedAddressIdx];
|
|
9117
|
+
if (address?.receiverName?.length == 0) {
|
|
9118
|
+
this.messageService.add({ severity: 'error', summary: 'Payment Failure', detail: 'Please provide address details' });
|
|
9119
|
+
return;
|
|
9120
|
+
}
|
|
9121
|
+
if (!(localStorage.getItem("cartId") == "undefined" || localStorage.getItem("cartId") == "null"))
|
|
9122
|
+
this.cartInfo["cartId"] = localStorage.getItem("cartId");
|
|
9123
|
+
else {
|
|
9124
|
+
this.messageService.add({ severity: 'info', summary: 'Please wait', detail: 'We are processing your payment', life: 2000 });
|
|
9125
|
+
await this.restService.addItemToDB(this.cartInfo).toPromise().then((response) => {
|
|
9126
|
+
localStorage.setItem("cartId", response.data?.cartId);
|
|
9127
|
+
this.cartInfo["cartId"] = response.data?.cartId;
|
|
9128
|
+
});
|
|
9129
|
+
}
|
|
9130
|
+
this.cartInfo["addressDetails"] = address;
|
|
9131
|
+
const updateAddress = await this.restService.addItemToDB(this.cartInfo).toPromise();
|
|
9132
|
+
const payload = {
|
|
9133
|
+
"userId": userDetail.userId,
|
|
9134
|
+
"cartId": localStorage.getItem('cartId'),
|
|
9135
|
+
"orderAmount": Number(Number(((this.responseData?.totalAmount ?? 0))).toFixed(2)),
|
|
9136
|
+
"isPaymentGatewayEnabled": isPaymentGatewayEnabled,
|
|
9137
|
+
"contactDetails": {
|
|
9138
|
+
"name": address.receiverName,
|
|
9139
|
+
"mobile": address.receiverPhone,
|
|
9140
|
+
"countryCode": "91",
|
|
9141
|
+
"email": address.receiverEmail
|
|
9142
|
+
},
|
|
9143
|
+
"paymentMerchantId": merchantId,
|
|
9144
|
+
"isJewellery": this.isJewellery,
|
|
9145
|
+
"referralId": result?.referralUniqueId
|
|
9146
|
+
};
|
|
9147
|
+
this.restService.createPaymentToken(payload).subscribe((paymentDetails) => {
|
|
9148
|
+
if (isPaymentGatewayEnabled)
|
|
9149
|
+
this._eventService.cashFreeEvent.emit(paymentDetails);
|
|
9150
|
+
else {
|
|
9151
|
+
localStorage.removeItem("orderId");
|
|
9152
|
+
localStorage.removeItem("cartId");
|
|
9153
|
+
localStorage.removeItem("paymentFor");
|
|
9154
|
+
this.storageService.clearUserCart();
|
|
9155
|
+
Swal.fire({
|
|
9156
|
+
icon: "success",
|
|
9157
|
+
title: "Hurray",
|
|
9158
|
+
text: "Order placed successfully",
|
|
9159
|
+
confirmButtonText: "See Details"
|
|
9160
|
+
}).then((response) => {
|
|
9161
|
+
if (response.isConfirmed) {
|
|
9162
|
+
this.router.navigate(['/profile']);
|
|
9163
|
+
}
|
|
9164
|
+
});
|
|
9165
|
+
}
|
|
9166
|
+
}, (error) => {
|
|
9167
|
+
if (error.errorCode == 1001 || error.errorCode == 1002) {
|
|
9168
|
+
Swal.fire({
|
|
9169
|
+
icon: "info",
|
|
9170
|
+
html: "<p>" + error.message.replace(/ *\([^)]*\) */g, "") + "</p>",
|
|
9171
|
+
showCancelButton: error.errorCode == 1002,
|
|
9172
|
+
confirmButtonText: "Remove item & Place Order",
|
|
9173
|
+
cancelButtonText: "Reduce quantity",
|
|
9174
|
+
cancelButtonColor: "#928c8c",
|
|
9175
|
+
}).then(async (response) => {
|
|
9176
|
+
this.messageService.add({ severity: 'info', summary: 'Processing', detail: 'Please wait, updaing your cart', life: 2000 });
|
|
9177
|
+
const regExp = /{([^}]+)}/g;
|
|
9178
|
+
const id = regExp.exec(error.message)?.[1];
|
|
9179
|
+
let itemDetail = null;
|
|
9180
|
+
const productDetailsAsync = await this.restService.getProductDetails(id).toPromise().then((response) => {
|
|
9181
|
+
itemDetail = response[0];
|
|
9182
|
+
});
|
|
9183
|
+
if (response.isDismissed) {
|
|
9184
|
+
this.cartInfo.orderedItems.forEach((item) => {
|
|
9185
|
+
if (item.itemId == itemDetail?.itemId)
|
|
9186
|
+
item.quantity = itemDetail?.itemInventory.openingStock;
|
|
9187
|
+
});
|
|
9188
|
+
const addItemDBAsync = await this.restService.addItemToDB(this.cartInfo).toPromise();
|
|
9189
|
+
const addItemIndexDBAsync = await this.storageService.addAllProductsToCart(this.cartInfo.orderedItems);
|
|
9190
|
+
}
|
|
9191
|
+
else if (response.isConfirmed) {
|
|
9192
|
+
this.cartInfo.orderedItems = this.cartInfo.orderedItems.filter((item) => item.itemId != itemDetail?.itemId);
|
|
9193
|
+
const addItemDBAsync = await this.restService.addItemToDB(this.cartInfo).toPromise();
|
|
9194
|
+
const addItemIndexDBAsync = await this.storageService.addAllProductsToCart(this.cartInfo.orderedItems);
|
|
9195
|
+
this.proceedToPayment();
|
|
9196
|
+
}
|
|
9197
|
+
});
|
|
9198
|
+
}
|
|
9199
|
+
else {
|
|
9200
|
+
this.messageService.add({ severity: 'error', summary: 'Payment Failure', detail: 'Please try again' });
|
|
9201
|
+
}
|
|
9202
|
+
});
|
|
9201
9203
|
}
|
|
9202
9204
|
addressSelected(index) {
|
|
9203
9205
|
this.selectedAddressIdx = index;
|