fix(apps): sort event type duration badges numerically - #29954
Conversation
|
Welcome to Cal.diy, @yuvrajnode! Thanks for opening this pull request. A few things to keep in mind:
A maintainer will review your PR soon. Thanks for contributing! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe event types step card now sorts event durations by numeric value. This replaces default lexicographic sorting. Mergeability Score: ⚪ Minimal · up to This change corrects duration badge ordering without altering single-duration behavior or introducing broader product impact. No actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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 |
What
Fixes duration badge ordering on the app-installation event-type picker (
EventTypeCardinEventTypesStepCard.tsx).Why
Array.prototype.sort()with no comparator coerces every element to a string before comparing. For a number array like[15, 30, 60, 90, 120], that produces lexicographic order —120sorts before15because'1' < '2'as characters. Concretely, an event type with those durations rendered its badges as:instead of the expected:
Fix
Pass an explicit numeric comparator:
.sort((a, b) => a - b). This matches the convention already used for sorting numbers elsewhere in the codebase (getUserAvailability.ts,slots.ts).Testing
Verified locally that
[15, 30, 60, 90, 120].sort()produces[120, 15, 30, 60, 90]and.sort((a,b) => a-b)produces[15, 30, 60, 90, 120]. No behavior change for single-duration event types.