module Workstation
  class AddArtistModal < UniversalPage
    text_field(:artist_name, id: "createArtistModalArtistName")
    div(:artist_name_error, id: "artistNameError")
    select(:artist_country, id: "artistCountry")
    link(:submit, text: "Create Artist")
    button(:close_modal_window, class: %w[close btn])

    def wait_for_modal_to_load
      close_modal_window_element.wait_until(timeout: 60, &:present?)
    end

    def create_artist(name)
      default_country = "USA"
      artist_name_element.when_present(90)
      self.artist_name = name
      self.artist_country = default_country
      submit
      artist_name_element.when_not_present(60)
    end
  end
end
