class Admin::Legacy::Service::RequirementsController < Admin::Legacy::Service::Controller
  def show
    render_success :ok, json: requirement_props(requirement)
  end

  def update
    if requirement.update(requirement_params)
      render_success :ok, json: requirement_props(requirement)
    else
      render_error :unprocessable_entity, errors: requirement
    end
  end

  private
    def requirement
      @requirement ||= current_school.find_or_build_service_requirement
    end

    def requirement_params
      params.permit(:student_hours, :family_hours)
    end

    def requirement_props(requirement)
      {
        student_hours: requirement.student_hours,
        family_hours: requirement.family_hours
      }
    end
end
