class Admin::Legacy::Nursing::Students::ContactsController < Admin::Legacy::Nursing::Controller
  def index
    render_success :ok, json: contacts.map { |c| props(c) }
  end

  private
    def student
      @student ||= current_school.students.find_by(id: params[:student_id])
    end

    def contacts
      @contacts ||= student.all_contact_families.emergency.decorate
    end

    def props(contact)
      {
        id: contact.id,
        first_name: contact.first_name,
        last_name: contact.last_name,
        relationship: contact.relationship_name,
        work_phone: contact.work_phone,
        home_phone: contact.home_phone,
        cell_phone: contact.cell_phone,
        email: contact.email,
        email2: contact.email2,
        pickup: contact.pickup
      }
    end
end
