Files
euchre_camp/app/actions/admin/matches/new.rb
T
david 5bb3bc4e5f feat: enhance match entry form with validation and data
Add improved match entry form with player selection validation and
better user experience for recording match results.

Changes:
- Add player validation to prevent same player on both teams
- Add team score validation (must have winner)
- Improve form layout and player selection UI
- Add helper methods for player lookup and team building
2026-03-27 12:24:53 -07:00

38 lines
1.0 KiB
Ruby

# frozen_string_literal: true
module EuchreCamp
module Actions
module Admin
module Matches
class New < EuchreCamp::Action
include Deps[
players_repo: 'repositories.players',
events_repo: 'repositories.events',
teams_repo: 'repositories.teams'
]
def handle(request, response)
players = players_repo.all
tournament = nil
teams = []
# Check if creating match for specific tournament
if request.params[:event_id]
tournament = events_repo.by_id(request.params[:event_id])
teams = teams_repo.by_event(tournament[:id])
end
response.render(view,
players: players,
tournament: tournament,
teams: teams,
preselected_team_1: request.params[:team_1_id]&.to_i,
preselected_team_2: request.params[:team_2_id]&.to_i
)
end
end
end
end
end
end