class Admins::CompetitionPrizesController < Admins::BaseController
  def index
    @competition = current_competition
  end

  def new
    @prize = current_competition.competition_prizes.new
  end

  def create
    @prize = current_competition.competition_prizes.create!(save_params)
    render_ok
  end

  def edit
    @prize = current_competition_prize
  end

  def update
    current_competition_prize.update!(save_params)
    render_ok
  end

  def destroy
    current_competition_prize.destroy!

    render_delete_success
  end

  private

  def current_competition_prize
    @_current_competition_prize ||= current_competition.competition_prizes.find(params[:id])
  end

  def current_competition
    @_current_competition ||= Competition.find(params[:competition_id])
  end

  def save_params
    params.require(:competition_prize).permit(:name, :category, :num)
  end
end