import { Component, Output, EventEmitter } from '@angular/core';
import { NgClass } from '@angular/common';

export type ExportFormat = 'csv' | 'excel' | 'txt';

@Component({
  selector: 'app-export-chat-button',
  standalone: true,
  imports: [NgClass],
  templateUrl: './export-chat-button.html',
  styleUrl: './export-chat-button.scss'
})
export class ExportChatButton {
  @Output() onExport = new EventEmitter<ExportFormat>();

  isDropdownActive: boolean = false;

  toggleDropdown() {
    this.isDropdownActive = !this.isDropdownActive;
  }

  exportAs(format: ExportFormat, event: Event) {
    event.stopPropagation();
    this.onExport.emit(format);
    this.isDropdownActive = false;
  }
}
