-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Create commission product ID + misc. bounties fixes #2831
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 GitHub.
|
WalkthroughAdds optional productId support to commission creation across schema, action, and UI. Adjusts SWR cache invalidation targets for bounty submission approval to /api/bounties. Safeguards bounty submission requirements parsing with a default array. Introduces a slight delay when opening the claim bounty form to avoid accidental submission. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UI as CreateCommissionSheet (UI)
participant Server as createCommissionAction
participant Schema as createCommissionSchema
participant Sales as recordSaleWithTimestamp
participant Commissions as createPartnerCommission
User->>UI: Submit commission form (amount, type, productId?)
UI->>Server: POST createCommission (payload incl. productId?)
Server->>Schema: Validate input (productId nullish allowed)
Schema-->>Server: Parsed input
alt productId provided
Server->>Sales: recordSaleWithTimestamp(metadata: JSON{productId})
else no productId
Server->>Sales: recordSaleWithTimestamp(metadata: undefined)
end
Sales-->>Server: Sale record
Server->>Commissions: createPartnerCommission({ sale: { productId? }, ... })
Commissions-->>Server: Commission created
Server-->>UI: Success response
UI-->>User: Confirmation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks (2 passed, 1 warning)❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Poem
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. ✨ Finishing touches
🧪 Generate unit tests
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. Comment |
...b.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
Show resolved
Hide resolved
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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx (1)
94-99: Bug: ternary precedence breaks sortByAs written, the OR is evaluated before ?:, so any truthy searchParam forces metricColumnId. Use nullish coalescing with parentheses.
- const sortBy = - searchParams.get("sortBy") || bounty?.type === "performance" - ? metricColumnId - : "createdAt"; + const sortBy = + searchParams.get("sortBy") ?? (bounty?.type === "performance" + ? metricColumnId + : "createdAt");
♻️ Duplicate comments (1)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx (1)
48-49: LGTM: broader cache invalidationSwitching to mutatePrefix("/api/bounties") avoids memoization issues and refreshes related counts.
🧹 Nitpick comments (2)
apps/web/lib/zod/schemas/commissions.ts (1)
150-151: Add basic constraints to productIdMatch invoiceId constraints and avoid unbounded strings; consider documenting.
- productId: z.string().nullish(), + productId: z.string().max(190).nullish(),Optionally add to COMMISSION_EXPORT_COLUMNS if you plan to export/filter by product.
apps/web/lib/actions/partners/create-commission.ts (1)
249-252: Avoid sending empty sale contextSkip
salewhen productId is nullish to reduce noise.- sale: { - productId, - }, + ...(productId ? { sale: { productId } } : {}),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx(1 hunks)apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx(2 hunks)apps/web/lib/actions/partners/create-bounty-submission.ts(1 hunks)apps/web/lib/actions/partners/create-commission.ts(3 hunks)apps/web/lib/zod/schemas/commissions.ts(1 hunks)apps/web/ui/partners/bounties/claim-bounty-modal.tsx(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-26T14:32:33.851Z
Learnt from: TWilson023
PR: dubinc/dub#2736
File: apps/web/lib/actions/partners/create-bounty-submission.ts:105-112
Timestamp: 2025-08-26T14:32:33.851Z
Learning: Non-performance bounties are required to have submissionRequirements. In create-bounty-submission.ts, it's appropriate to let the parsing fail if submissionRequirements is null for non-performance bounties, as this indicates a data integrity issue that should be caught.
Applied to files:
apps/web/lib/actions/partners/create-bounty-submission.ts
📚 Learning: 2025-08-26T14:20:23.943Z
Learnt from: TWilson023
PR: dubinc/dub#2736
File: apps/web/app/api/workspaces/[idOrSlug]/notification-preferences/route.ts:13-14
Timestamp: 2025-08-26T14:20:23.943Z
Learning: The updateNotificationPreference action in apps/web/lib/actions/update-notification-preference.ts already handles all notification preference types dynamically, including newBountySubmitted, through its schema validation using the notificationTypes enum and Prisma's dynamic field update pattern.
Applied to files:
apps/web/lib/actions/partners/create-bounty-submission.ts
⏰ 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: Vade Review
🔇 Additional comments (4)
apps/web/ui/partners/bounties/claim-bounty-modal.tsx (1)
447-452: Set explicit Button type and prevent form submission instead of using setTimeoutFile: apps/web/ui/partners/bounties/claim-bounty-modal.tsx (around lines 447–452)
<Button variant="primary" text={isFormOpen ? "Submit proof" : "Claim bounty"} className="grow rounded-lg" + type={isFormOpen ? "submit" : "button"} - onClick={ - isFormOpen - ? undefined - : // Delay open to prevent also submitting the form - () => setTimeout(() => setIsFormOpen(true), 100) - } + onClick={ + isFormOpen + ? undefined + : (e) => { + e.preventDefault(); + setIsFormOpen(true); + } + } loading={isPending}Search output did not locate the Button implementation to confirm its default type; set the prop explicitly to avoid relying on defaults.
apps/web/lib/actions/partners/create-bounty-submission.ts (1)
106-108: Defaulting to [] hides data integrity issues for non-performance bountiesPast decision was to fail parsing when requirements are missing to catch bad data. This change makes image/URL optional silently.
Apply if you want to preserve strictness:
- const submissionRequirements = submissionRequirementsSchema.parse( - bounty.submissionRequirements || [], - ); + if (!bounty.submissionRequirements) { + throw new Error("Submission requirements missing for this bounty."); + } + const submissionRequirements = submissionRequirementsSchema.parse( + bounty.submissionRequirements, + );If relaxing is intentional, please confirm and add a comment explaining the rationale.
apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx (1)
429-430: LGTM: unify cache invalidationBroadly mutating /api/bounties is consistent with the details sheet and keeps counts fresh.
apps/web/lib/actions/partners/create-commission.ts (1)
229-231: LGTM: include productId in sale metadataPassing JSON metadata with productId to Tinybird is correct.
Summary by CodeRabbit
New Features
Bug Fixes