import { Component, Input, TemplateRef } from '@angular/core';
import { UI_CONFIG } from '../../../config/ui.config';

@Component({
	selector: 'app-dialog-chrome',
	templateUrl: './dialog-chrome.component.html',
	styleUrls: ['./dialog-chrome.component.scss'],
})
export class DialogChromeComponent {
	@Input({ required: true }) title!: string;
	@Input({ required: true }) actions!: TemplateRef<unknown>;
	@Input() errorMessage?: string | null;
	/** Structured validation error (e.g. currency rate dialog). */
	@Input() error?: { title?: string; errors?: Record<string, unknown> } | null;

	readonly modalButtonsTop = UI_CONFIG.modal_buttons === 'top';

	get hasError(): boolean {
		return !!(this.errorMessage || this.error?.title || this.error?.errors);
	}
}
