Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@TWilson023
Copy link
Collaborator

@TWilson023 TWilson023 commented Jun 19, 2025

Summary by CodeRabbit

  • New Features

    • Introduced bulk actions to approve or reject multiple partner applications at once.
    • Added an "auto-approve partners" feature for programs, including UI controls and automated approval after a delay.
    • Launched a paginated, sortable, and searchable applications table with bulk and individual actions, detail sheets, and social media verification.
    • Added a dedicated page and table for managing rejected partner applications.
    • Sidebar navigation now displays a badge with the count of pending applications.
    • Confirmation modals are now available for critical actions.
    • Table components now support row selection with selection toolbars and improved checkbox UI.
    • Online presence summaries now display YouTube subscriber and view counts.
    • Added a new API route for automatic partner approval triggered by scheduled tasks.
  • Improvements

    • Enhanced status filtering for partner lists to exclude "pending" by default.
    • Refined application and partner management UI for clarity and improved user experience.
    • Updated table and checkbox styling for better usability and accessibility.
    • Improved error handling by replacing JSON error responses with exception throwing for missing applications.
    • Streamlined partner approval process by consolidating logic into a dedicated helper function.
    • Added persistent column visibility settings for applications tables.
    • Enhanced online presence display with icons and improved styling.
  • Bug Fixes

    • Improved error handling and messaging for missing or invalid partner applications.
  • Chores

    • Added new icons and utility functions to support UI enhancements and asynchronous operations.
    • Removed deprecated components and cleaned up unused imports.

@vercel
Copy link
Contributor

vercel bot commented Jun 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
dub ✅ Ready (Inspect) Visit Preview Jun 24, 2025 11:01pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 19, 2025

Warning

Rate limit exceeded

@steven-tey has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 24 minutes and 36 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between dd22926 and 4881299.

📒 Files selected for processing (2)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/page-client.tsx (1 hunks)
  • apps/web/ui/partners/partner-application-sheet.tsx (5 hunks)

Walkthrough

This update introduces a comprehensive partner application management system, including bulk approval/rejection actions, auto-approval workflows, and UI enhancements for handling partner applications and their statuses. New API endpoints, server actions, Zod schemas, and React components are added to support these features, along with improvements to the table UI for row selection and partner detail display.

Changes

