Skip to content

Commit f43a5db

Browse files
committed
disable error handler on modalClose event
1 parent e8642bb commit f43a5db

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/components/easycredit-checkout/easycredit-checkout.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ export class EasycreditCheckout {
2626
@State() selectedInstallment: InstallmentPlan = null
2727
@State() submitDisabled = false
2828

29+
@Element() el: HTMLElement;
30+
2931
modal!: HTMLEasycreditModalElement;
3032

3133
caps: Caps
34+
errorHandlerTimeout: number
3235

3336
@Listen('selectedInstallment')
3437
selectedInstallmentHandler(e) {
@@ -43,6 +46,7 @@ export class EasycreditCheckout {
4346
@Listen('closeModal')
4447
closeModalHandler () {
4548
this.modal.close()
49+
clearTimeout(this.errorHandlerTimeout);
4650
}
4751

4852
isEnabled(type: METHODS) {
@@ -79,13 +83,11 @@ export class EasycreditCheckout {
7983
}
8084
}
8185

82-
@Element() el: HTMLElement;
83-
8486
submitHandler() {
8587
sendFeedback(this, { component: 'EasycreditCheckout', action: 'submit' })
8688

8789
this.submitButtonClicked = true
88-
addErrorHandler(this, () => {
90+
this.errorHandlerTimeout = addErrorHandler(this, () => {
8991
this.alert = 'Leider ist eine Zahlung mit easyCredit derzeit nicht möglich. Bitte verwenden Sie eine andere Zahlungsart oder wenden Sie sich an den Händler.'
9092
this.modal.close()
9193
})

src/utils/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Loader } from './loader'
22
import { InstallmentPlans, InstallmentPlansContainer } from '../types'
33

4-
export function addErrorHandler(component, callback) {
4+
export function addErrorHandler(component, callback): number {
55
let time = 10
66

7-
let timeout = window.setTimeout(() => {
7+
const timeout: number = window.setTimeout(() => {
88
console.error('No event handler handled the submit event of <easycredit-checkout> within ' + time + ' seconds. Please check the integration.')
99
sendFeedback(component, { component: 'EasycreditCheckout', action: 'error' })
1010

0 commit comments

Comments
 (0)