class Admin::Settings::SchoolsController < Admin::Controller
  def show
    render_success :ok, json: school_props
  end

  def update
    if current_school.update(school_params)
      render_success :ok
    else
      render_error :unprocessable_entity, errors: current_school
    end
  end

  private
    def school_params
      params.permit(
        :name,
        :short_name,
        :motto,
        :address,
        :address_ext,
        :city,
        :state,
        :zip,
        :county,
        :country_id,
        :time_zone
      )
    end

    def school_props
      {
        name: current_school.name,
        short_name: current_school.short_name,
        motto: current_school.motto,
        address: current_school.address,
        address_ext: current_school.address_ext,
        city: current_school.city,
        state: current_school.state,
        zip: current_school.zip,
        county: current_school.county,
        country_id: current_school.country_id,
        time_zone: current_school.time_zone
      }
    end
end
