import { Component, Input } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { UiCard } from '@app/components/ui-card';
import { InputFields } from '@/app/modules/components/input-fields';
import { InputGroups } from '@/app/modules/components/input-groups';
import { CheckboxesAndRadios } from '@/app/modules/components/checkboxes-and-radios';
import { FloatingLabels } from '@/app/modules/components/floating-labels';

@Component({
  selector: 'app-config',
  standalone: true,
  imports: [FormsModule, UiCard, InputFields, InputGroups, CheckboxesAndRadios, FloatingLabels],
  templateUrl: './config.html',
})
export class MerchantsConfig {
  @Input() merchantId: string = '';
  
  config = {
    apiKey: '',
    secretKey: '',
    webhookUrl: '',
    callbackUrls: {
      paymentSuccess: '',
      paymentFailed: '',
      subscriptionCreated: '',
      subscriptionCancelled: ''
    },
    allowedIPs: [''],
    rateLimit: 100,
    isActive: true,
    enableSMS: true,
    enableEmail: false
  };

  addIP() {
    this.config.allowedIPs.push('');
  }

  removeIP(index: number) {
    this.config.allowedIPs.splice(index, 1);
  }

  saveConfig() {
    console.log('Saving config:', this.config);
    // Logique de sauvegarde
  }

  testWebhook() {
    console.log('Testing webhook:', this.config.webhookUrl);
    // Logique de test
  }

  regenerateKeys() {
    console.log('Regenerating API keys');
    // Logique de régénération
  }
}