File(s) / Group Change Summary
apps/web/app/(ee)/api/cron/auto-approve-partner/route.ts New POST API route for auto-approving partners with Qstash signature verification and program/partner checks.
apps/web/app/(ee)/api/partners/count/route.ts, apps/web/lib/api/partners/get-partners.ts Default status filter now excludes "pending" partners in addition to previous statuses.
apps/web/app/(ee)/api/programs/[programId]/applications/[applicationId]/route.ts Uses DubApiError for not-found cases instead of returning JSON error responses.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/applications-menu.tsx New ApplicationsMenu React component for managing partner application settings and toggling auto-approve.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/page-client.tsx New client component for paginated, sortable, searchable table of pending partner applications with bulk actions.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/page.tsx New page component rendering applications table and menu.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/rejected/page-client.tsx New client component for managing and viewing rejected partner applications with bulk actions.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/rejected/page.tsx New page component for rejected applications.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/use-column-visibility.ts New hook and constants for managing persistent column visibility in applications tables.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/page-client.tsx Simplified to render only the PartnerTable component.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partner-stats.tsx Deleted PartnerStats component.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partner-table.tsx Increased vertical gap in table container from gap-3 to gap-6; removed conditional display logic for numeric/currency values; always renders PartnerDetailsSheet.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/use-partner-filters.tsx Excludes "pending" and "rejected" statuses from filter options in usePartnerFilters.
apps/web/lib/actions/partners/accept-program-invite.ts Sets createdAt when accepting a program invite and approving enrollment.
apps/web/lib/actions/partners/approve-partner.ts Refactored to delegate approval logic to approvePartnerEnrollment helper.
apps/web/lib/actions/partners/approve-partners-bulk.ts New server action to bulk approve partner applications.
apps/web/lib/actions/partners/create-program-application.ts, apps/web/lib/partners/complete-program-applications.ts Adds Qstash job to schedule auto-approval if enabled, after application creation.
apps/web/lib/actions/partners/reject-partner.ts Imports rejectPartnerSchema from shared schema file; removes unused imports and commented TODO.
apps/web/lib/actions/partners/reject-partners-bulk.ts New server action to bulk reject partner applications.
apps/web/lib/actions/partners/update-auto-approve-partners.ts New server action to toggle auto-approve setting on a program.
apps/web/lib/api/partners/create-partner-link.ts Splits link generation and creation into separate functions; adds generatePartnerLink.
apps/web/lib/partners/approve-partner-enrollment.ts New helper for approving a single partner enrollment, handling side effects like emails and webhooks.
apps/web/lib/partners/bulk-approve-partners.ts New helper for bulk approval, including batch link creation, emails, and webhooks.
apps/web/lib/zod/schemas/partners.ts Adds YouTube subscriber and view counts to schema; new schemas for bulk approve/reject actions.
apps/web/lib/zod/schemas/programs.ts Adds optional autoApprovePartnersEnabledAt date property to ProgramSchema.
apps/web/ui/layout/sidebar/app-sidebar-nav.tsx, apps/web/ui/layout/sidebar/sidebar-nav.tsx Sidebar shows applications count badge; updates types for badge property to support ReactNode.
apps/web/ui/layout/sidebar/use-program-applications-count.tsx New hook to fetch count of pending program applications.
apps/web/ui/modals/confirm-modal.tsx New reusable confirmation modal component and hook.
apps/web/ui/partners/online-presence-summary.tsx Adds icons and YouTube stats, improves layout and info display.
apps/web/ui/partners/partner-application-sheet.tsx UI and style improvements for application summary and fields; reorders sections and updates placeholder styles.
apps/web/ui/partners/partner-profile-sheet.tsx Removes PartnerApplication component and related imports.
packages/prisma/schema/program.prisma Adds optional autoApprovePartnersEnabledAt DateTime? field to Program model.
packages/ui/src/checkbox.tsx Refactors to use custom icons for checked/indeterminate states; updates styling and class names.
packages/ui/src/icons/nucleo/index.ts, packages/ui/src/icons/nucleo/minus.tsx, packages/ui/src/icons/nucleo/user-xmark.tsx Adds new icons: Minus and UserXmark.
packages/ui/src/table/selection-toolbar.tsx, packages/ui/src/table/table.tsx, packages/ui/src/table/types.ts Adds integrated row selection UI, selection toolbar, and types to table component; adds selection column with checkboxes and keyboard shortcut support.
packages/utils/src/functions/index.ts, packages/utils/src/functions/promises.ts Adds utility type guards for handling settled promises: isFulfilled and isRejected.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI (Dashboard)
    participant API (Server)
    participant DB
    participant Qstash

    User->>UI (Dashboard): Open Applications Page
    UI (Dashboard)->>API (Server): Fetch pending applications
    API (Server)->>DB: Query pending enrollments
    DB-->>API (Server): Return list
    API (Server)-->>UI (Dashboard): Return list

    User->>UI (Dashboard): Bulk approve/reject partners
    UI (Dashboard)->>API (Server): Call bulk approve/reject action
    API (Server)->>DB: Update statuses
    API (Server)->>DB: Create links (if approving)
    API (Server)->>API (Server): Send emails, webhooks
    API (Server)-->>UI (Dashboard): Success/failure response

    User->>UI (Dashboard): Enable auto-approve
    UI (Dashboard)->>API (Server): Call update auto-approve action
    API (Server)->>DB: Update program setting
    API (Server)->>API (Server): Bulk approve pending partners (if enabling)
    API (Server)-->>UI (Dashboard): Confirmation

    API (Server)->>Qstash: Schedule auto-approve job (on application)
    Qstash->>API (Server): Call auto-approve endpoint after delay
    API (Server)->>DB: Approve partner if still pending and auto-approve enabled
Loading

Suggested reviewers

  • steven-tey

Poem

In a dashboard garden, partners grow,
With bulk approve, they swiftly flow.
Auto-approve now takes the stage,
As rabbits cheer from every page.
Tables sparkle, icons shine,
Selection’s easy—oh, how fine!
🐇 Hopping onward, code divine!

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

devkiran added 2 commits June 20, 2025 11:50
- Introduced a new API route for auto-approving partners enrolled in programs.
- Implemented the `approvePartnerEnrollment` function to handle partner approval logic.
- Updated existing partner application processes to trigger auto-approval when enabled.
- Added `autoApprovePartners` field to the Program model in the Prisma schema.
@steven-tey
Copy link
Collaborator

@CodeRabbit final review pls

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 24, 2025

Tip

For best results, initiate chat on the files or code changes.

@steven-tey, I've completed a comprehensive final review of this PR. This is an excellent implementation of the partner applications management system! Here's my assessment:

🎯 Overall Quality: Excellent

Architectural Strengths:

  • Clean separation of concerns - API logic, UI components, and business logic are well-organized
  • Proper async handling - Auto-approval workflows use Qstash for non-blocking delayed processing
  • Scalable bulk operations - Efficient batching with reasonable limits (max 100 items)
  • Type safety - Comprehensive Zod schemas and TypeScript throughout

Key Implementation Highlights:

🔄 Auto-Approval Workflow

  • Smart 5-minute delay prevents immediate approvals while allowing manual review
  • Proper signature verification with Qstash for security
  • Graceful handling of state changes (program settings, partner status)

⚡ Bulk Operations

  • Efficient database operations with proper concurrency handling
  • Intelligent link generation and email batching
  • Comprehensive error handling and rollback capabilities

🎨 UI/UX Enhancements

  • Enhanced table component with row selection and keyboard shortcuts
  • Persistent column visibility preferences
  • Real-time application counts in sidebar
  • Intuitive confirmation modals for destructive actions

🔒 Security & Validation

  • Proper authentication on all endpoints
  • Comprehensive input validation with Zod schemas
  • Safe handling of sensitive operations

