Skip to content

fixes #368: add player count limit and date validation in TournamentHub#369

Open
compiler041 wants to merge 2 commits intoAOSSIE-Org:mainfrom
compiler041:fix/tournament-hub-clean
Open

fixes #368: add player count limit and date validation in TournamentHub#369
compiler041 wants to merge 2 commits intoAOSSIE-Org:mainfrom
compiler041:fix/tournament-hub-clean

Conversation

@compiler041
Copy link
Contributor

@compiler041 compiler041 commented Mar 22, 2026

Addressed Issues:

Fixes #368

Screenshots/Recordings:

Screenshot 2026-03-20 141007

**After:
Screenshot 2026-03-21 152434

Additional Notes:

Added client-side validation to TournamentHub.tsx:

  • Prevents tournament creation with a past start date
  • Enforces a minimum and maximum player count limit
  • Displays appropriate error messages to the user

AI Usage Disclosure:

  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: Claude

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

Summary by CodeRabbit

  • New Features

    • Customizable maximum participant limit during tournament creation with validation (requires valid power-of-two and bounds)
    • Tournament date picker restricted to today onwards and rejects invalid/missing start dates on submit
  • UI/UX Improvements

    • Participant avatar display capped at 6 with a “+N” overflow indicator
    • Updated tournament card layout styling
  • Bug Fixes

    • Creation form now fully resets new participant fields and related errors after creating a tournament

@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 134c86f6-b2bc-4343-be5a-f4b8a835339f

📥 Commits

Reviewing files that changed from the base of the PR and between bb763f1 and 4da700b.

📒 Files selected for processing (1)
  • frontend/src/Pages/TournamentHub.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/Pages/TournamentHub.tsx

📝 Walkthrough

Walkthrough

Add client-side validation and UI tweaks: enforce start date >= today, add configurable max participants with power-of-two and bounds checks, reset new participant fields on create, cap avatar display to 6 with “+N” overflow, and change card container overflow to hidden.

Changes

Cohort / File(s) Summary
Tournament creation form & UI
frontend/src/Pages/TournamentHub.tsx
Added participant options state (participantOption, customParticipants, customError), helper validation (isPowerOfTwo, getMaxParticipants) and logic to derive/validate maxParticipants; added start-date validation and set date input min to today; reset new fields after create; capped visible avatars to 6 with a “+N” overflow badge; changed tournament card container from overflow-visible to overflow-hidden.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I dug a hole, then dug some more,
I found a form and fixed the door,
Dates now march from today’s bright sun,
Players counted—powers of two, not one,
Six friends peek; the rest show “+N” — hop, done! 🎪

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check ❓ Inconclusive Avatar display capping (6 visible + overflow badge) and overflow-hidden styling adjustment appear to be scope creep not mentioned in issue #368, though they may be UI improvements. Clarify whether avatar capping and overflow styling changes were necessary for issue #368 or represent unrelated enhancements that should be reviewed separately.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: adding player count limits and date validation to TournamentHub, directly matching the PR's core objectives.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #368: enforces min/max player count validation, rejects past dates with error handling, and prevents form submission on validation failure.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can suggest fixes for GitHub Check annotations.

Configure the reviews.tools.github-checks setting to adjust the time to wait for GitHub Checks to complete.

@compiler041 compiler041 changed the title Add in tournamenthub.tsx fixes #368: add player count limit and date validation in TournamentHub Mar 22, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/src/Pages/TournamentHub.tsx`:
- Around line 84-85: The form relies on the date input's min attribute only; add
a submit-time validation inside handleCreate (and the other create/submit
handler around lines 278-285) that reads the chosen date (e.g., tournament date
state), parses it to a Date, compares it to today's date (ignoring time), and if
the chosen date is in the past set a clear error state/flag (e.g., setDateError
or setFormError) and return early so submission is blocked; reference
getMaxParticipants for context where maxParticipants is fetched and ensure the
new check runs before any create logic uses that value.
- Around line 60-75: getMaxParticipants currently validates minimum and
power-of-two but doesn't enforce an upper cap; update the function to compare
against a defined maximum (e.g. const MAX_PARTICIPANTS = 64) and if val >
MAX_PARTICIPANTS call setCustomError("Must be at most X.") and return null, then
clear error and return val; also ensure the non-custom branch (return
parseInt(participantOption)) validates/caps against MAX_PARTICIPANTS as well,
and add the max={MAX_PARTICIPANTS} attribute to the custom participants input so
the UI prevents oversized values; reference getMaxParticipants,
participantOption, customParticipants, setCustomError, and isPowerOfTwo when
making changes.
- Around line 319-329: The placeholder and helper text next to the custom input
conflict with the validation (power-of-two) — update the input placeholder (the
JSX input element with placeholder="e.g. 12, 20, 32") to show valid power-of-two
examples (e.g. "e.g. 8, 16, 32") and adjust the helper copy (the fallback <p>
that currently reads "Must be a power of 2...") if needed to match the
placeholder; keep the conditional rendering that shows {customError} unchanged
so validation errors still display.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 938278c6-1a68-4ad3-83be-6960f232264a

📥 Commits

Reviewing files that changed from the base of the PR and between 09ef1bb and bb763f1.

📒 Files selected for processing (1)
  • frontend/src/Pages/TournamentHub.tsx

@compiler041
Copy link
Contributor Author

I have resolved all the issues reported by coderabbit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: TournamentHub allows invalid dates and unrestricted player counts

1 participant