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

Skip to content

Conversation

@steven-tey
Copy link
Collaborator

@steven-tey steven-tey commented Aug 1, 2025

Summary by CodeRabbit

  • New Features

    • Added the ability for users to withdraw their pending program applications, including a confirmation modal and user feedback through notifications.
  • Improvements

    • Updated the program sidebar to simplify the display by always showing rewards and action buttons, removing loading placeholders.

@vercel
Copy link
Contributor

vercel bot commented Aug 1, 2025

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

Name Status Preview Updated (UTC)
dub ✅ Ready (Inspect) Visit Preview Aug 1, 2025 6:40pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 1, 2025

Walkthrough

This update introduces the ability for partners to withdraw their pending program applications. It adds a server-side action for withdrawal, integrates a confirmation modal and withdrawal button in the UI, manages loading and error states, and simplifies the sidebar by removing loading state checks for program enrollment rewards.

Changes

Cohort / File(s) Change Summary
Unapproved Program Page UI & Logic
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/unapproved-program-page.tsx
Adds a "Withdraw Application" button for pending applications, a confirmation modal, loading state management, and logic to call the new withdrawal action, handle navigation, and display toast notifications.
Program Sidebar Loading State
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/apply/program-sidebar.tsx
Removes the use of the program enrollment loading state, always renders the rewards list and button, and eliminates conditional UI based on loading.
Partner Application Withdrawal Action
apps/web/lib/actions/partners/withdraw-partner-application.ts
Introduces withdrawPartnerApplicationAction to allow authenticated partners to withdraw their pending program applications, deleting enrollment and application records if applicable, with validation and error handling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UnapprovedProgramPage
    participant ConfirmModal
    participant withdrawPartnerApplicationAction
    participant Router
    participant Toast

    User->>UnapprovedProgramPage: Clicks "Withdraw Application"
    UnapprovedProgramPage->>ConfirmModal: Opens confirmation modal
    User->>ConfirmModal: Confirms withdrawal
    ConfirmModal->>UnapprovedProgramPage: Triggers withdrawal
    UnapprovedProgramPage->>withdrawPartnerApplicationAction: Calls action with programId
    withdrawPartnerApplicationAction-->>UnapprovedProgramPage: Returns success or error
    UnapprovedProgramPage->>Router: Navigates to programs list (on success)
    UnapprovedProgramPage->>Toast: Shows success or error notification
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related PRs

  • Program status updates #2594: Adds the original UnapprovedProgramPage, which is directly extended in this PR to support withdrawal functionality for pending applications.

Poem

A bunny hops with glee today,
For partners now can walk away—
Withdraw with ease, no need to wait,
A modal asks, "Are you sure, mate?"
With actions swift and UI bright,
This code brings freedom into sight!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch withdraw-application

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 generate unit tests to generate unit tests for 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.

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: 2

🧹 Nitpick comments (2)
apps/web/lib/actions/partners/withdraw-partner-application.ts (2)

46-46: Remove console.log or replace with proper logging.

Console.log statements should not be present in production code. Consider using a proper logging library or remove this debug statement.

-    console.log("Deleted program enrollment", res);

27-30: Consider more user-friendly error message.

The error message could be more user-friendly by avoiding technical jargon like "pending".

-      throw new Error(
-        "You can only withdraw your application if it's still pending.",
-      );
+      throw new Error(
+        "You can only withdraw applications that are still under review.",
+      );
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9ee224b and 6d79705.

📒 Files selected for processing (3)
  • apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/unapproved-program-page.tsx (4 hunks)
  • apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/apply/program-sidebar.tsx (2 hunks)
  • apps/web/lib/actions/partners/withdraw-partner-application.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: in apps/web/ui/partners/rewards/rewards-logic.tsx, when setting the entity field in a reward conditi...
Learnt from: TWilson023
PR: dubinc/dub#2673
File: apps/web/ui/partners/rewards/rewards-logic.tsx:268-275
Timestamp: 2025-07-30T15:29:54.131Z
Learning: In apps/web/ui/partners/rewards/rewards-logic.tsx, when setting the entity field in a reward condition, dependent fields (attribute, operator, value) should be reset rather than preserved because different entities (customer vs sale) have different available attributes. Maintaining existing fields when the entity changes would create invalid state combinations and confusing UX.

Applied to files:

  • apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/apply/program-sidebar.tsx
  • apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/unapproved-program-page.tsx
📚 Learning: in apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx, the form schema uses partial condition ob...
Learnt from: TWilson023
PR: dubinc/dub#2673
File: apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx:56-66
Timestamp: 2025-07-30T15:25:13.936Z
Learning: In apps/web/ui/partners/rewards/add-edit-reward-sheet.tsx, the form schema uses partial condition objects to allow users to add empty/unconfigured condition fields without type errors, while submission validation uses strict schemas to ensure data integrity. This two-stage validation pattern improves UX by allowing progressive completion of complex forms.

Applied to files:

  • apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/apply/program-sidebar.tsx
📚 Learning: in the partnerprogramsummary email template (packages/email/src/templates/partner-program-summary.ts...
Learnt from: devkiran
PR: dubinc/dub#2448
File: packages/email/src/templates/partner-program-summary.tsx:0-0
Timestamp: 2025-05-29T04:45:18.504Z
Learning: In the PartnerProgramSummary email template (packages/email/src/templates/partner-program-summary.tsx), the stat titles are hardcoded constants ("Clicks", "Leads", "Sales", "Earnings") that will always match the ICONS object keys after toLowerCase() conversion, so icon lookup failures are not possible.

Applied to files:

  • apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/apply/program-sidebar.tsx
  • apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/unapproved-program-page.tsx
📚 Learning: in apps/web/ui/partners/design/previews/lander-preview.tsx, the ellipsis wave animation delay calcul...
Learnt from: TWilson023
PR: dubinc/dub#2614
File: apps/web/ui/partners/design/previews/lander-preview.tsx:181-181
Timestamp: 2025-07-09T20:52:56.592Z
Learning: In apps/web/ui/partners/design/previews/lander-preview.tsx, the ellipsis wave animation delay calculation `3 - i * -0.15` is intentionally designed to create negative delays that offset each dot's animation cycle. This pattern works correctly for the intended ellipsis effect and should not be changed to positive incremental delays.

Applied to files:

  • apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/apply/program-sidebar.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (3)
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/apply/program-sidebar.tsx (1)

28-34: Loading state handling is safe to remove

The sidebar renders server-provided program data immediately and falls back to application- or program-level rewards/discounts while the client fetches programEnrollment. Since we only use programEnrollment to adjust badge, rewards, and button text after loading, showing the UI immediately avoids unnecessary blocking or skeletons—and any brief “Apply” → “Accept invite” button text update is minimal and acceptable.

apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/unapproved-program-page.tsx (2)

105-116: LGTM! Well-implemented withdrawal UI.

The withdrawal button implementation is excellent:

  • Properly conditional (only shows for pending applications)
  • Clear labeling and styling
  • Proper loading state management
  • Good accessibility with the confirmation modal

53-72: Well-structured confirmation modal with comprehensive error handling.

The confirmation modal setup is well-implemented with:

  • Clear, descriptive messaging that explains consequences
  • Proper async error handling with try/catch/finally
  • Appropriate toast notifications for user feedback
  • Consistent loading state management

@steven-tey steven-tey merged commit 6fec9b5 into main Aug 1, 2025
10 checks passed
@steven-tey steven-tey deleted the withdraw-application branch August 1, 2025 18:44
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.

2 participants