module Project
  module SalesGoalsCommon
    include PageObject
    include PageHelpers::ReactHelpers

    spans(:goal_value, class: "TargetMarketGoalsListItem-goal-value")
    elements(:delete_goal, class: "Icons-trash-can")
    elements(:edit_goal, class: "Icons-edit")
    button(:confirm_submit, id: "confirm-submit")
    text_fields(:goal_input, id: "label-goal")
    text_fields(:dist, id: "distribution-goal")
    text_field(:first_week_estimate, id: "first-week-sale-estimate")
    react_select(:target_market_dropdown, class: "AddTargetMarket")
    h4(:target_country_name, class: "TargetMarketGoalsForm-country-name")
    button(:save_sales_estimate) do
      div_element(class: "TargetMarketGoalsForm-controls").button_element(text: "Save")
    end
    div(:target_goal_item, class: "TargetMarketGoalsListItem")

    def delete_all_goals
      delete_goal_elements.each do |icon|
        icon.click
        confirm_submit
      end
    end
  end
end
