-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Remove dependencies on partnerId path param #2498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
## Walkthrough
This update removes the dependency on explicit `programId` parameters throughout the codebase, instead deriving the program ID from the workspace context using `getDefaultProgramIdOrThrow` or `useWorkspace`. All API endpoints, hooks, and UI routes are refactored to use simplified paths without dynamic program ID segments, consolidating program-related navigation and logic under a singular `/program` route.
## Changes
| File(s) / Area | Change Summary |
|------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `apps/web/app/(ee)/api/partners/count/route.ts`, `/api/programs/[programId]/payouts/count/route.ts`, `/api/programs/[programId]/payouts/route.ts` | Refactored to derive `programId` from workspace context instead of route params; removed explicit `programId` extraction and validation; updated query logic accordingly. |
| `apps/web/lib/actions/partners/program-resources/add-program-resource.ts`, `/delete-program-resource.ts`, `/upload-lander-image.ts` | Removed `programId` from input schemas and action handlers; now internally derives `programId` from workspace context in all partner resource actions. |
| `apps/web/lib/swr/use-commissions-timeseries.ts`, `/use-discount-partners.ts`, `/use-discounts.ts`, `/use-payouts-count.ts`, `/use-payouts.ts`, `/use-program-metrics.ts`, `/use-program-resources.ts`, `/use-program-revenue.ts`, `/use-program.ts`, `/use-reward-partners.ts`, `/use-rewards.ts` | Refactored SWR hooks to no longer use `programId` from URL params; now use `defaultProgramId` from `useWorkspace`; updated fetch keys and conditional logic; removed `useParams` imports. |
| `apps/web/lib/swr/use-partners-count.ts` | Removed `programId` from parameters and internal logic; simplified SWR key and query string construction; updated function signature. |
| `apps/web/ui/layout/sidebar/app-sidebar-nav.tsx` | Updated all program-related sidebar links to use `/program` instead of `/programs/${defaultProgramId}`; adjusted logic for active path detection. |
| `apps/web/ui/partners/archive-partner-modal.tsx`, `/ban-partner-modal.tsx`, `/design/branding-form.tsx`, `/mark-commission-duplicate-modal.tsx`, `/mark-commission-fraud-or-canceled-modal.tsx`, `/mark-payout-paid-modal.tsx`, `/payout-details-sheet.tsx`, `/unban-partner-modal.tsx` | Removed `useParams` and `programId` usage; now rely on `useWorkspace` for workspace and program context; updated URLs and conditional checks accordingly. |
| `apps/web/ui/partners/partner-details-sheet.tsx`, `/partner-row-item.tsx` | Simplified URLs in tabs and links by removing dynamic `programId` segments; updated to use `/program/` paths. |
| `apps/web/ui/partners/design/modals/earnings-calculator-block-modal.tsx` | Updated link URLs to remove dynamic `defaultProgramId` segment, using `/program/settings/rewards` instead. |
| `apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/customers/[customerId]/page-client.tsx`, `/program/branding/program-branding-tabs.tsx`, `/program/branding/resources/add-color-modal.tsx`, `/add-file-modal.tsx`, `/add-logo-modal.tsx`, `/resources/page-client.tsx`, `/commissions/commission-stats.tsx`, `/commissions/commission-table.tsx`, `/page-client.tsx`, `/partners/partner-stats.tsx`, `/partners/partner-table.tsx`, `/payouts/payout-table.tsx`, `/pending-payouts.tsx`, `/program-metrics.tsx`, `/settings/layout.tsx`, `/settings/program-settings-header.tsx`, `/top-partners.tsx` | Removed `programId` from URL params, hooks, and links; updated all affected routes and navigation to use `/program` instead of `/programs/${programId}`; refactored components to derive necessary context internally. |
| `apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/page.tsx` | Deleted file; previously handled redirect logic based on project and program configuration. |
| `apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx` | Updated conditions and links for partners-related usage categories to use `/program` path and require both `partnersEnabled` and `defaultProgramId`. |
| `apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/resources/page-client.tsx` | Removed `useParams` usage; `useProgramResources` now called without arguments. |
| `apps/web/app/(ee)/app.dub.co/(new-program)/sidebar-context.tsx` | Changed redirect logic to use `/program` path instead of `/programs/${defaultProgramId}`. |
| `apps/web/lib/middleware/utils/app-redirect.ts` | Updated redirect patterns to replace plural "programs" with singular "program"; removed dynamic program ID segments from all redirect rules. |
| `apps/web/lib/swr/use-program-resources.ts` | Refactored hook to take no parameters; now determines endpoint internally using `useParams` and `useWorkspace`. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant UI
participant useWorkspace
participant API/Actions
UI->>useWorkspace: Get workspaceId, defaultProgramId
useWorkspace-->>UI: Returns context (workspaceId, defaultProgramId)
UI->>API/Actions: Make request (no explicit programId param)
API/Actions->>useWorkspace: Get workspace context
API/Actions->>API/Actions: Derive programId via getDefaultProgramIdOrThrow(workspace)
API/Actions-->>UI: Respond with dataPossibly related PRs
Poem
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (2)
apps/web/lib/actions/partners/upload-lander-image.ts (1)
9-12: 🛠️ Refactor suggestionRemove unused
programIdfrom the schema.The schema still requires
programIdas input, but the action no longer uses it (line 18 derives it from workspace context instead). This creates confusion and unnecessary coupling.const schema = z.object({ workspaceId: z.string(), - programId: z.string(), });apps/web/app/(ee)/api/programs/[programId]/payouts/route.ts (1)
1-14: 💡 Verification agent🧩 Analysis chain
Verify route path consistency with the refactored implementation.
The file path still includes
[programId]as a dynamic route segment, but the handler no longer uses this parameter. Consider whether the route should be updated to reflect thatprogramIdis no longer required from the URL.
🏁 Script executed:
#!/bin/bash # Check if other API routes in the same pattern have been updated fd -t f "route.ts" apps/web/app | grep -E "programs/\[programId\]" | head -10Length of output: 872
Remove the unused
[programId]segment from the payouts routeYour GET handler now sources the program ID via
getDefaultProgramIdOrThrow(workspace)(and doesn’t readparams.programId), so the[programId]folder is misleading. You should either:
- Drop the dynamic segment—move
apps/web/app/(ee)/api/programs/[programId]/payouts/route.ts
→
apps/web/app/(ee)/api/programs/payouts/route.ts
and update any client calls/tests.- Or re-introduce
params.programIdinto your handler if the URL must drive which program is used.Points to address:
- File/folder structure under
apps/web/app/(ee)/api/programs- Downstream client code (and any tests) referencing this endpoint
🧹 Nitpick comments (4)
apps/web/lib/swr/use-commissions-timeseries.ts (1)
43-43: Simplify the boolean expression.The ternary operator is unnecessary here. The expression can be simplified for better readability.
- loading: !data && !error ? true : false, + loading: !data && !error,🧰 Tools
🪛 Biome (1.9.4)
[error] 43-43: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with(lint/complexity/noUselessTernary)
apps/web/lib/swr/use-program.ts (1)
35-35: Simplify the loading state logic.The ternary operator with boolean literals is unnecessary and can be simplified.
Apply this diff to simplify the loading state:
- loading: !program && !error ? true : false, + loading: !program && !error,🧰 Tools
🪛 Biome (1.9.4)
[error] 35-35: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with(lint/complexity/noUselessTernary)
apps/web/lib/swr/use-program-revenue.ts (1)
43-43: Simplify the ternary operator.The boolean literal in the ternary expression is unnecessary and can be simplified.
- loading: !data && !error ? true : false, + loading: !data && !error,🧰 Tools
🪛 Biome (1.9.4)
[error] 43-43: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with(lint/complexity/noUselessTernary)
apps/web/lib/swr/use-program-resources.ts (1)
14-18: Consider simplifying the endpoint construction logic.The endpoint construction logic handles multiple scenarios but could be made more readable and maintainable.
Consider extracting the endpoint logic into a helper function or adding comments to clarify the different scenarios:
+ // Determine the appropriate endpoint based on context: + // 1. Partner-facing view: use programSlug from URL + // 2. Admin view: use defaultProgramId from workspace + // 3. No program context: disable request const endpoint = programSlug ? `/api/partner-profile/programs/${programSlug}/resources` : defaultProgramId ? `/api/programs/${defaultProgramId}/resources?workspaceId=${workspaceId}` : null;Alternatively, extract to a helper function:
const getResourcesEndpoint = (programSlug: string | undefined, defaultProgramId: string | undefined, workspaceId: string) => { if (programSlug) return `/api/partner-profile/programs/${programSlug}/resources`; if (defaultProgramId) return `/api/programs/${defaultProgramId}/resources?workspaceId=${workspaceId}`; return null; };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (31)
apps/web/app/(ee)/api/partners/count/route.ts(2 hunks)apps/web/app/(ee)/api/programs/[programId]/payouts/count/route.ts(2 hunks)apps/web/app/(ee)/api/programs/[programId]/payouts/route.ts(2 hunks)apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/resources/page-client.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/branding/resources/add-color-modal.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/branding/resources/add-file-modal.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/branding/resources/add-logo-modal.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/branding/resources/page-client.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/commissions/commission-table.tsx(0 hunks)apps/web/lib/actions/partners/program-resources/add-program-resource.ts(2 hunks)apps/web/lib/actions/partners/program-resources/delete-program-resource.ts(2 hunks)apps/web/lib/actions/partners/upload-lander-image.ts(2 hunks)apps/web/lib/swr/use-commissions-timeseries.ts(1 hunks)apps/web/lib/swr/use-discount-partners.ts(1 hunks)apps/web/lib/swr/use-discounts.ts(1 hunks)apps/web/lib/swr/use-payouts-count.ts(1 hunks)apps/web/lib/swr/use-payouts.ts(1 hunks)apps/web/lib/swr/use-program-metrics.ts(1 hunks)apps/web/lib/swr/use-program-resources.ts(2 hunks)apps/web/lib/swr/use-program-revenue.ts(3 hunks)apps/web/lib/swr/use-program.ts(2 hunks)apps/web/lib/swr/use-reward-partners.ts(1 hunks)apps/web/lib/swr/use-rewards.ts(1 hunks)apps/web/ui/partners/archive-partner-modal.tsx(2 hunks)apps/web/ui/partners/ban-partner-modal.tsx(2 hunks)apps/web/ui/partners/design/branding-form.tsx(2 hunks)apps/web/ui/partners/mark-commission-duplicate-modal.tsx(3 hunks)apps/web/ui/partners/mark-commission-fraud-or-canceled-modal.tsx(3 hunks)apps/web/ui/partners/mark-payout-paid-modal.tsx(1 hunks)apps/web/ui/partners/payout-details-sheet.tsx(3 hunks)apps/web/ui/partners/unban-partner-modal.tsx(1 hunks)
💤 Files with no reviewable changes (1)
- apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/commissions/commission-table.tsx
🧰 Additional context used
🧬 Code Graph Analysis (12)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/branding/resources/add-logo-modal.tsx (1)
apps/web/lib/swr/use-program-resources.ts (1)
useProgramResources(10-38)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/branding/resources/add-file-modal.tsx (1)
apps/web/lib/swr/use-program-resources.ts (1)
useProgramResources(10-38)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/branding/resources/page-client.tsx (1)
apps/web/lib/swr/use-program-resources.ts (1)
useProgramResources(10-38)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/branding/resources/add-color-modal.tsx (1)
apps/web/lib/swr/use-program-resources.ts (1)
useProgramResources(10-38)
apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/resources/page-client.tsx (1)
apps/web/lib/swr/use-program-resources.ts (1)
useProgramResources(10-38)
apps/web/lib/swr/use-payouts-count.ts (1)
apps/web/lib/types.ts (1)
PayoutsCount(424-428)
apps/web/ui/partners/mark-payout-paid-modal.tsx (1)
apps/web/lib/actions/partners/mark-payout-paid.ts (1)
markPayoutPaidAction(14-46)
apps/web/app/(ee)/api/partners/count/route.ts (1)
apps/web/lib/api/programs/get-default-program-id-or-throw.ts (1)
getDefaultProgramIdOrThrow(4-17)
apps/web/lib/actions/partners/program-resources/add-program-resource.ts (1)
apps/web/lib/api/programs/get-default-program-id-or-throw.ts (1)
getDefaultProgramIdOrThrow(4-17)
apps/web/lib/swr/use-discount-partners.ts (1)
apps/web/lib/types.ts (1)
EnrolledPartnerProps(402-404)
apps/web/lib/actions/partners/upload-lander-image.ts (1)
apps/web/lib/api/programs/get-default-program-id-or-throw.ts (1)
getDefaultProgramIdOrThrow(4-17)
apps/web/lib/actions/partners/program-resources/delete-program-resource.ts (1)
apps/web/lib/api/programs/get-default-program-id-or-throw.ts (1)
getDefaultProgramIdOrThrow(4-17)
🪛 Biome (1.9.4)
apps/web/lib/swr/use-commissions-timeseries.ts
[error] 43-43: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with
(lint/complexity/noUselessTernary)
apps/web/lib/swr/use-program.ts
[error] 35-35: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with
(lint/complexity/noUselessTernary)
apps/web/lib/swr/use-program-revenue.ts
[error] 43-43: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with
(lint/complexity/noUselessTernary)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (53)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/branding/resources/add-color-modal.tsx (2)
49-49: LGTM! Hook refactor correctly implemented.The
useProgramResourceshook now internally determines the program ID using workspace context, eliminating the need to pass it as a parameter.
107-112: LGTM! Action call correctly updated.The
executeAsynccall correctly removes theprogramIdparameter since the action now derives it internally viagetDefaultProgramIdOrThrow(workspace).apps/web/ui/partners/design/branding-form.tsx (2)
41-41: LGTM! Workspace context integration correctly implemented.Using
defaultProgramIdfromuseWorkspace()instead of extractingprogramIdfrom URL parameters aligns perfectly with the refactor objectives.
52-52: LGTM! LocalStorage key correctly updated.The localStorage key now uses
defaultProgramIdto maintain consistency with the program identification approach.apps/web/ui/partners/payout-details-sheet.tsx (2)
40-40: LGTM! Workspace context integration correctly implemented.Using
defaultProgramIdfromuseWorkspace()instead of extractingprogramIdfrom URL parameters successfully removes the dependency on route parameters.
63-63: LGTM! URL constructions correctly updated.The partner details and commissions links now use
defaultProgramIdfrom workspace context, maintaining functionality while removing URL parameter dependencies.Also applies to: 186-186
apps/web/ui/partners/mark-payout-paid-modal.tsx (2)
38-38: LGTM: Correctly using workspace context for program identification.The change from extracting
programIdviauseParams()to usingdefaultProgramIdfromuseWorkspace()aligns perfectly with the server-sidemarkPayoutPaidActionwhich derives the program ID internally viagetDefaultProgramIdOrThrow(workspace).
46-46: LGTM: Consistent use of defaultProgramId in cache invalidation.The mutation cache key correctly uses
defaultProgramIdto maintain consistency with the new workspace-based program identification pattern.apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/resources/page-client.tsx (1)
14-14: LGTM: Simplified hook usage aligns with internal program ID resolution.The removal of parameters from
useProgramResources()is correct. The hook now internally handles program identification by checking forprogramSlugfrom route parameters or falling back todefaultProgramIdfrom workspace context, as shown in the relevant code snippet fromuse-program-resources.ts.apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/branding/resources/add-file-modal.tsx (1)
47-47: LGTM: Correctly simplified to use internal program identification.The removal of parameters from
useProgramResources()is consistent with the hook's refactored implementation that internally resolves the program context usinguseParams()anduseWorkspace(), as shown in the relevant code snippet.apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/branding/resources/add-logo-modal.tsx (1)
47-47: LGTM: Consistent with the centralized program identification pattern.The simplification of
useProgramResources()call without parameters correctly leverages the hook's internal logic for program context resolution, maintaining consistency with the broader refactoring across all resource management components.apps/web/ui/partners/archive-partner-modal.tsx (2)
26-26: Good architectural improvement: centralizing program ID management.The change from URL parameters to workspace context is a clean refactor that simplifies the component API and centralizes program ID management.
46-54: Correctly updated conditional logic and dependency array.The removal of
programIdfrom the conditional check and dependency array is consistent with the refactor. The component now properly relies onworkspaceIdfrom the workspace context.apps/web/ui/partners/mark-commission-duplicate-modal.tsx (3)
37-37: Proper workspace context integration.Good use of workspace context to obtain both
workspaceIdanddefaultProgramId, eliminating dependency on URL parameters.
46-46: Correctly using defaultProgramId in mutation path.The mutation path now properly uses
defaultProgramIdfrom workspace context instead of URL parameters, which is consistent with the architectural refactor.
148-148: Simplified conditional logic.Removing the
programIdcheck simplifies the validation logic since the program ID is now managed internally through workspace context.apps/web/ui/partners/ban-partner-modal.tsx (2)
65-75: Consistent refactor in onSubmit callback.The removal of
programIdfrom the conditional check and dependency array is consistent with the workspace context refactor. The logic now properly relies onworkspaceId.
80-82: Properly updated isDisabled memo.The
isDisabledmemoization correctly removesprogramIddependency and includesworkspaceId, maintaining consistency with the architectural changes.apps/web/ui/partners/unban-partner-modal.tsx (2)
58-66: Consistent refactor pattern in onSubmit.The changes mirror the pattern used in other partner modal components - removing
programIddependency and properly updating the dependency array withworkspaceId.
70-72: Correctly updated isDisabled logic.The
isDisabledmemoization follows the same pattern as the ban-partner-modal, ensuring consistency across related components in the refactor.apps/web/lib/swr/use-program.ts (1)
14-14: LGTM! Clean refactoring to use workspace context.The change from
useParams()touseWorkspace()for program identification is consistent with the PR objective and centralizes program ID resolution through workspace context rather than URL parameters.Also applies to: 21-23
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/[programId]/branding/resources/page-client.tsx (2)
20-20: LGTM! Consistent with the internal program identification pattern.The removal of
programIdparameter fromuseProgramResources()is correct, as the hook now derives the program ID internally from workspace context as shown in the relevant code snippet fromapps/web/lib/swr/use-program-resources.ts.
41-45: LGTM! Properly updated action call parameters.The removal of
programIdfrom theexecuteAsynccall is consistent with the refactoring where actions now derive the program ID internally from workspace context.apps/web/lib/swr/use-reward-partners.ts (2)
17-17: LGTM! Consistent refactoring pattern.The change from
useParams()touseWorkspace()follows the established pattern for centralizing program identification through workspace context.
20-26: LGTM! Properly updated SWR key and endpoint construction.The SWR condition now correctly checks for
defaultProgramIdinstead ofprogramId, and the endpoint URL construction uses the workspace-derived program ID. This ensures the hook only fetches data when all required identifiers are available.apps/web/ui/partners/mark-commission-fraud-or-canceled-modal.tsx (3)
44-44: LGTM! Consistent workspace context usage.The change from
useParams()touseWorkspace()aligns with the refactoring pattern and ensures program identification is centralized through workspace context.
53-53: LGTM! Properly updated cache invalidation.The mutate prefix correctly uses
defaultProgramIdto ensure cache invalidation targets the correct program endpoint after the commission status update.
156-156: LGTM! Simplified conditional logic.The conditional check is now simplified to only verify
workspaceIdsincedefaultProgramIdis derived from the workspace context and doesn't need separate validation.apps/web/lib/swr/use-discounts.ts (1)
7-12: LGTM! Consistent refactoring to use workspace context.The hook correctly replaces URL parameter extraction with workspace context. The conditional logic properly ensures both
workspaceIdanddefaultProgramIdare available before making the API request.apps/web/lib/swr/use-payouts-count.ts (1)
12-18: LGTM! Follows the consistent refactoring pattern.The hook properly implements the same refactoring approach as other hooks, removing URL parameter dependency and using workspace context for program identification.
apps/web/lib/swr/use-program-revenue.ts (1)
15-15: LGTM! Consistent workspace context usage.The refactoring correctly implements the same pattern as other hooks, using
defaultProgramIdfrom workspace context instead of URL parameters.Also applies to: 31-32
apps/web/lib/swr/use-rewards.ts (1)
7-12: LGTM! Consistent implementation of the refactoring pattern.The hook correctly follows the same pattern as other hooks in this PR, using workspace context instead of URL parameters for program identification.
apps/web/lib/swr/use-payouts.ts (2)
13-13: LGTM! Proper refactoring to use workspace context.The change from
useParamstouseWorkspacecorrectly centralizes program ID management through workspace context, aligning with the PR objectives to remove dependencies on URL parameters.
16-21: Good defensive programming with conditional SWR key.The conditional logic ensures SWR only attempts to fetch when both
workspaceIdanddefaultProgramIdare available, preventing unnecessary API calls and potential errors. This is a solid improvement over the previous implementation.apps/web/lib/swr/use-discount-partners.ts (2)
18-18: Consistent refactoring pattern applied correctly.The change to use
defaultProgramIdfromuseWorkspaceinstead of URL parameters is consistent with the overall refactoring effort and correctly implemented.
21-27: Well-structured conditional SWR key with multiple guards.The conditional logic properly combines the
enabledparameter with the availability of both IDs, providing fine-grained control over when the API call should be made. This prevents unnecessary requests and improves performance.apps/web/lib/swr/use-program-metrics.ts (2)
8-8: Appropriate use of workspace context for program identification.The refactoring correctly uses
useWorkspaceto obtain both workspace and program identifiers, eliminating the dependency on URL parameters as intended.
12-16: Proper conditional fetching logic implemented.The SWR key construction correctly ensures both
workspaceIdanddefaultProgramIdare available before attempting the API call, following the established pattern from other hooks in this refactor.apps/web/lib/actions/partners/program-resources/delete-program-resource.ts (3)
3-3: Correct import for centralized program ID resolution.The import of
getDefaultProgramIdOrThrowaligns with the refactoring pattern to derive program IDs internally rather than from client input.
15-19: Schema correctly updated to remove programId dependency.Removing
programIdfrom the input schema is appropriate as the program ID is now derived internally from workspace context, preventing clients from providing potentially incorrect or unauthorized program IDs.
25-26: Proper internal derivation of program ID with error handling.The use of
getDefaultProgramIdOrThrow(workspace)correctly centralizes program ID resolution and provides appropriate error handling when no default program exists, as shown in the relevant code snippet fromapps/web/lib/api/programs/get-default-program-id-or-throw.ts(lines 4-17).apps/web/lib/actions/partners/upload-lander-image.ts (1)
16-18: LGTM: Clean implementation of workspace-derived program ID.The refactor correctly derives the program ID from workspace context, eliminating the dependency on external input parameters.
apps/web/lib/actions/partners/program-resources/add-program-resource.ts (2)
4-4: LGTM: Clean import addition.The import is correctly added to support the workspace-derived program ID pattern.
54-55: LGTM: Consistent implementation of workspace-derived program ID.The refactor correctly removes
programIdfrom the input destructuring and derives it from workspace context instead. This is consistent with the broader refactoring pattern.apps/web/app/(ee)/api/partners/count/route.ts (2)
1-1: LGTM: Appropriate import for workspace-derived program ID.The import correctly supports the refactoring to derive program ID from workspace context.
11-11: LGTM: Clean removal of programId dependency.The refactor correctly derives program ID from workspace context instead of requiring it as a query parameter, simplifying the API interface.
apps/web/app/(ee)/api/programs/[programId]/payouts/route.ts (1)
13-14: LGTM: Correct implementation of workspace-derived program ID.The refactor properly removes dependency on the
programIdroute parameter and derives it from workspace context instead.apps/web/app/(ee)/api/programs/[programId]/payouts/count/route.ts (3)
1-1: LGTM: Clean import addition for centralized program ID resolution.The import of
getDefaultProgramIdOrThrowaligns with the refactor to derive program IDs from workspace context rather than route parameters.
13-75: LGTM: Core logic preserved with improved program ID resolution.The refactor correctly maintains all existing functionality while centralizing program ID resolution. The query building, filtering logic, and response formatting remain intact and correct.
10-11:Details
❓ Verification inconclusive
Verify route path consistency with the refactor.
The function signature correctly removes the
paramsargument and derivesprogramIdinternally. However, the route path still contains[programId]but no longer uses it from the route parameters.Please verify if the route path should be updated to reflect that
programIdis no longer extracted from URL parameters:Consider updating the route path to
/api/programs/payouts/countsince the programId is now derived from workspace context.
🏁 Script executed:
#!/bin/bash # Check if there are other API routes that have been similarly refactored rg -A 5 "export const GET = withWorkspace.*getDefaultProgramIdOrThrow" --type tsLength of output: 82
Verify dynamic route path vs. internal
programIdresolutionThe GET handler now derives
programIdviagetDefaultProgramIdOrThrow(workspace)and no longer reads it from URL params, but the folder name still includes[programId]. Ensure this dynamic segment is still needed—if all routes now pullprogramIdfrom the workspace, you should remove the[programId]folder and update the path accordingly (e.g./api/programs/payouts/count).• Search for other handlers that use
getDefaultProgramIdOrThrowto confirm consistency:#!/bin/bash rg "getDefaultProgramIdOrThrow" -n .• If no other routes rely on the URL param, refactor:
- Remove or rename the
[programId]directory underapps/web/app/(ee)/api/programs/- Update any import or link paths accordingly
apps/web/lib/swr/use-program-resources.ts (3)
2-2: LGTM: Proper imports for internal dependency resolution.The addition of
useParamsanduseWorkspacecorrectly enables the hook to derive its dependencies internally rather than accepting them as parameters.Also applies to: 6-6
10-12: LGTM: Clean function signature simplification.Removing the parameter dependency and deriving values internally aligns well with the broader refactor pattern across the codebase.
36-36: LGTM: Simplified loading state logic.The simplified
isLoadinglogic correctly removes dependency on input props and maintains the same behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/layout.tsx (1)
6-9: Clean up unused parameter in function signature.The
programIdparameter is no longer used sinceProgramSettingsHeadernow gets the slug internally viauseParams(). Consider removing it from the function signature.export default function ProgramSettingsLayout({ children, params, -}: PropsWithChildren<{ params: { slug: string; programId: string } }>) { +}: PropsWithChildren<{ params: { slug: string } }>) {apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/program-branding-tabs.tsx (1)
8-8: Remove unusedprogramIdparameter.The
programIdparameter is no longer used in the component since URLs have been simplified to use/program/...paths instead of/programs/${programId}/.... Consider removing it from the component props.export function ProgramBrandingTabs({ slug, - programId, }: { slug: string; - programId: string; }) {apps/web/ui/layout/sidebar/app-sidebar-nav.tsx (1)
256-256: Simplify the unnecessary ternary operator.The boolean condition can be simplified for better readability.
- showNews: pathname.startsWith(`/${slug}/program`) ? false : true, + showNews: !pathname.startsWith(`/${slug}/program`),🧰 Tools
🪛 Biome (1.9.4)
[error] 256-256: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with(lint/complexity/noUselessTernary)
apps/web/lib/swr/use-partners-count.ts (1)
14-14: Consider removing unused programId parameter.The
programIdparameter in the function signature is no longer used in the implementation and could be removed for clarity.} & { - programId?: string; ignoreParams?: boolean; enabled?: boolean;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (28)
apps/web/app/(ee)/app.dub.co/(new-program)/sidebar-context.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/customers/[customerId]/page-client.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/program-branding-tabs.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/resources/add-color-modal.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/resources/add-file-modal.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/resources/add-logo-modal.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/resources/page-client.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-stats.tsx(2 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-table.tsx(0 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx(3 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partner-stats.tsx(2 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partner-table.tsx(2 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsx(2 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/pending-payouts.tsx(2 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/program-metrics.tsx(2 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/layout.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/program-settings-header.tsx(2 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/top-partners.tsx(2 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/page.tsx(0 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx(1 hunks)apps/web/lib/middleware/utils/app-redirect.ts(1 hunks)apps/web/lib/swr/use-partners-count.ts(1 hunks)apps/web/ui/layout/sidebar/app-sidebar-nav.tsx(2 hunks)apps/web/ui/modals/program-welcome-modal.tsx(1 hunks)apps/web/ui/partners/design/modals/earnings-calculator-block-modal.tsx(2 hunks)apps/web/ui/partners/partner-details-sheet.tsx(4 hunks)apps/web/ui/partners/partner-row-item.tsx(2 hunks)apps/web/ui/partners/payout-details-sheet.tsx(2 hunks)
💤 Files with no reviewable changes (2)
- apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-table.tsx
- apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/programs/page.tsx
✅ Files skipped from review due to trivial changes (1)
- apps/web/ui/partners/payout-details-sheet.tsx
🧰 Additional context used
🧬 Code Graph Analysis (6)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/layout.tsx (1)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/program-settings-header.tsx (1)
ProgramSettingsHeader(6-43)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/resources/add-logo-modal.tsx (1)
apps/web/lib/swr/use-program-resources.ts (1)
useProgramResources(10-38)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/pending-payouts.tsx (1)
apps/web/lib/types.ts (1)
PayoutResponse(432-432)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/resources/add-color-modal.tsx (1)
apps/web/lib/swr/use-program-resources.ts (1)
useProgramResources(10-38)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/resources/page-client.tsx (1)
apps/web/lib/swr/use-program-resources.ts (1)
useProgramResources(10-38)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/resources/add-file-modal.tsx (1)
apps/web/lib/swr/use-program-resources.ts (1)
useProgramResources(10-38)
🪛 Biome (1.9.4)
apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
[error] 256-256: Unnecessary use of boolean literals in conditional expression.
Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with
(lint/complexity/noUselessTernary)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (40)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/layout.tsx (1)
13-13: LGTM! Simplified component usage.The refactor to remove explicit prop passing is consistent with the broader effort to simplify routing and parameter handling.
apps/web/app/(ee)/app.dub.co/(new-program)/sidebar-context.tsx (1)
37-39: LGTM! Simplified routing structure.The change from
/programs/${defaultProgramId}to/programaligns with the broader refactor to remove explicit programId parameters from URLs while maintaining the same functionality.apps/web/ui/partners/design/modals/earnings-calculator-block-modal.tsx (2)
46-46: LGTM! Consistent workspace hook usage.Removing the
defaultProgramIdextraction aligns with the refactor to derive program information from context rather than explicit parameters.
131-131: LGTM! Updated link path structure.The URL change from
/programs/${defaultProgramId}to/programmaintains functionality while simplifying the routing structure.apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsx (2)
302-302: LGTM! Simplified parameter extraction.Removing the
programIdextraction is consistent with the refactor to use program information from workspace context instead of URL parameters.
318-318: LGTM! Updated tooltip link path.The URL change maintains the same functionality while using the simplified
/programpath structure.apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/resources/page-client.tsx (1)
20-20: LGTM: Simplified hook usage aligns with centralized program identification.The refactored
useProgramResources()hook now handles program identification internally, eliminating the need to pass explicit parameters. This simplifies the component logic and aligns with the broader effort to centralize program context within workspace hooks.apps/web/ui/modals/program-welcome-modal.tsx (2)
23-23: LGTM: Simplified parameter extraction aligns with refactor.Removing
programIdfrom URL parameters is consistent with the broader refactor to centralize program identification within workspace context.
31-31: LGTM: Simplified URL structure removes dependency on dynamic program ID.The URL path change from
/programs/${programId}/brandingto/program/brandingaligns with the new routing structure that uses workspace context for program identification instead of explicit URL parameters.apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partner-stats.tsx (2)
16-16: LGTM: Parameter extraction simplified to remove programId dependency.Removing
programIdfrom URL parameters is consistent with the refactor to centralize program identification within workspace context.
40-40: LGTM: URL structure simplified to use singular program route.The URL change from
/programs/${programId}/partnersto/program/partnersaligns with the new routing structure that eliminates dynamic program ID segments in favor of workspace-based program context.apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commission-stats.tsx (2)
11-11: LGTM: Parameter extraction simplified to remove programId dependency.Removing
programIdfrom URL parameters is consistent with the refactor to centralize program identification within workspace context.
21-21: LGTM: URL structure simplified to use singular program route.The URL change from
/programs/${programId}/commissionsto/program/commissionsaligns with the new routing structure that eliminates dynamic program ID segments in favor of workspace-based program context.apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/resources/add-logo-modal.tsx (1)
47-47: LGTM: Clean API simplification.The change correctly removes explicit parameter passing to
useProgramResources(), which now internally derives the program information viauseParamsanduseWorkspace. This aligns with the broader refactor to centralize program identification.apps/web/ui/partners/partner-row-item.tsx (2)
18-18: Consistent with URL structure refactor.Correctly removes
programIdfrom route parameters as it's no longer needed in the simplified routing structure.
73-73: URL path correctly updated.The href change from
/programs/${programId}/partnersto/program/partnersaligns with the broader refactor to use fixed program paths instead of dynamic segments.apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/customers/[customerId]/page-client.tsx (1)
241-241: URL structure correctly simplified.The
viewAllHrefpath change from/programs/${programId}/commissionsto/program/commissionsis consistent with the architectural decision to remove dynamic program ID segments from URLs.apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/top-partners.tsx (2)
8-8: Consistent parameter cleanup.Correctly removes
programIdfromuseParams()destructuring as it's no longer needed with the new routing structure.
20-20: URL path correctly updated to match new structure.The href change from
/programs/${programId}/partnersto/program/partnerscompletes the consistent URL structure refactor across all reviewed components.apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/program-branding-tabs.tsx (1)
26-26: LGTM! URL simplification is consistent with the refactor.The URLs have been correctly simplified from
/programs/${programId}/brandingto/program/brandingand similar for resources, which aligns with the broader refactor to remove explicit programId from URL parameters.Also applies to: 31-31
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/page-client.tsx (2)
17-17: LGTM! Correctly removed programId extraction.The removal of
programIdfromuseParams()is appropriate since the program context is now derived internally from the workspace context rather than URL parameters.
32-32: URL paths simplified correctly.The URLs have been appropriately updated from
/programs/${programId}/settingsand/programs/${programId}/commissionsto/program/settingsand/program/commissions, removing the dynamic program ID segment as intended.Also applies to: 76-76
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx (2)
200-200: LGTM! Improved conditional logic.Adding the
defaultProgramIdcheck to the condition is appropriate - partner-related usage categories should only be shown when both partners are enabled and a default program ID exists in the workspace context.
207-207: URL paths correctly simplified.The partner-related URLs have been properly updated from
/programs/${defaultProgramId}/partnersand/programs/${defaultProgramId}/payoutsto/program/partnersand/program/payouts, aligning with the refactor to remove explicit program ID segments.Also applies to: 215-215
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/resources/add-color-modal.tsx (1)
49-49: LGTM! Hook usage updated correctly.The
useProgramResources()hook call has been correctly updated to not pass any parameters, which aligns with the refactored hook implementation that now derives the program ID internally from the workspace context (as shown in theapps/web/lib/swr/use-program-resources.tssnippet).apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/pending-payouts.tsx (1)
12-12: LGTM! Clean refactor implementation.The changes correctly implement the programId removal refactor:
- Proper use of
defaultProgramIdfrom workspace context instead of URL parameters- Appropriate conditional checks in SWR to prevent unnecessary API calls
- Consistent URL path simplification
Also applies to: 15-22, 36-36
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partner-table.tsx (1)
353-353: LGTM! Consistent with the routing refactor.The changes correctly remove
programIddependency and use the simplified routing structure. The commission navigation will work properly with the new/program/commissionspath.Also applies to: 455-455
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/branding/resources/add-file-modal.tsx (1)
47-47: LGTM! Properly adapted to refactored dependencies.The changes correctly reflect the updated
useProgramResourceshook andaddProgramResourceActionthat now internally handleprogramIdvia workspace context. The simplified API calls are consistent with the broader refactor.Also applies to: 92-98
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/program-metrics.tsx (2)
62-62: LGTM! URL refactor implemented correctly.The parameter and URL path changes are consistent with the broader refactor to remove
programIddependencies and use simplified routing.Also applies to: 67-67
23-23: Clarify the sales tab mapping intention.The TODO comment suggests uncertainty about the correct tab for the "Sales" metric. Currently, both the "Sales" and "Commissions" stats point to the "commissions" tab. Please confirm:
- Is this the intended behavior temporarily?
- When will the sales analytics tab be available?
- Should these stats point to different destinations?
Also applies to: 31-31
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/settings/program-settings-header.tsx (2)
6-7: LGTM! Clean refactor to remove programId dependency.The component now correctly uses
useParamsto get the slug directly instead of relying on props, which is more appropriate for a client component.
20-20: Consistent URL simplification across all tabs.All tab URLs have been correctly updated to use the simplified
/program/settings/pattern, removing the programId dependency as intended.Also applies to: 25-25, 30-30, 35-35
apps/web/ui/partners/partner-details-sheet.tsx (2)
41-41: Correct removal of defaultProgramId dependency.The components no longer need to destructure
defaultProgramIdfromuseWorkspacesince program context is now handled internally by the API endpoints.Also applies to: 217-217
169-169: URL paths consistently simplified to use /program route.All partner-related URLs have been correctly updated to use the simplified
/program/pattern instead of/programs/${programId}/, aligning with the broader routing refactor.Also applies to: 261-261, 278-278
apps/web/ui/layout/sidebar/app-sidebar-nav.tsx (1)
74-74: Sidebar navigation URLs correctly updated to use simplified /program route.All program-related navigation items now use the unified
/program/path pattern, removing the dynamic programId segment as intended.Also applies to: 78-78, 83-83, 87-87, 91-91, 95-95, 99-99
apps/web/lib/swr/use-partners-count.ts (1)
38-38: SWR key correctly simplified to remove programId dependency.The condition now appropriately checks only the
enabledflag, aligning with the API endpoint changes that handle program identification internally.apps/web/lib/middleware/utils/app-redirect.ts (4)
24-27: LGTM! Correctly handles legacy URL migration.The regex pattern properly captures the workspace slug and remaining path while removing the program ID segment. This effectively migrates old
/[slug]/programs/prog_[id]/:path*URLs to the new simplified/[slug]/program/:path*structure.
29-32: Consistent update for new routing structure.The redirect rule correctly updated to match the new singular "program" path structure and removes the program ID dependency from the URL pattern.
34-37: Consistent update for branding redirect.The redirect rule properly updated to use the new singular "program" path structure while maintaining the same logical redirect behavior.
39-42: Consistent update for sales redirect.The redirect rule correctly updated to use the new simplified routing structure, removing the program ID dependency while maintaining the sales-to-commissions redirect logic.
|
🤖 Bug0 QA Agent Here are the results of the automated tests for PR #2498:
To re-run the tests, please comment |
Summary by CodeRabbit
Refactor
Bug Fixes
Chores