+
Skip to content

Conversation

steven-tey
Copy link
Collaborator

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

Summary by CodeRabbit

  • Refactor
    • Consolidated imports of UI components for improved maintainability.
    • Changed the export of the EditColumnsButton component to a named export and updated related exports.
    • Removed the columns prop from the Table component, streamlining its usage.
  • Bug Fixes
    • Marked the earnings field in the partner schema as deprecated to improve data clarity.
  • Enhancements
    • Improved program navigation by updating workspace data before redirecting to the default program page.
    • Optimized program data fetching by relying on the default program identifier instead of the full programs list.
    • Streamlined onboarding flow by removing automatic redirection query parameters after program creation.
    • Updated support email placeholder and refined input field focus behavior for better user experience.
    • Enhanced workspace data refresh and redirect logic for program authorization to better handle missing default programs.
    • Updated program creation process to improve concurrency handling and cleanup.
    • Adjusted program deletion to reset workspace default program when applicable.
    • Improved program authorization component to use client-side navigation with loading states for smoother user experience.

Copy link
Contributor

vercel bot commented Jun 1, 2025

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

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

Copy link
Contributor

coderabbitai bot commented Jun 1, 2025

Walkthrough

The changes consolidate imports of the EditColumnsButton component into grouped imports from "@dub/ui" and switch its export from default to named. The earnings field in a partner schema was marked as deprecated. The columns prop was removed from the Table component parameters. Navigation and data-fetching logic related to programs and onboarding were simplified by removing redundant mutations and redirects. A deletion script was updated to reset a project's defaultProgramId before program removal. Minor UI input placeholder and autofocus attribute adjustments were also made. The ProgramAuth component now refreshes workspace data and adjusts redirect logic based on defaultProgramId and partnersEnabled.

Changes

File(s) Change Summary
.../(dashboard)/[slug]/(ee)/programs/[programId]/partners/partner-table.tsx
.../customer-table/customer-table.tsx
.../events-table.tsx
Consolidated EditColumnsButton import to grouped "@dub/ui" import; removed direct/local imports.
packages/ui/src/table/edit-columns-button.tsx Changed imports to local paths; switched EditColumnsButton from default to named export.
packages/ui/src/table/index.ts Added export: re-exported all from "./edit-columns-button".
packages/ui/src/table/table.tsx Removed columns prop from Table component's parameter list.
apps/web/lib/zod/schemas/partners.ts Marked earnings field as deprecated with OpenAPI metadata and updated description.
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/programs/new/overview/page-client.tsx Removed mutate from swr; removed mutateWorkspace() call after onboarding success; no cache mutation now.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/page.tsx Changed workspace data fetch to only get defaultProgramId; updated redirect logic accordingly.
apps/web/lib/actions/partners/onboard-program.ts Removed redirect to new program page with query parameter after program creation during onboarding.
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/programs/new/support/form.tsx Changed support email placeholder; removed autoFocus from some inputs, keeping it only on support email.
apps/web/scripts/partners/delete-program.ts Updated target program ID; added step to clear project's defaultProgramId before deleting program.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/auth.tsx Added workspace data refresh on missing defaultProgramId; simplified redirect logic based on partnersEnabled and defaultProgramId.
apps/web/lib/actions/partners/create-program.ts Wrapped program creation and workspace update in a transaction; deferred partner invitations and cleanup with Promise.allSettled; changed to redirect after creation.

Sequence Diagram(s)

sequenceDiagram
    participant PageClient as New Program Page Client
    participant WorkspaceAPI as Workspace Data API
    participant Navigation as Next.js Navigation

    PageClient->>WorkspaceAPI: mutateWorkspace()
    WorkspaceAPI-->>PageClient: updated workspace data
    PageClient->>Navigation: redirect to new program page (using defaultProgramId)
Loading
sequenceDiagram
    participant ProgramsPage as Programs Page
    participant DB as Database
    participant Navigation as Next.js Navigation

    ProgramsPage->>DB: fetch workspace with defaultProgramId only
    DB-->>ProgramsPage: workspace data with defaultProgramId
    ProgramsPage->>ProgramsPage: if no defaultProgramId, redirect to /dashboard
    ProgramsPage->>Navigation: redirect to defaultProgramId program page
Loading
sequenceDiagram
    participant ProgramAuth as ProgramAuth Component
    participant WorkspaceAPI as Workspace Data API
    participant Navigation as Next.js Navigation

    ProgramAuth->>WorkspaceAPI: mutateWorkspace() if no defaultProgramId
    WorkspaceAPI-->>ProgramAuth: updated workspace data
    ProgramAuth->>ProgramAuth: check partnersEnabled and defaultProgramId
    alt defaultProgramId missing and partnersEnabled true
        ProgramAuth->>Navigation: redirect to /[slug]/programs/new
    else defaultProgramId missing and partnersEnabled false
        ProgramAuth->>Navigation: redirect to /[slug]
    end
Loading

Suggested reviewers

  • TWilson023

