-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Partner profile updates #2872
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
Partner profile updates #2872
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdds modular partner-profile UI (three new sub-forms and an interests modal), extends Prisma enums/relations and Zod schemas for partner profile fields, updates API/auth and updatePartnerProfile action to persist new relations/fields, adjusts related UI components, and removes the Website & Socials page. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant AYF as AboutYouForm
participant MOD as IndustryInterestsModal
participant ACT as updatePartnerProfileAction
participant DB as Database
participant T as Toast
U->>AYF: Edit description / monthlyTraffic / open interests
AYF->>MOD: open modal
MOD-->>AYF: save(selectedInterests)
AYF->>ACT: submit(formData)
ACT->>DB: update partner + replace related relations
DB-->>ACT: success / error
alt success
ACT-->>AYF: ok
AYF-->>T: success toast
AYF-->>AYF: reset dirty state
else error
ACT-->>AYF: error
AYF-->>T: error toast
AYF->>AYF: set form error
end
sequenceDiagram
autonumber
actor U as User
participant PDF as ProfileDetailsForm
participant MOD as StripeChangeConfirmModal
participant ACT as updatePartnerProfileAction
participant DB as Database
participant T as Toast
U->>PDF: Modify avatar/name/email/country/profileType/companyName
PDF->>PDF: detect payouts & stripe connection
alt country/profileType change requires confirmation
PDF->>MOD: open confirmation
alt confirm
MOD-->>PDF: proceed
else cancel
MOD-->>PDF: abort
end
end
PDF->>ACT: submit(formData)
ACT->>DB: update partner + nested relations
DB-->>ACT: success / error
alt success
ACT-->>PDF: ok
PDF-->>T: show success or verification prompt
PDF-->>PDF: reset form
else error
ACT-->>PDF: error
PDF-->>T: show error / merge-accounts toast
PDF->>PDF: set field/root errors
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
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 |
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
🧹 Nitpick comments (4)
packages/ui/src/icons/nucleo/cloud.tsx (1)
12-28: Deduplicate SVG attributes; remove redundant fill and push shared stroke to the groupBoth paths repeat identical stroke and fill props, while the parent group sets an unused fill. Centralize shared attributes on the and simplify the paths.
Apply this diff:
- <g fill="currentColor"> - <path - d="M13.464,6.891c-.186-2.314-2.102-4.141-4.464-4.141-2.485,0-4.5,2.015-4.5,4.5,0,.35,.049,.686,.124,1.013-1.597,.067-2.874,1.374-2.874,2.987,0,1.657,1.343,3,3,3h7.75c2.071,0,3.75-1.679,3.75-3.75,0-1.736-1.185-3.182-2.786-3.609Z" - fill="none" - stroke="currentColor" - strokeLinecap="round" - strokeLinejoin="round" - strokeWidth="1.5" - /> - <path - d="M9.705,8c.687-.767,1.684-1.25,2.795-1.25,.333,0,.657,.059,.964,.141" - fill="none" - stroke="currentColor" - strokeLinecap="round" - strokeLinejoin="round" - strokeWidth="1.5" - /> + <g fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.5"> + <path d="M13.464,6.891c-.186-2.314-2.102-4.141-4.464-4.141-2.485,0-4.5,2.015-4.5,4.5,0,.35,.049,.686,.124,1.013-1.597,.067-2.874,1.374-2.874,2.987,0,1.657,1.343,3,3,3h7.75c2.071,0,3.75-1.679,3.75-3.75,0-1.736-1.185-3.182-2.786-3.609Z" /> + <path d="M9.705,8c.687-.767,1.684-1.25,2.795-1.25,.333,0,.657,.059,.964,.141" /> </g>apps/web/lib/actions/partners/update-partner-profile.ts (3)
97-122: Avoid shadowing outernameand improve readability in map callbacksThe callback param
nameshadows the outernamefield. Rename tovalue(or similar) in each map to reduce confusion.Apply this diff:
- ...(industryInterests && { + ...(industryInterests && { industryInterests: { deleteMany: {}, - create: industryInterests.map((name) => ({ - industryInterest: name, + create: industryInterests.map((value) => ({ + industryInterest: value, })), }, }), - ...(preferredEarningStructures && { + ...(preferredEarningStructures && { preferredEarningStructures: { deleteMany: {}, - create: preferredEarningStructures.map((name) => ({ - preferredEarningStructure: name, + create: preferredEarningStructures.map((value) => ({ + preferredEarningStructure: value, })), }, }), - ...(salesChannels && { + ...(salesChannels && { salesChannels: { deleteMany: {}, - create: salesChannels.map((name) => ({ - salesChannel: name, + create: salesChannels.map((value) => ({ + salesChannel: value, })), }, }),
181-184: Harden error handling:errorisunknownAccessing
error.messagedirectly can throw iferrorisn’t anError. Guard it to avoid masking the real failure.Apply this diff:
- } catch (error) { - console.error(error); - - throw new Error(error.message); - } + } catch (error) { + console.error(error); + const message = + error instanceof Error ? error.message : "Failed to update partner profile"; + throw new Error(message); + }
225-228: Align error messaging with actual constraints (include company name)You also gate on companyName changes, but the message mentions only country/profile type. Include company name to reduce confusion.
- "Since you've already received payouts on Dub, you cannot change your country or profile type. Please contact support to update those fields.", + "Since you've already received payouts on Dub, you cannot change your country, profile type, or company name. Please contact support to update those fields.",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx(1 hunks)apps/web/lib/actions/partners/update-partner-profile.ts(7 hunks)apps/web/lib/partners/partner-profile.ts(1 hunks)apps/web/lib/zod/schemas/partners.ts(5 hunks)packages/prisma/schema/partner.prisma(4 hunks)packages/ui/src/icons/nucleo/cloud.tsx(1 hunks)packages/ui/src/icons/nucleo/index.ts(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/prisma/schema/partner.prisma
- apps/web/lib/partners/partner-profile.ts
🧰 Additional context used
🧠 Learnings (6)
📚 Learning: 2025-09-17T17:44:03.965Z
Learnt from: TWilson023
PR: dubinc/dub#2857
File: apps/web/lib/actions/partners/update-program.ts:96-0
Timestamp: 2025-09-17T17:44:03.965Z
Learning: In apps/web/lib/actions/partners/update-program.ts, the team prefers to keep the messagingEnabledAt update logic simple by allowing client-provided timestamps rather than implementing server-controlled timestamp logic to avoid added complexity.
Applied to files:
apps/web/lib/actions/partners/update-partner-profile.ts
📚 Learning: 2025-07-30T15:25:13.936Z
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/lib/actions/partners/update-partner-profile.ts
📚 Learning: 2025-09-24T15:57:55.259Z
Learnt from: TWilson023
PR: dubinc/dub#2872
File: apps/web/lib/actions/partners/update-partner-profile.ts:97-104
Timestamp: 2025-09-24T15:57:55.259Z
Learning: In the Dub codebase, the team prefers to maintain consistency with existing patterns for database operations, even if there are theoretical improvements available. The deleteMany: {} pattern for relation updates is an accepted approach that the team considers low-risk.
Applied to files:
apps/web/lib/actions/partners/update-partner-profile.ts
📚 Learning: 2025-09-24T15:51:28.818Z
Learnt from: TWilson023
PR: dubinc/dub#2872
File: apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx:218-219
Timestamp: 2025-09-24T15:51:28.818Z
Learning: In the Dub codebase, OG_AVATAR_URL concatenation with partner names follows a consistent pattern throughout the application where names are used directly without URL encoding. This is an established codebase-wide pattern.
Applied to files:
apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx
📚 Learning: 2025-07-30T15:29:54.131Z
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)/profile/profile-details-form.tsx
📚 Learning: 2025-09-24T15:50:16.387Z
Learnt from: TWilson023
PR: dubinc/dub#2872
File: apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx:180-189
Timestamp: 2025-09-24T15:50:16.387Z
Learning: TWilson023 prefers to keep security vulnerability fixes separate from refactoring PRs when the vulnerable code is existing and was only moved/relocated rather than newly introduced.
Applied to files:
apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx
🧬 Code graph analysis (3)
apps/web/lib/actions/partners/update-partner-profile.ts (2)
apps/web/lib/zod/schemas/misc.ts (1)
uploadedImageSchema(117-129)apps/web/lib/zod/schemas/partners.ts (2)
MAX_PARTNER_DESCRIPTION_LENGTH(271-271)PartnerProfileSchema(245-269)
apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/profile-details-form.tsx (8)
packages/prisma/client.ts (1)
PartnerProfileType(19-19)apps/web/lib/types.ts (2)
PartnerProps(428-428)PayoutsCount(458-462)apps/web/ui/partners/online-presence-form.tsx (2)
useOnlinePresenceForm(70-83)OnlinePresenceForm(89-414)apps/web/ui/modals/confirm-modal.tsx (1)
useConfirmModal(105-118)apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/settings-row.tsx (1)
SettingsRow(3-23)apps/web/lib/actions/partners/update-partner-profile.ts (1)
updatePartnerProfileAction(42-185)packages/utils/src/constants/misc.ts (1)
OG_AVATAR_URL(29-29)apps/web/app/(ee)/partners.dub.co/(dashboard)/profile/page-client.tsx (1)
ProfileForm(183-463)
apps/web/lib/zod/schemas/partners.ts (1)
packages/prisma/client.ts (4)
MonthlyTraffic(15-15)IndustryInterest(13-13)PreferredEarningStructure(23-23)SalesChannel(28-28)
⏰ 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 (4)
packages/ui/src/icons/nucleo/cloud.tsx (1)
5-11: Good prop override orderPlacing {...props} after explicit width/height lets consumers override defaults cleanly.
packages/ui/src/icons/nucleo/index.ts (1)
2-2: Re-exports look good and keep alphabetical orderApple and Cloud are added in the expected spots without naming conflicts.
Also applies to: 61-61
apps/web/lib/zod/schemas/partners.ts (2)
243-269: Good: enum array validation + de-dup guards addedThe uniqueness refinements on industryInterests, preferredEarningStructures, and salesChannels will prevent Prisma join unique violations and align inputs with DB constraints.
271-299: Description length mismatch: updates capped at 500 but read schema allows 5000MAX_PARTNER_DESCRIPTION_LENGTH is 500 here, and update actions enforce it, while PartnerSchema still permits 5000 to avoid breaking reads. This can reject updates for existing partners whose description > 500 if the client sends the field unchanged.
To avoid accidental failures:
- Ensure clients only send description when changed (undefined otherwise), or
- Backfill/truncate existing descriptions > 500, or
- Temporarily accept >500 server-side unless changed.
Would you like a follow-up migration plan to normalize existing descriptions > 500?
Summary by CodeRabbit