Skip to content

feat: automatically sort sponsors based on tier priority#12

Closed
madhavansingh wants to merge 1 commit intoAOSSIE-Org:mainfrom
madhavansingh:feat/sponsor-tier-sorting
Closed

feat: automatically sort sponsors based on tier priority#12
madhavansingh wants to merge 1 commit intoAOSSIE-Org:mainfrom
madhavansingh:feat/sponsor-tier-sorting

Conversation

@madhavansingh
Copy link
Copy Markdown

@madhavansingh madhavansingh commented Mar 15, 2026

Addressed Issues:

Fixes #11

Screenshots/Recordings:

N/A – This change introduces internal logic to automatically sort sponsors by their sponsorship tier before rendering. There are no visual UI changes.

Additional Notes:

This PR introduces automatic sorting of sponsors based on their sponsorship tier priority.

Sponsors are now displayed in the following order:

Platinum → Gold → Silver → Bronze

This ensures that higher-tier sponsors receive appropriate visibility and maintains a consistent sponsorship hierarchy across implementations of the SupportUsButton component.

The sorting is implemented without mutating the original props array to maintain React best practices and TypeScript type safety.

Checklist

  • My code follows the project's code style and conventions
  • I have made corresponding changes to the documentation
  • 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 Contributing Guidelines

Summary by CodeRabbit

Release Notes

  • New Features
    • Sponsors are now displayed in organized order by sponsorship tier (Platinum, Gold, Silver, Bronze).

@github-actions github-actions Bot added enhancement New feature or request frontend Changes to frontend code javascript JavaScript/TypeScript code changes size/S Small PR (11-50 lines changed) first-time-contributor First PR of an external contributor pending-coderabbit-review labels Mar 15, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 15, 2026

Walkthrough

The SupportUsButton component now automatically sorts sponsors by sponsorship tier priority before rendering. A sorting mechanism orders sponsors from Platinum to Bronze, replacing the original unsorted sponsor list in all rendering operations and presence checks.

Changes

Cohort / File(s) Summary
Sponsor Tier Sorting
src/components/SupportUsButton.tsx
Adds Tier import and introduces sponsor sorting logic that orders sponsors by tier priority (Platinum < Gold < Silver < Bronze). Applies sortedSponsors throughout rendering logic, replacing direct sponsors usage while maintaining fallback handling for undefined/empty sponsor lists.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

Typescript Lang

Poem

🐰 Sponsors align in order grand,
Platinum first, as they planned,
Bronze brings up the rear so fine,
Tiers now sparkle, tier by line!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: automatic sorting of sponsors by tier priority.
Linked Issues check ✅ Passed The implementation satisfies all coding requirements from issue #11: sponsors are sorted in the correct priority order (Platinum→Gold→Silver→Bronze), sorting occurs within the component without mutating props, and TypeScript type safety is maintained.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the linked issue #11, focusing exclusively on implementing sponsor tier-based sorting with no unrelated modifications.

✏️ 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
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@madhavansingh
Copy link
Copy Markdown
Author

Hi maintainers,

I have implemented sponsor tier sorting as discussed in the issue.
This contribution is part of my open-source contributions while preparing for GSoC 2026 with AOSSIE.

Please let me know if any changes or improvements are required.
Thank you!

Copy link
Copy Markdown

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/SupportUsButton.tsx (1)

1-5: ⚠️ Potential issue | 🟡 Minor

Missing "use client" directive for client-side component.

This component uses React hooks patterns and renders interactive elements. As per coding guidelines for NextJS, client components should include the "use client" directive at the top of the file.

🛠️ Proposed fix
+"use client";
+
 import React from "react";
 import type { supportUsButtonProps } from "../types/index";
 import type { Theme } from "../types/index";
 import type { ButtonVariant } from "../types/index";
 import type { Tier } from "../types/index";

