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 (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThis PR extends the booking and lookahead system to track activity-asset mappings throughout the data flow. It adds activity_asset_mapping_id to booking types and queries, updates form options to standardized values, enhances the upload review dialog to correct both asset type and work pattern, and derives stable activity identities for reliable drilling and state matching. ChangesActivity-Asset Mapping and Booking Context Enhancement
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
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)
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: 2
🧹 Nitpick comments (1)
src/lib/formOptions.ts (1)
1-23: ⚡ Quick winExport derived union types from these option arrays.
This will prevent string drift in payload/types and catch invalid literals at compile time.
♻️ Proposed refactor
export const ASSET_TYPE_OPTIONS = [ "crane", "hoist", "loading_bay", "ewp", "concrete_pump", "excavator", "forklift", "telehandler", "compactor", "other", "none", ] as const; + +export type AssetTypeOption = (typeof ASSET_TYPE_OPTIONS)[number]; export const WORK_PROFILE_SHAPE_OPTIONS = [ "single_day", "flat", "front_loaded", "back_loaded", "bell", "inverse_bell", "staged", ] as const; + +export type WorkProfileShapeOption = + (typeof WORK_PROFILE_SHAPE_OPTIONS)[number];🤖 Prompt for 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. In `@src/lib/formOptions.ts` around lines 1 - 23, The option arrays ASSET_TYPE_OPTIONS and WORK_PROFILE_SHAPE_OPTIONS are fine but you should export derived union types to prevent string drift; add exported type aliases (e.g., AssetType and WorkProfileShape) using the array literal types (typeof ASSET_TYPE_OPTIONS[number] and typeof WORK_PROFILE_SHAPE_OPTIONS[number]) so consumers and payload/types use the exact allowed literals derived from those arrays rather than repeating raw strings.
🤖 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 `@src/components/lookahead/ActivityDrilldownDialog.tsx`:
- Around line 31-32: The helper getActivityRowKey should treat
activity.activity_asset_mapping_id as empty when it is null, undefined, or a
string of only whitespace so React keys won't collide; change the logic in
getActivityRowKey to trim the mapping id and use it only if trimmed.length > 0,
otherwise return activity.activity_id (ensuring the return is a string). Apply
the same guard/trim-and-fallback pattern to the other locations that currently
use activity.activity_asset_mapping_id for keys/IDs (the similar usages near the
other getActivityRowKey occurrences) so every key/path uses the mapping id only
when nonblank and falls back to activity_id.
In `@src/components/lookahead/UploadReviewDialog.tsx`:
- Around line 328-340: The handler handleCorrect currently sends profile_shape:
profileShape || null which clears an existing mapping.profile_shape when
profileShape is undefined; change the payload so profile_shape is only changed
when the user explicitly provided a value: set profile_shape to
mapping.profile_shape (or null if absent) when profileShape is undefined,
otherwise use the provided profileShape (or null for an explicit empty value).
Apply the same fix to the other similar mapping-correction call sites in this
component that call onCorrectMapping so they preserve stored profile_shape
unless explicitly edited.
---
Nitpick comments:
In `@src/lib/formOptions.ts`:
- Around line 1-23: The option arrays ASSET_TYPE_OPTIONS and
WORK_PROFILE_SHAPE_OPTIONS are fine but you should export derived union types to
prevent string drift; add exported type aliases (e.g., AssetType and
WorkProfileShape) using the array literal types (typeof
ASSET_TYPE_OPTIONS[number] and typeof WORK_PROFILE_SHAPE_OPTIONS[number]) so
consumers and payload/types use the exact allowed literals derived from those
arrays rather than repeating raw strings.
🪄 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: 57e0ef41-14a9-441a-9337-cbc92a3107cf
📒 Files selected for processing (15)
src/components/forms/CreateAssetForm.tsxsrc/components/forms/CreateBookingForm.tsxsrc/components/forms/UpdateAssetForm.tsxsrc/components/lookahead/ActivityDrilldownDialog.tsxsrc/components/lookahead/LookaheadDashboard.tsxsrc/components/lookahead/UploadReviewDialog.tsxsrc/hooks/bookings/api.tssrc/hooks/lookahead/api.test.tssrc/hooks/lookahead/api.tssrc/hooks/lookahead/keys.tssrc/hooks/lookahead/useLookaheadQueries.tssrc/lib/apiNormalization.test.tssrc/lib/apiNormalization.tssrc/lib/formOptions.tssrc/types/index.ts
Summary by CodeRabbit
New Features
Improvements
Tests