-
Notifications
You must be signed in to change notification settings - Fork 61
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
fix(samgongustofa): Disable "Continue" button when selecting vehicle with error (and user has over 20 vehicles) #16752
fix(samgongustofa): Disable "Continue" button when selecting vehicle with error (and user has over 20 vehicles) #16752
Conversation
WalkthroughThe changes involve modifications to the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16752 +/- ##
==========================================
- Coverage 36.54% 36.53% -0.01%
==========================================
Files 6888 6890 +2
Lines 143667 143657 -10
Branches 40937 40937
==========================================
- Hits 52497 52486 -11
- Misses 91170 91171 +1 Flags with carried forward coverage won't be shown. Click here to find out more.
... and 11 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Datadog ReportAll test runs ✅ 34 Total Test Services: 0 Failed, 32 Passed Test ServicesThis report shows up to 10 services
🔻 Code Coverage Decreases vs Default Branch (2) |
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
🧹 Outside diff range and nitpick comments (4)
libs/application/templates/transport-authority/transfer-of-vehicle-ownership/src/fields/VehiclesField/index.tsx (2)
65-65
: Consider using a more specific prop spreading approach.While spreading all props enhances flexibility, it might pass unnecessary props to the child component. Consider explicitly spreading only the required props or creating a dedicated type for the expected props.
-{...props} +{ + application: props.application, + setFieldLoadingState: props.setFieldLoadingState, + setSubmitButtonDisabled: props.setSubmitButtonDisabled, + // Add other necessary props +}
Line range hint
39-53
: Fix missing dependencies in useCallback.The
updateData
callback usesupdateApplication
andlocale
, but they're not included in the dependency array. This could lead to stale closures.}, [ + updateApplication, + application.id, + locale ])libs/application/ui-fields/src/lib/FindVehicleFormField/FindVehicleFormField.tsx (2)
200-212
: Consider improving error handling with TypeScript typesThe error handling could be more robust by defining specific error types for better type safety and error differentiation.
- } catch (error) { + } catch (error: unknown) { + const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred'; console.error('error', error)
Line range hint
262-302
: Consider extracting common state management logicThe machine and vehicle state management share similar patterns. Consider extracting the common logic into a custom hook for better reusability and maintainability.
Example approach:
function useVehicleState<T extends { disabled?: boolean }>( fieldId: string, setValue: Function ) { const setCommonValues = (details: T, isDisabled: boolean) => { setValue('findVehicle', true) setSubmitButtonDisabled?.(!isDisabled) // ... other common logic } return { setCommonValues } }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (2)
libs/application/templates/transport-authority/transfer-of-vehicle-ownership/src/fields/VehiclesField/index.tsx
(1 hunks)libs/application/ui-fields/src/lib/FindVehicleFormField/FindVehicleFormField.tsx
(8 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
libs/application/templates/transport-authority/transfer-of-vehicle-ownership/src/fields/VehiclesField/index.tsx (1)
Pattern libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
libs/application/ui-fields/src/lib/FindVehicleFormField/FindVehicleFormField.tsx (1)
Pattern libs/**/*
: "Confirm that the code adheres to the following:
- Reusability of components and hooks across different NextJS apps.
- TypeScript usage for defining props and exporting types.
- Effective tree-shaking and bundling practices."
🔇 Additional comments (4)
libs/application/templates/transport-authority/transfer-of-vehicle-ownership/src/fields/VehiclesField/index.tsx (2)
Line range hint 28-37
: LGTM! Well-structured vehicle details fetching logic.
The wrapper function provides a clean abstraction for vehicle details fetching with proper TypeScript types and error handling.
Line range hint 54-95
: Implementation aligns with PR objectives.
The conditional rendering correctly handles users with over 20 vehicles by using FindVehicleFormField with proper error handling and button state management. This matches the PR's goal of disabling the 'Continue' button when selecting a vehicle with error.
✅ Verification successful
Implementation correctly handles submit button state
The FindVehicleFormField component properly implements the setSubmitButtonDisabled functionality:
- Disables submit button when vehicle validation fails
- Enables submit button when a valid vehicle is selected
- Consistently handles error states and loading states
- Used consistently across different vehicle-related forms in the codebase
The implementation aligns with the PR objectives and follows the established patterns across the codebase for managing form submission states.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Verify that FindVehicleFormField is used consistently across the codebase
ast-grep --pattern 'FindVehicleFormField setSubmitButtonDisabled={$_}'
Length of output: 72
Script:
#!/bin/bash
# Let's try a broader search for FindVehicleFormField usage
ast-grep --pattern 'FindVehicleFormField'
# Also search for the component file to understand its implementation
fd FindVehicleFormField
# Search for setSubmitButtonDisabled prop usage in TSX files
rg "setSubmitButtonDisabled" -t tsx
Length of output: 4011
Script:
#!/bin/bash
# Let's examine the FindVehicleFormField component implementation
cat libs/application/ui-fields/src/lib/FindVehicleFormField/FindVehicleFormField.tsx
# And check for setSubmitButtonDisabled usage with proper file extension
rg "setSubmitButtonDisabled" --type-add 'tsx:*.tsx' -t tsx
Length of output: 24695
libs/application/ui-fields/src/lib/FindVehicleFormField/FindVehicleFormField.tsx (2)
233-257
: LGTM: Effective implementation of vehicle validation and button state
The implementation correctly handles the disabled state based on validation errors and debt status, which aligns with the PR objective of preventing users from proceeding with invalid vehicle selections.
Line range hint 416-524
: LGTM: Clear visual feedback for disabled states
The implementation provides clear visual feedback through color coding and error messages when a vehicle or machine is disabled, improving the user experience.
libs/application/ui-fields/src/lib/FindVehicleFormField/FindVehicleFormField.tsx
Show resolved
Hide resolved
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.
LGMT
…or-vehicle-search-field
…with error (and user has over 20 vehicles) (#16752) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
…with error (and user has over 20 vehicles) (#16752) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
What
When searching for vehicle (user has over 20), user is able to continue here:
We should disable the button, and also make zod validation prevent him from continuing to the next step
Checklist:
Summary by CodeRabbit
New Features
VehiclesField
component for better prop management.FindVehicleFormField
, ensuring accurate vehicle details processing.Bug Fixes
Documentation
FindVehicleFormField
.