-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Make partner image optional at onboarding #2983
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.
💡 Enable Vercel Agent with $100 free credit for automated AI reviews |
WalkthroughThe PR makes partner image optional across the onboarding flow: it removes the required form validation, conditionally uploads the image (only when provided) and sets imageUrl to null otherwise, and updates the Zod schema to accept null/undefined image values. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Form
participant ServerAction
participant Storage
participant DB
User->>Form: fill fields (image optional)
Form->>ServerAction: submit(payload)
alt image provided
ServerAction->>Storage: upload(image)
Storage-->>ServerAction: imageUrl
ServerAction->>DB: createOrUpdatePartner({..., imageUrl })
else no image
ServerAction->>DB: createOrUpdatePartner({..., imageUrl: null})
end
ServerAction-->>Form: result
Form-->>User: show success / errors
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 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: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/lib/actions/partners/onboard-partner.ts (1)
40-52: Existing partner images will be overwritten with null during re-onboarding.When an existing partner re-onboards without providing a new image, line 52 sets
image: imageUrl(which is null) in the payload, overwriting their existing image. This differs from the conditional handling ofdescriptionat line 51.Consider preserving the existing image when no new image is provided during re-onboarding:
Apply this diff:
}), ...(description && { description }), - image: imageUrl, + ...(imageUrl !== null && { image: imageUrl }), users: {This ensures:
- New partners without images: image remains null (no spread)
- New partners with images: image is set to uploaded URL
- Existing partners without new images: image field is not updated (preserves existing)
- Existing partners with new images: image is updated to new URL
🧹 Nitpick comments (1)
apps/web/lib/zod/schemas/partners.ts (1)
532-546: Consider removing the redundant transform.The transform
(v) => v || ""at line 545 appears unnecessary since:
- When the field is undefined (not provided),
.optional()bypasses the transform entirely- When the field is provided, the union validation would reject empty or null values before reaching the transform
- Valid image strings are truthy, so the transform wouldn't modify them
While this doesn't cause bugs, it adds cognitive overhead. Given the "temporary fix" comment, consider cleaning this up in a follow-up.
Apply this diff to simplify:
const partnerImageSchema = z .union([ base64ImageSchema, storedR2ImageUrlSchema, publicHostedImageSchema, z .string() .url() .trim() .refine((url) => url.startsWith(GOOGLE_FAVICON_URL), { message: `Image URL must start with ${GOOGLE_FAVICON_URL}`, }), ]) - .transform((v) => v || "") .optional();
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx(0 hunks)apps/web/lib/actions/partners/onboard-partner.ts(1 hunks)apps/web/lib/zod/schemas/partners.ts(1 hunks)
💤 Files with no reviewable changes (1)
- apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/onboarding-form.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (1)
apps/web/lib/actions/partners/onboard-partner.ts (1)
33-37: LGTM! Conditional upload logic is sound.The conditional check properly prevents unnecessary storage operations when no image is provided, and the null fallback correctly reflects the optional nature of the field.
Summary by CodeRabbit