Poem

In the warren, code hops anew,
Imports gathered, columns few.
Buttons renamed, exports aligned,
Schema fields left behind.
The table now sets its own array,
Programs redirect a clearer way,
Rabbits tidy up the day! 🐇✨


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fc8ca56 and 80759c5.

📒 Files selected for processing (4)
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/programs/new/overview/page-client.tsx (1 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/auth.tsx (1 hunks)
  • apps/web/lib/actions/partners/create-program.ts (4 hunks)
  • apps/web/scripts/partners/delete-program.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/web/scripts/partners/delete-program.ts
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/programs/new/overview/page-client.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/auth.tsx
  • apps/web/lib/actions/partners/create-program.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

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

@steven-tey steven-tey requested a review from Copilot June 1, 2025 21:44
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the table components, updates the column-editing button export, removes the columns prop from Table, and streamlines partner onboarding and schema fields.

  • Refactor Table API by dropping the columns prop
  • Switch EditColumnsButton to a named export and update imports
  • Remove earnings from partner schema and simplify onboarding action

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/ui/src/table/table.tsx Removed the columns prop from Table component signature
packages/ui/src/table/index.ts Re-exported edit-columns-button alongside other table exports
packages/ui/src/table/edit-columns-button.tsx Changed EditColumnsButton to a named export and updated imports
apps/web/lib/zod/schemas/partners.ts Deleted earnings field from EnrolledPartnerSchema
apps/web/lib/actions/partners/onboard-program.ts Removed redirect logic after creating a program
apps/web/app/.../programs/page.tsx Switched redirect to use defaultProgramId
apps/web/app/.../customer-table.tsx, events-table.tsx, etc. Updated imports to use named EditColumnsButton
Comments suppressed due to low confidence (3)

packages/ui/src/table/table.tsx:288

  • Dropping the columns prop is a breaking change; update any documentation, TypeScript definitions, and bump the package version accordingly to signal consumers about the API change.
columns,

apps/web/lib/zod/schemas/partners.ts:242

  • The earnings field was removed from the schema—ensure any dependent data transformations or UI logic that relied on this field are covered by tests and updated to prevent runtime errors.
earnings: z.number().default(0)

apps/web/lib/actions/partners/onboard-program.ts:32

  • Removing the redirect and program ID assignment breaks the onboarding flow—users won’t be navigated to the new program. Consider restoring the redirect with the created program’s ID or explicitly handling navigation in the caller.
return;

import { Popover } from "../popover";

export default function EditColumnsButton({ table }: { table: Table<any> }) {
export function EditColumnsButton({ table }: { table: Table<any> }) {
Copy link

Copilot AI Jun 1, 2025

Choose a reason for hiding this comment

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

[nitpick] Since EditColumnsButton switched from default to named export, update any README, component docs, or Storybook stories to reflect the new import syntax.

Copilot uses AI. Check for mistakes.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 07efe13 and b63f364.

📒 Files selected for processing (3)
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/programs/new/overview/page-client.tsx (2 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/page.tsx (1 hunks)
  • apps/web/lib/actions/partners/onboard-program.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/web/lib/actions/partners/onboard-program.ts (1)
apps/web/lib/actions/partners/create-program.ts (1)
  • createProgram (17-181)
apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/programs/new/overview/page-client.tsx (1)
apps/web/lib/actions/partners/onboard-program.ts (1)
  • onboardProgramAction (12-39)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (4)
apps/web/lib/actions/partners/onboard-program.ts (1)

28-32: Good refactoring to separate navigation concerns.

The removal of server-side redirect logic aligns well with the coordinated changes across the codebase. Server actions now focus purely on data mutations while client-side components handle navigation using the workspace's defaultProgramId.

apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/page.tsx (1)

15-15: Excellent optimization to reduce data fetching.

Fetching only defaultProgramId instead of the full programs list is more efficient and aligns with the simplified navigation logic.

apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/programs/new/overview/page-client.tsx (2)

13-13: Good addition for client-side navigation.

Adding the redirect import supports the shift from server-side to client-side navigation control.


26-26: Correctly accessing defaultProgramId from workspace context.

This aligns with the pattern of using defaultProgramId for navigation throughout the application.

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

🔭 Outside diff range comments (1)
apps/web/scripts/partners/delete-program.ts (1)

6-58: 🛠️ Refactor suggestion

Add error handling for production safety.

The script lacks error handling, which could lead to silent failures or partial completion in production environments.

Consider adding try-catch blocks and logging:

 async function main() {
+  try {
     // existing operations...
     
     console.log("Successfully deleted program", deletedProgram);
+  } catch (error) {
+    console.error("Failed to delete program:", error);
+    process.exit(1);
+  }
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b63f364 and 2a32322.

📒 Files selected for processing (5)
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/programs/new/overview/page-client.tsx (1 hunks)
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/programs/new/support/form.tsx (1 hunks)
  • apps/web/lib/actions/partners/onboard-program.ts (1 hunks)
  • apps/web/lib/zod/schemas/partners.ts (1 hunks)
  • apps/web/scripts/partners/delete-program.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/programs/new/support/form.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/web/lib/actions/partners/onboard-program.ts
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/programs/new/overview/page-client.tsx
  • apps/web/lib/zod/schemas/partners.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (1)
apps/web/scripts/partners/delete-program.ts (1)

9-9: LGTM - Updated target program ID.

The program ID update is straightforward and appears to target a different program for deletion.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2a32322 and ac223f3.

📒 Files selected for processing (2)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/auth.tsx (1 hunks)
  • apps/web/scripts/partners/delete-program.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/scripts/partners/delete-program.ts
⏰ 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)/programs/[programId]/auth.tsx (3)

11-11: LGTM: Import addition is correct.

The addition of useEffect to the React imports is necessary for the new hook implementation below.


14-21: Good practice: Descriptive function renaming.

Renaming mutate to mutateWorkspace improves code readability and makes the function's purpose clearer.


40-46:

✅ Verification successful

Verify the removal of empty string check.

The redirect logic was simplified by removing the check for defaultProgramId === "". This could be problematic if the API can return an empty string instead of null/undefined for missing program IDs.

Please verify that defaultProgramId is never returned as an empty string from the API:


🏁 Script executed:

#!/bin/bash
# Description: Search for empty string checks and API responses related to defaultProgramId
# Expected: Confirm whether empty string handling is still needed

# Search for empty string checks on defaultProgramId
rg -A 3 -B 3 'defaultProgramId.*==.*""'

# Search for API endpoints or responses that might return defaultProgramId
rg -A 5 -B 5 'defaultProgramId'

Length of output: 29538


Empty string check on defaultProgramId is unnecessary
Based on the Prisma schema and update scripts, defaultProgramId is only ever assigned a valid program ID or null—it cannot be an empty string. You can safely rely on the simplified redirect logic.

  • packages/prisma/schema/workspace.prisma: defaultProgramId String? (no empty-string default)
  • apps/web/scripts/partners/{create-program.ts, delete-program.ts} & backfill-default-program-ids.ts only set defaultProgramId to an ID or null

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

🔭 Outside diff range comments (1)
apps/web/lib/actions/partners/create-program.ts (1)

146-158: ⚠️ Potential issue

Partners are invited twice (await + deferred)

The partners are invited immediately with await Promise.all(...) and again inside waitUntil (lines 162-172).
This results in:

  • duplicate partner records,
  • duplicate links,
  • duplicate email notifications.

Remove one of the two calls (usually the awaited one) or gate the second call behind a feature flag/condition.

-// invite the partners
-if (partners && partners.length > 0) {
-  await Promise.all(
-    partners.map((partner) =>
-      invitePartner({ ... }),
-    ),
-  );
-}
🧹 Nitpick comments (1)
apps/web/lib/actions/partners/create-program.ts (1)

160-172: Non-promise values passed to Promise.allSettled

Inside Promise.allSettled you spread the result of the conditional partners map which is OK, but if partners is [] you pass an empty array (fine), whereas the uploaded-logo deletion expression can resolve to boolean false, also fine.
However, readability suffers and consumers of the settled results must now handle heterogeneous value types.

Consider normalising the list so every entry is a Promise, e.g.:

const tasks: Promise<unknown>[] = [];

if (partners?.length) tasks.push(...partners.map(invitePartner));
tasks.push(
  prisma.program.update({ ... }),
  uploadedLogo && isStored(uploadedLogo)
    ? storage.delete(...)
    : Promise.resolve()
);

waitUntil(Promise.allSettled(tasks));
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ac223f3 and fc8ca56.

📒 Files selected for processing (6)
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/programs/new/overview/page-client.tsx (1 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/auth.tsx (1 hunks)
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/page.tsx (1 hunks)
  • apps/web/lib/actions/partners/create-program.ts (3 hunks)
  • apps/web/lib/actions/partners/onboard-program.ts (1 hunks)
  • apps/web/scripts/partners/delete-program.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • apps/web/lib/actions/partners/onboard-program.ts
  • apps/web/scripts/partners/delete-program.ts
  • apps/web/app/(ee)/app.dub.co/(new-program)/[slug]/programs/new/overview/page-client.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/page.tsx
  • apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/auth.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (1)
apps/web/lib/actions/partners/create-program.ts (1)

134-138: 🛠️ Refactor suggestion

programOnboarding: undefined may not remove the key in JSON

Setting a JSON column to { …, programOnboarding: undefined } often serialises to null, leaving the key behind.
If the intention is to delete the key, build a new object without the property:

-      store: {
-        ...store,
-        programOnboarding: undefined,
-      },
+      store: Object.fromEntries(
+        Object.entries(store).filter(([k]) => k !== "programOnboarding"),
+      ),

Alternatively, use the unset operator if supported by your Prisma connector.

Likely an incorrect or invalid review comment.

This was referenced Oct 15, 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.

1 participant

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载