Skip to content

feat: enforce teamMin/teamMax limits in SubmissionForm#432

Closed
Anuoluwapo25 wants to merge 1 commit into
boundlessfi:mainfrom
Anuoluwapo25:team-size-limits
Closed

feat: enforce teamMin/teamMax limits in SubmissionForm#432
Anuoluwapo25 wants to merge 1 commit into
boundlessfi:mainfrom
Anuoluwapo25:team-size-limits

Conversation

@Anuoluwapo25

@Anuoluwapo25 Anuoluwapo25 commented Mar 2, 2026

Copy link
Copy Markdown

###Overview

This PR enforces hackathon team size constraints (teamMin, teamMax) directly within the SubmissionForm UI.

Users can no longer:

-Proceed with a team smaller than the configured minimum

-Invite members beyond the configured maximum

-This ensures organizer-defined limits are strictly respected at the interface level before submission.

Summary by CodeRabbit

  • New Features

    • Added team size validation enforcing minimum and maximum member limits during team formation.
    • Introduced member count badge displaying current members vs. maximum allowed in the Invite Members section.
    • Added warning message when team size falls below minimum, indicating additional members needed.
  • UX Improvements

@vercel

vercel Bot commented Mar 2, 2026

Copy link
Copy Markdown

@Anuoluwapo25 is attempting to deploy a commit to the Threadflow Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Mar 2, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The submission form now enforces team size constraints by validating maximum capacity when adding invitees and minimum requirements before progression. The Invite Members section displays a badge showing current vs. maximum members, warnings for undersized teams, and disables inputs when capacity is reached.

Changes

Cohort / File(s) Summary
Team Size Validation & UI Enhancement
components/hackathons/submissions/SubmissionForm.tsx
Adds maximum team size enforcement in handleAddInvitee with early return on capacity breach. Implements minimum size validation in handleNext with error toast. Updates Invite Members UI with dynamic member count badge, capacity warning paragraph, disabled input fields at max capacity, and aria-labels for accessibility status.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Poem

🐰 A team takes shape with careful measure,
Max and min now guard the treasure,
Badges gleam to show the way,
Disabled fields when full—hooray!
One hop closer, form perfected!

🚥 Pre-merge checks | ✅ 3
✅ 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 directly and accurately summarizes the main change: enforcing team size limits (teamMin/teamMax) in the SubmissionForm component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
components/hackathons/submissions/SubmissionForm.tsx (1)

790-817: Extract shared team-capacity booleans to reduce duplication.

invitees.length + 1 >= currentHackathon.teamMax and related calculations are repeated in multiple JSX props/branches. Centralizing into teamSize, isAtTeamMax, and membersNeeded will reduce drift risk and improve readability.

♻️ Suggested refactor
+  const teamSize = invitees.length + 1;
+  const isAtTeamMax = !!(
+    currentHackathon && teamSize >= currentHackathon.teamMax
+  );
+  const membersNeeded = currentHackathon
+    ? Math.max(currentHackathon.teamMin - teamSize, 0)
+    : 0;
...
-                              invitees.length + 1 >= currentHackathon.teamMax
+                              isAtTeamMax
...
-                            {invitees.length + 1} / {currentHackathon.teamMax}{' '}
+                            {teamSize} / {currentHackathon.teamMax}{' '}
                             members
...
-                        invitees.length + 1 < currentHackathon.teamMin && (
+                        membersNeeded > 0 && (
                           <p className='text-xs text-yellow-500'>
                             Minimum {currentHackathon.teamMin} members required
-                            — add{' '}
-                            {currentHackathon.teamMin - (invitees.length + 1)}{' '}
+                            — add {membersNeeded}{' '}
                             more to proceed.
                           </p>
                         )}
...
-                            disabled={
-                              !!(
-                                currentHackathon &&
-                                invitees.length + 1 >= currentHackathon.teamMax
-                              )
-                            }
+                            disabled={isAtTeamMax}
...
-                          disabled={
-                            !!(
-                              currentHackathon &&
-                              invitees.length + 1 >= currentHackathon.teamMax
-                            )
-                          }
+                          disabled={isAtTeamMax}
...
-                            currentHackathon &&
-                            invitees.length + 1 >= currentHackathon.teamMax
+                            isAtTeamMax
                               ? 'Team is at maximum capacity'
                               : 'Add member'
                           }

Also applies to: 827-832, 842-847, 856-861, 867-879

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/hackathons/submissions/SubmissionForm.tsx` around lines 790 - 817,
Compute shared team-capacity values once and reuse them: add local constants
(e.g., teamSize = invitees.length + 1, isAtTeamMax = teamSize >=
currentHackathon.teamMax, membersNeeded = Math.max(0, currentHackathon.teamMin -
teamSize)) near the top of the component or inside the SubmissionForm render so
all JSX uses these variables instead of repeating invitees.length + 1 and
arithmetic; update the Badge className condition, the Badge text, and all
conditional renders that reference teamMin/teamMax (the places currently using
invitees.length + 1) to use teamSize, isAtTeamMax, and membersNeeded (keeping
currentHackathon null checks as before).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@components/hackathons/submissions/SubmissionForm.tsx`:
- Around line 459-469: The current validation only enforces
currentHackathon.teamMin when creating a new team and skips the myTeam branch,
so existing teams can bypass minimum-size checks; update the submission flow in
SubmissionForm (the handler that checks invitees and myTeam) to apply the same
minimum-member validation for both new-team and myTeam branches by checking
currentHackathon.teamMin against the total members (invitees.length + 1 or the
existing team member count) before allowing submission, and surface the same
toast.error message when the team is below teamMin.

---

Nitpick comments:
In `@components/hackathons/submissions/SubmissionForm.tsx`:
- Around line 790-817: Compute shared team-capacity values once and reuse them:
add local constants (e.g., teamSize = invitees.length + 1, isAtTeamMax =
teamSize >= currentHackathon.teamMax, membersNeeded = Math.max(0,
currentHackathon.teamMin - teamSize)) near the top of the component or inside
the SubmissionForm render so all JSX uses these variables instead of repeating
invitees.length + 1 and arithmetic; update the Badge className condition, the
Badge text, and all conditional renders that reference teamMin/teamMax (the
places currently using invitees.length + 1) to use teamSize, isAtTeamMax, and
membersNeeded (keeping currentHackathon null checks as before).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6fc1293 and d37a179.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • components/hackathons/submissions/SubmissionForm.tsx

Comment thread components/hackathons/submissions/SubmissionForm.tsx

@Benjtalkshow Benjtalkshow left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Anuoluwapo25

Kindly make these changes:

  • In SubmissionForm.tsx, the minimum team size validation (teamMin) currently only applies when creating a new team, allowing submissions with existing teams (myTeam) to bypass the check. The submission logic should enforce the same minimum-member validation for both new and existing teams and display the same toast.error message when the team size is below teamMin.

  • Refactor the code to avoid repeating team-size calculations by introducing shared constants such as teamSize, isAtTeamMax, and membersNeeded, and reuse them across the component (badge display, conditions, and UI logic).

  • The max team size field should be derived from the hackathon rules data and should not be editable. It should control how many open roles a user can create.

  • The CodeRabbit feedback was marked as resolved without an accompanying fix commit. Please ensure all corrections are implemented in code and backed by a verifiable commit rather than resolving comments manually.

  • Make a screen record of creating a team post using an ongoing hackathon.

@Anuoluwapo25

Anuoluwapo25 commented Mar 5, 2026 via email

Copy link
Copy Markdown
Author

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.

Enforce Team Size Limits (teamMin, teamMax)

2 participants