Add custom duration input for group discount codes#3897
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR enables selecting custom discount durations (integer 0–9999 months). It relaxes the Zod schema to accept integer non-negative values up to 9999, adds a ChangesCustom Duration Selection for Discounts
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
apps/web/lib/zod/schemas/misc.tsParsing error: The keyword 'import' is reserved apps/web/ui/partners/discounts/add-edit-discount-sheet.tsxParsing error: The keyword 'import' is reserved 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.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/ui/partners/discounts/add-edit-discount-sheet.tsx`:
- Around line 633-648: The custom duration input disallows zero via min="1" and
the onChange guard (parsed > 0) even though the schema and presets allow 0;
change the input attribute to min="0", clamp parsed using
Math.max(Math.min(parsed, 9999), 0) (or equivalent) and update the onChange
condition to accept parsed >= 0 so setValue("maxDuration", clamped, {
shouldDirty: true }) and setCustomDurationInput(display) will allow and persist
zero; update references in the component handling customDurationInput and the
onChange handler accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2db62fa1-25b0-45a3-9bac-e2c072c27508
📒 Files selected for processing (3)
apps/web/lib/zod/schemas/misc.tsapps/web/ui/partners/discounts/add-edit-discount-sheet.tsxapps/web/ui/shared/inline-badge-popover.tsx
Summary by CodeRabbit
New Features
Improvements
Bug Fixes