As per coding guidelines: **/*.{ts,tsx,js,jsx}: NextJS - Ensure that "use client" is being used.

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

In `@src/components/SupportUsButton.tsx` around lines 1 - 5, Add the NextJS client
directive by inserting the exact string "use client" as the very first line of
the SupportUsButton component file (before any imports) so the component (e.g.,
SupportUsButton and any hooks it uses) is treated as a client component; ensure
it appears above all import statements and keep the rest of the file unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/SupportUsButton.tsx`:
- Line 256: The conditional rendering uses a redundant truthy check; update the
JSX conditional in SupportUsButton so it only checks the array length (replace
"{sortedSponsors && sortedSponsors.length > 0 && (" with "{sortedSponsors.length
> 0 && ("), referring to the sortedSponsors variable to remove the unnecessary
"sortedSponsors &&" guard since sortedSponsors is always an array.
- Around line 74-84: Move the inline tierPriority object out of the
SupportUsButton component and define it once at module scope (e.g.,
TIER_PRIORITY: Record<Tier, number>) so it isn't recreated on every render; then
update the sorting logic inside sortedSponsors (used in SupportUsButton) to
reference TIER_PRIORITY instead of the local tierPriority variable. Ensure the
fallback tier handling (a.sponsorshipTier || 'Bronze') remains unchanged and
that the symbol names TIER_PRIORITY and sortedSponsors are used to locate the
changes.
- Around line 291-294: The map is using the array index as the React key
(sortedSponsors.map(... key={index})), which is unstable when the list is
sorted; change the key to a stable unique identifier such as sponsor.name or a
combination like `${sponsor.name}-${sponsor.link}` (use the sponsor variable
inside the sortedSponsors.map callback) so React reconciliation remains
predictable.

---

Outside diff comments:
In `@src/components/SupportUsButton.tsx`:
- Around line 1-5: Add the NextJS client directive by inserting the exact string
"use client" as the very first line of the SupportUsButton component file
(before any imports) so the component (e.g., SupportUsButton and any hooks it
uses) is treated as a client component; ensure it appears above all import
statements and keep the rest of the file unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: bb64eb77-2dc8-4bbf-a33b-a0cc21b8f678

📥 Commits

Reviewing files that changed from the base of the PR and between 6f9f9a2 and b7f1b0e.

📒 Files selected for processing (1)
  • src/components/SupportUsButton.tsx

Comment thread src/components/SupportUsButton.tsx
${Theme === "corporate" && "bg-blue-600/50"}`}
>
{sponsors && sponsors.length > 0 && (
{sortedSponsors && sortedSponsors.length > 0 && (
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Simplify redundant truthy check.

Since sortedSponsors is always an array (either sorted sponsors or []), the truthy check sortedSponsors && is redundant. An empty array is truthy in JavaScript.

♻️ Proposed simplification
-        {sortedSponsors && sortedSponsors.length > 0 && (
+        {sortedSponsors.length > 0 && (
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{sortedSponsors && sortedSponsors.length > 0 && (
{sortedSponsors.length > 0 && (
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/SupportUsButton.tsx` at line 256, The conditional rendering
uses a redundant truthy check; update the JSX conditional in SupportUsButton so
it only checks the array length (replace "{sortedSponsors &&
sortedSponsors.length > 0 && (" with "{sortedSponsors.length > 0 && ("),
referring to the sortedSponsors variable to remove the unnecessary
"sortedSponsors &&" guard since sortedSponsors is always an array.

Comment on lines +291 to 294
{sortedSponsors.map((sponsor, index) => (
<a
href={sponsor.link}
key={index}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider using a stable unique key instead of array index.

Using index as a key can cause rendering issues when the list order changes (which happens with sorting). If sponsor.name is unique, or a combination of sponsor.name and sponsor.link, consider using that as the key for more predictable React reconciliation.

♻️ Proposed fix using sponsor name as key
-              {sortedSponsors.map((sponsor, index) => (
+              {sortedSponsors.map((sponsor) => (
                 <a
                   href={sponsor.link}
-                  key={index}
+                  key={`${sponsor.name}-${sponsor.link ?? ''}`}
                   target="_blank"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{sortedSponsors.map((sponsor, index) => (
<a
href={sponsor.link}
key={index}
{sortedSponsors.map((sponsor) => (
<a
href={sponsor.link}
key={`${sponsor.name}-${sponsor.link ?? ''}`}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/SupportUsButton.tsx` around lines 291 - 294, The map is using
the array index as the React key (sortedSponsors.map(... key={index})), which is
unstable when the list is sorted; change the key to a stable unique identifier
such as sponsor.name or a combination like `${sponsor.name}-${sponsor.link}`
(use the sponsor variable inside the sortedSponsors.map callback) so React
reconciliation remains predictable.

@rahul-vyas-dev
Copy link
Copy Markdown
Contributor

@madhavansingh could you please send any visual guide for this?

@github-actions
Copy link
Copy Markdown

⚠️ This PR has merge conflicts.

Please resolve the merge conflicts before review.

Your PR will only be reviewed by a maintainer after all conflicts have been resolved.

📺 Watch this video to understand why conflicts occur and how to resolve them:
https://www.youtube.com/watch?v=Sqsz1-o7nXk

@rahul-vyas-dev
Copy link
Copy Markdown
Contributor

The conflict didn’t get resolved.

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

Labels

enhancement New feature or request first-time-contributor First PR of an external contributor frontend Changes to frontend code javascript JavaScript/TypeScript code changes pending-coderabbit-review PR has merge conflicts size/S Small PR (11-50 lines changed)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: automatically sort sponsors by sponsorship tier priority

2 participants