import { Directive, HostListener } from '@angular/core';

@Directive({
  // eslint-disable-next-line @angular-eslint/directive-selector
  selector: '[msfaPreventDoubleSubmit]',
})
export class PreventDoubleSubmitDirective {
  @HostListener('click', ['$event'])
  onSubmit(event: UIEvent): void {
    const clickCount = event.detail;

    if (clickCount > 1) {
      event.preventDefault();
    }
  }
}
