Skip to content

Commit

Permalink
disable error handler on modalClose event
Browse files Browse the repository at this point in the history
  • Loading branch information
netzkollektiv committed Sep 25, 2024
1 parent e8642bb commit f43a5db
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/components/easycredit-checkout/easycredit-checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ export class EasycreditCheckout {
@State() selectedInstallment: InstallmentPlan = null
@State() submitDisabled = false

@Element() el: HTMLElement;

modal!: HTMLEasycreditModalElement;

caps: Caps
errorHandlerTimeout: number

@Listen('selectedInstallment')
selectedInstallmentHandler(e) {
Expand All @@ -43,6 +46,7 @@ export class EasycreditCheckout {
@Listen('closeModal')
closeModalHandler () {
this.modal.close()
clearTimeout(this.errorHandlerTimeout);
}

isEnabled(type: METHODS) {
Expand Down Expand Up @@ -79,13 +83,11 @@ export class EasycreditCheckout {
}
}

@Element() el: HTMLElement;

submitHandler() {
sendFeedback(this, { component: 'EasycreditCheckout', action: 'submit' })

this.submitButtonClicked = true
addErrorHandler(this, () => {
this.errorHandlerTimeout = addErrorHandler(this, () => {
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.'
this.modal.close()
})
Expand Down
4 changes: 2 additions & 2 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Loader } from './loader'
import { InstallmentPlans, InstallmentPlansContainer } from '../types'

export function addErrorHandler(component, callback) {
export function addErrorHandler(component, callback): number {
let time = 10

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

Expand Down

0 comments on commit f43a5db

Please sign in to comment.