# frozen_string_literal: true module EuchreCamp module Actions module Admin module Tournaments module Teams class Destroy < EuchreCamp::Action include Deps[teams_repo: 'repositories.teams'] def handle(request, response) tournament_id = request.params[:id] team_id = request.params[:team_id] teams_repo.delete(team_id.to_i) response.flash[:message] = "Team removed" response.redirect_to("/admin/tournaments/#{tournament_id}") rescue StandardError => e response.flash[:error] = "Failed to remove team: #{e.message}" response.redirect_to("/admin/tournaments/#{tournament_id}") end end end end end end end