import { PhoneMenu } from '@/manager/shared/components/PhoneMenu';
import { BaseComponent } from '@/shared/base/BaseComponent';
import { Phone } from '@/shared/types/phone-types';

export class PhoneField extends BaseComponent {
  private readonly input = this.host.locator('input');
  private readonly prefixMenuButton = this.host.getByTestId('phone-prefix-button');
  private readonly menu = new PhoneMenu(this.prefixMenuButton);

  async fill(phone: Phone, country: string): Promise<void> {
    await this.menu.open();
    await this.menu.select(phone, country);
    await this.input.fill(phone.number);
  }
}
