class Admin::Legacy::Student::SchoolYears::ExitReasonsController <
    Admin::Legacy::Student::Controller
  def index
    render_success :ok, json: items
  end

  private
    def school_year
      @school_year ||= current_school.school_years.find_by(id: params[:school_year_id])
    end

    def items
      if current_school.ed_fi_system?
        EdFi::Descriptor.by_exit_withdrawl_descriptor(current_school, school_year.academic_year)
          .map { |i| { text: i.name, value: i.code.to_i } }
      else
        default_descriptors
      end
    end

    def default_descriptors
      [
        { text: 'Graduation', value: 6 },
        { text: 'Transfer', value: 3 },
        { text: 'Maximum Age', value: 8 },
        { text: 'Dropout', value: 9 },
        { text: 'Death', value: 7 },
        { text: 'Withdrawl', value: 50 }
      ]
    end
end
