import {
  Component,
  input,
  output,
  inject,
  ChangeDetectionStrategy,
} from '@angular/core';
import { ButtonComponent } from '@isa/ui/buttons';
import { BonRedemptionStore } from '@isa/crm/data-access';

/**
 * Smart component for Bon redemption action button.
 *
 * Injects BonRedemptionStore for state management.
 *
 * Displays "Für Kunden verbuchen" button with pending state.
 *
 * @example
 * <crm-bon-redemption-button
 *   [disabled]="disabled"
 *   (redeem)="onRedeem()" />
 */
@Component({
  selector: 'crm-bon-redemption-button',
  imports: [ButtonComponent],
  templateUrl: './bon-redemption-button.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BonRedemptionButtonComponent {
  /**
   * Store for accessing state
   */
  readonly store = inject(BonRedemptionStore);

  /**
   * Whether the button should be disabled (from parent)
   */
  readonly disabled = input<boolean>(false);

  /**
   * Emits when redemption should be triggered
   */
  readonly redeem = output<void>();

  /**
   * Handle redemption button click
   */
  onRedeem(): void {
    this.redeem.emit();
  }
}