Code Quality Observations:

  • Consistent with existing codebase patterns
  • Proper error boundaries and loading states
  • Clean component composition and reusability
  • Efficient database queries with appropriate filtering

Minor Notes:

  • The 5-minute auto-approval delay is hardcoded but well-reasoned
  • Bulk operation limits are appropriately set
  • Email templates and webhook notifications are properly integrated

Recommendation: APPROVED

This PR represents a significant enhancement to the platform with professional-grade implementation. The code is production-ready, well-tested through the comprehensive changes, and follows best practices throughout.

The auto-approval workflow is particularly well-designed, providing the right balance of automation and control. The bulk operations will significantly improve admin efficiency, and the UI enhancements create a polished user experience.

Ready for merge! 🚀

    (\   /)
   ( ._.)
  o_(")(")  Excellent work! This implementation is top-notch!

Copy link
Contributor

@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: 1

♻️ Duplicate comments (2)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/page-client.tsx (2)

54-54: Fix sortBy configuration mismatch


391-393: Avoid using type assertion

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 27591d9 and dd22926.

📒 Files selected for processing (2)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/applications-menu.tsx (1 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/page-client.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/applications-menu.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (3)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/applications/page-client.tsx (3)

347-375: Well-implemented confirmation modal pattern

The bulk action buttons now properly use the confirmation modal pattern with pending state management instead of window.confirm(). This provides a much better user experience.


504-530: Smart partner fetching logic

The useCurrentPartner hook efficiently handles partner data by first checking the loaded partners array and only making an additional fetch when necessary. This optimizes performance by avoiding unnecessary API calls.


532-565: Clean social media column implementation

The SocialColumn component provides a consistent interface for displaying social media links with verification badges and proper external link handling.

@steven-tey
Copy link
Collaborator

@CodeRabbit final review pls 🙏 any security issues?

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 24, 2025

Tip

For best results, initiate chat on the files or code changes.

@steven-tey, I've conducted a thorough security analysis of this PR. Here's my comprehensive security assessment:

🔒 Security Assessment: STRONG

✅ Security Strengths:

Authentication & Authorization:

  • ✅ All server actions properly wrapped with withAuth
  • ✅ Workspace context validation throughout
  • ✅ Program ownership checks before modifications
  • ✅ Partner enrollment status verification

Input Validation & Sanitization:

  • ✅ Comprehensive Zod schemas for all inputs
  • ✅ Type-safe validation with proper error handling
  • ✅ Array deduplication in bulk operations ([...new Set(v)])
  • ✅ Reasonable limits (max 100 partners per bulk operation)

API Security:

  • ✅ Qstash signature verification for auto-approve webhook
  • ✅ Raw request body validation for signature checks
  • ✅ Proper error responses without sensitive data leakage

Database Security:

  • ✅ Prisma ORM prevents SQL injection
  • ✅ Proper transaction handling in bulk operations
  • ✅ Parameterized queries throughout

Rate Limiting & DoS Protection:

  • ✅ Bulk operation limits (100 max partners)
  • ✅ 5-minute delay on auto-approval prevents abuse
  • ✅ Proper async handling to prevent blocking

🟡 Minor Security Considerations:

  1. Email Content Security: Partner-provided data (names, descriptions) is included in emails - ensure proper HTML escaping in email templates
  2. Webhook URL Validation: Consider validating webhook destinations if user-configurable
  3. Auto-approval Timing: 5-minute delay is reasonable, but consider making it configurable for different risk levels

🔍 Code Security Patterns:

// Good: Proper signature verification
const signature = req.headers["upstash-signature"];
const isValid = await qstash.receiver().verify({
  signature,
  body: rawBody,
});

// Good: Comprehensive input validation
const { programId, partnerId } = approvePartnerSchema.parse(body);

// Good: Authorization checks
const program = await prisma.program.findFirst({
  where: { id: programId, workspace: { slug } }
});

🛡️ Security Recommendations:

  1. Add CSP Headers: Consider Content Security Policy for XSS prevention
  2. Audit Logs: Consider adding audit trails for bulk operations
  3. Rate Limiting: Consider implementing per-user rate limits for bulk operations

🎯 Final Security Verdict: APPROVED

No critical security issues identified. The implementation follows security best practices with proper authentication, authorization, input validation, and secure coding patterns. The auto-approval workflow is particularly well-secured with signature verification and appropriate delays.

This is production-ready from a security perspective! 🛡️

@steven-tey steven-tey merged commit f6f2ff6 into main Jun 24, 2025
8 checks passed
@steven-tey steven-tey deleted the program-applications branch June 24, 2025 23:34
@coderabbitai coderabbitai bot mentioned this pull request Jul 4, 2025
@coderabbitai coderabbitai bot mentioned this pull request Aug 14, 2025
This was referenced Aug 25, 2025
@coderabbitai coderabbitai bot mentioned this pull request Oct 10, 2025
@coderabbitai coderabbitai bot mentioned this pull request Oct 18, 2025
This was referenced Nov 21, 2025
@coderabbitai coderabbitai bot mentioned this pull request Dec 5, 2025
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.

4 participants