ng-easycommerce-v18 0.3.14-beta.10 → 0.3.14-beta.11
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/README.md +1 -1
- package/esm2022/lib/ec-components/auth-ec/login-form-ec/login-form-ec.component.mjs +3 -2
- package/esm2022/lib/ec-components/auth-ec/password-reset-ec/password-reset-ec.component.mjs +4 -3
- package/esm2022/lib/ec-components/widgets-ec/decidir-ec/decidir-ec.component.mjs +49 -27
- package/fesm2022/ng-easycommerce-v18.mjs +51 -27
- package/fesm2022/ng-easycommerce-v18.mjs.map +1 -1
- package/lib/ec-components/auth-ec/login-form-ec/login-form-ec.component.d.ts +1 -0
- package/lib/ec-components/auth-ec/password-reset-ec/password-reset-ec.component.d.ts +1 -0
- package/lib/ec-components/widgets-ec/decidir-ec/decidir-ec.component.d.ts +6 -0
- package/package.json +1 -1
|
@@ -8232,6 +8232,7 @@ class LoginFormEcComponent {
|
|
|
8232
8232
|
_formBuilder = inject(FormBuilder);
|
|
8233
8233
|
_toastService = inject(ToastService);
|
|
8234
8234
|
_router = inject(Router);
|
|
8235
|
+
platformId = inject(PLATFORM_ID);
|
|
8235
8236
|
showPassword = false;
|
|
8236
8237
|
/**
|
|
8237
8238
|
* Parametro para indicar si tras loguear
|
|
@@ -8277,7 +8278,7 @@ class LoginFormEcComponent {
|
|
|
8277
8278
|
this.loggedIn = true;
|
|
8278
8279
|
if (this.inCart) {
|
|
8279
8280
|
// Si se está en el carrito, se cierra el modal de login
|
|
8280
|
-
if (isPlatformBrowser(
|
|
8281
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
8281
8282
|
const modal = document.getElementById('modalInvitado');
|
|
8282
8283
|
if (modal) {
|
|
8283
8284
|
const modalInstance = window.bootstrap?.Modal?.getInstance(modal);
|
|
@@ -8709,6 +8710,7 @@ class PasswordResetEcComponent extends ComponentHelper {
|
|
|
8709
8710
|
ready = false;
|
|
8710
8711
|
token;
|
|
8711
8712
|
formGroup;
|
|
8713
|
+
platformId = inject(PLATFORM_ID);
|
|
8712
8714
|
constructor(authService, toastr, activedRoute, router, formBuilder) {
|
|
8713
8715
|
super();
|
|
8714
8716
|
this.authService = authService;
|
|
@@ -8760,7 +8762,7 @@ class PasswordResetEcComponent extends ComponentHelper {
|
|
|
8760
8762
|
};
|
|
8761
8763
|
sendToLogin = () => this.router.navigateByUrl('/auth/login');
|
|
8762
8764
|
showPassword = () => {
|
|
8763
|
-
if (!isPlatformBrowser(
|
|
8765
|
+
if (!isPlatformBrowser(this.platformId))
|
|
8764
8766
|
return;
|
|
8765
8767
|
const passwordInput = document.getElementById('contraseña1');
|
|
8766
8768
|
const showIcon = document.getElementById('show1');
|
|
@@ -8775,7 +8777,7 @@ class PasswordResetEcComponent extends ComponentHelper {
|
|
|
8775
8777
|
hideIcon?.classList.toggle('d-none');
|
|
8776
8778
|
};
|
|
8777
8779
|
showPassword2 = () => {
|
|
8778
|
-
if (!isPlatformBrowser(
|
|
8780
|
+
if (!isPlatformBrowser(this.platformId))
|
|
8779
8781
|
return;
|
|
8780
8782
|
const passwordInput = document.getElementById('contraseña2');
|
|
8781
8783
|
const showIcon = document.getElementById('show2');
|
|
@@ -10185,6 +10187,12 @@ class DecidirEcComponent extends ComponentHelper {
|
|
|
10185
10187
|
params;
|
|
10186
10188
|
showModal = false;
|
|
10187
10189
|
dataRedirect = () => this.apiConsts.getUrlBase() + 'shop-api/' + this.consts.getChannel() + '/decidir/' + this.cartService.cartToken + '/process-payment';
|
|
10190
|
+
platformId = inject(PLATFORM_ID);
|
|
10191
|
+
isBrowser = isPlatformBrowser(this.platformId);
|
|
10192
|
+
windowRef = this.isBrowser ? window : null;
|
|
10193
|
+
localStorageRef = this.windowRef?.localStorage ?? null;
|
|
10194
|
+
sessionStorageRef = this.windowRef?.sessionStorage ?? null;
|
|
10195
|
+
messageListener = (event) => this.handleIframeMessage(event);
|
|
10188
10196
|
constructor(renderer, connection, toastrService, consts, apiConsts, cartService, activedRoute, sanitizer, paramsService) {
|
|
10189
10197
|
super();
|
|
10190
10198
|
this.renderer = renderer;
|
|
@@ -10209,32 +10217,38 @@ class DecidirEcComponent extends ComponentHelper {
|
|
|
10209
10217
|
}
|
|
10210
10218
|
ngOnDestroy() {
|
|
10211
10219
|
// Remover el listener de mensajes
|
|
10212
|
-
|
|
10220
|
+
if (this.isBrowser && this.windowRef) {
|
|
10221
|
+
this.windowRef.removeEventListener('message', this.messageListener, false);
|
|
10222
|
+
}
|
|
10213
10223
|
// console.log("SE DESTROZA");
|
|
10214
10224
|
}
|
|
10215
10225
|
ngOnChanges() {
|
|
10216
10226
|
// console.log("SE CAMBIO");
|
|
10217
10227
|
}
|
|
10218
10228
|
openModal() {
|
|
10229
|
+
if (!this.isBrowser || !this.localStorageRef)
|
|
10230
|
+
return;
|
|
10219
10231
|
this.clearStorageState();
|
|
10220
|
-
|
|
10221
|
-
|
|
10232
|
+
this.localStorageRef.setItem('dataRedirect', this.dataRedirect());
|
|
10233
|
+
this.localStorageRef.setItem('dataDecidir', JSON.stringify({
|
|
10222
10234
|
...this.method,
|
|
10223
10235
|
total_amount: this.total_amount
|
|
10224
10236
|
}));
|
|
10225
|
-
|
|
10237
|
+
this.localStorageRef.setItem('subtotal', this.total_amount.toString());
|
|
10226
10238
|
this.showModal = true;
|
|
10227
10239
|
this.closeModal = '';
|
|
10228
10240
|
this.callState();
|
|
10229
10241
|
}
|
|
10230
10242
|
clearStorageState = () => {
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
|
|
10234
|
-
|
|
10235
|
-
|
|
10236
|
-
|
|
10237
|
-
|
|
10243
|
+
if (!this.isBrowser)
|
|
10244
|
+
return;
|
|
10245
|
+
this.sessionStorageRef?.removeItem('state');
|
|
10246
|
+
this.localStorageRef?.removeItem('state');
|
|
10247
|
+
this.localStorageRef?.removeItem('dataRedirect');
|
|
10248
|
+
this.localStorageRef?.removeItem('dataDecidir');
|
|
10249
|
+
this.localStorageRef?.removeItem('message');
|
|
10250
|
+
this.localStorageRef?.removeItem('subMessage');
|
|
10251
|
+
this.localStorageRef?.removeItem('subtotal');
|
|
10238
10252
|
};
|
|
10239
10253
|
clickClose = () => {
|
|
10240
10254
|
this.closeModal = 'cancel';
|
|
@@ -10242,14 +10256,18 @@ class DecidirEcComponent extends ComponentHelper {
|
|
|
10242
10256
|
this.processError('Se cancelo el pago con Decidir');
|
|
10243
10257
|
};
|
|
10244
10258
|
showMessage = () => {
|
|
10245
|
-
|
|
10246
|
-
|
|
10259
|
+
if (!this.isBrowser || !this.localStorageRef)
|
|
10260
|
+
return;
|
|
10261
|
+
let message = this.localStorageRef.getItem('message') || undefined;
|
|
10262
|
+
let subMessage = this.localStorageRef.getItem('subMessage') || undefined;
|
|
10247
10263
|
message && this.toastrService.show(message, {}, '', { closeButton: true, timeOut: 6000 });
|
|
10248
10264
|
subMessage && this.toastrService.show(subMessage, {}, '', { closeButton: true, timeOut: 6000 });
|
|
10249
10265
|
};
|
|
10250
10266
|
callState = () => {
|
|
10267
|
+
if (!this.isBrowser || !this.localStorageRef)
|
|
10268
|
+
return;
|
|
10251
10269
|
try {
|
|
10252
|
-
let state = this.closeModal != '' ? this.closeModal :
|
|
10270
|
+
let state = this.closeModal != '' ? this.closeModal : this.localStorageRef.getItem('state');
|
|
10253
10271
|
this.loading = true;
|
|
10254
10272
|
state && this.showMessage();
|
|
10255
10273
|
if (state) {
|
|
@@ -10284,16 +10302,20 @@ class DecidirEcComponent extends ComponentHelper {
|
|
|
10284
10302
|
// console.log("ERROR ENVIO BACK ", err);
|
|
10285
10303
|
};
|
|
10286
10304
|
getCheckoutDecidir = () => {
|
|
10305
|
+
if (!this.isBrowser)
|
|
10306
|
+
return;
|
|
10287
10307
|
this.loading = true;
|
|
10288
10308
|
this.dataDecidir = this.method;
|
|
10289
10309
|
this.url = this.sanitizer.bypassSecurityTrustResourceUrl('assets/decidirFormEc.html');
|
|
10290
10310
|
this.loading = false;
|
|
10291
10311
|
// Escuchar mensajes del iframe para manejar la comunicación
|
|
10292
|
-
|
|
10312
|
+
this.windowRef?.addEventListener('message', this.messageListener, false);
|
|
10293
10313
|
};
|
|
10294
10314
|
handleIframeMessage = (event) => {
|
|
10295
10315
|
// Verificar el origen por seguridad
|
|
10296
|
-
if (
|
|
10316
|
+
if (!this.isBrowser || !this.windowRef)
|
|
10317
|
+
return;
|
|
10318
|
+
if (event.origin !== this.windowRef.location.origin) {
|
|
10297
10319
|
return;
|
|
10298
10320
|
}
|
|
10299
10321
|
if (event.data && event.data.type === 'DECIDIR_PAYMENT') {
|
|
@@ -10302,6 +10324,8 @@ class DecidirEcComponent extends ComponentHelper {
|
|
|
10302
10324
|
}
|
|
10303
10325
|
};
|
|
10304
10326
|
processPayment = (paymentData) => {
|
|
10327
|
+
if (!this.isBrowser)
|
|
10328
|
+
return;
|
|
10305
10329
|
this.loading = true;
|
|
10306
10330
|
this.connection.post('shop-api/' + this.consts.getChannel() + '/decidir/' + this.cartService.cartToken + '/process-payment')
|
|
10307
10331
|
.subscribe({
|
|
@@ -10309,33 +10333,33 @@ class DecidirEcComponent extends ComponentHelper {
|
|
|
10309
10333
|
this.loading = false;
|
|
10310
10334
|
// console.log('Respuesta del backend:', response);
|
|
10311
10335
|
if (response.status === 'approved' || response.status === 'partially_authorized') {
|
|
10312
|
-
|
|
10336
|
+
this.localStorageRef?.setItem('state', response.status === 'approved' ? 'success' : 'partially_authorized');
|
|
10313
10337
|
if (response.message)
|
|
10314
|
-
|
|
10338
|
+
this.localStorageRef?.setItem('message', response.message);
|
|
10315
10339
|
if (response.subMessage)
|
|
10316
|
-
|
|
10340
|
+
this.localStorageRef?.setItem('subMessage', response.subMessage);
|
|
10317
10341
|
this.callState();
|
|
10318
10342
|
}
|
|
10319
10343
|
else {
|
|
10320
|
-
|
|
10344
|
+
this.localStorageRef?.setItem('state', 'failure');
|
|
10321
10345
|
if (response.message)
|
|
10322
|
-
|
|
10346
|
+
this.localStorageRef?.setItem('message', response.message);
|
|
10323
10347
|
if (response.subMessage)
|
|
10324
|
-
|
|
10348
|
+
this.localStorageRef?.setItem('subMessage', response.subMessage);
|
|
10325
10349
|
this.callState();
|
|
10326
10350
|
}
|
|
10327
10351
|
},
|
|
10328
10352
|
error: (error) => {
|
|
10329
10353
|
this.loading = false;
|
|
10330
10354
|
console.error('Error processing payment:', error);
|
|
10331
|
-
|
|
10355
|
+
this.localStorageRef?.setItem('state', 'failure');
|
|
10332
10356
|
this.processError('Error al procesar el pago');
|
|
10333
10357
|
this.callState();
|
|
10334
10358
|
}
|
|
10335
10359
|
});
|
|
10336
10360
|
};
|
|
10337
10361
|
resizeIframe = (obj) => {
|
|
10338
|
-
if (typeof document === 'undefined' || !obj.contentWindow || !obj.contentWindow.document)
|
|
10362
|
+
if (!this.isBrowser || typeof document === 'undefined' || !obj.contentWindow || !obj.contentWindow.document)
|
|
10339
10363
|
return;
|
|
10340
10364
|
obj.style.height = obj.contentWindow.document.body.scrollHeight + 'px';
|
|
10341
10365
|
obj.style.width = obj.contentWindow.document.body.scrollWidth + 'px';
|