fix: handle undefined values in onboarding components#241
Closed
Benbenzhouz wants to merge 8 commits intomainfrom
Closed
fix: handle undefined values in onboarding components#241Benbenzhouz wants to merge 8 commits intomainfrom
Benbenzhouz wants to merge 8 commits intomainfrom
Conversation
4 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses undefined value handling issues in onboarding components and standardizes API base URL configuration across the frontend application. The changes focus on preventing runtime errors from undefined values in address autocomplete, user input areas, and OAuth callback flows.
Key Changes:
- Added undefined value guards to AddressAutocomplete and UserInputArea components
- Enhanced OAuth callback data validation with required field checks
- Unified API base URL configuration with fallback chain across multiple files
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| src/components/ui/AddressAutocomplete.tsx | Added undefined handling for value prop, enhanced address formatting validation, and improved null-safety in rendering logic |
| src/app/onboarding/components/UserInputArea.tsx | Updated userInput prop type to accept undefined and added safe guards for trim() operations |
| src/app/auth/callback/AuthCallbackContent.tsx | Added validation for required user fields (_id, email) and fallback values for optional fields |
| src/lib/axiosBaseQuery.ts | Standardized API base URL with fallback chain including NEXT_PUBLIC_API_URL and localhost default |
| src/features/public/publicApiSlice.ts | Applied same API base URL fallback chain for consistency |
| src/components/GoogleOAuthButton.tsx | Updated API base URL configuration to match standardized fallback pattern |
| src/services/places.ts | Updated API base URL with standardized fallback chain |
| package.json | Explicitly specified port 3000 for dev script |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Replace || with ?? in AuthCallbackContent.tsx - Replace || with ?? in UserInputArea.tsx - Replace || with ?? in GoogleOAuthButton.tsx - Replace || with ?? in AddressAutocomplete.tsx - Replace || with ?? in publicApiSlice.ts - Replace || with ?? in axiosBaseQuery.ts - Fix useEffect dependency in AddressAutocomplete.tsx - Remove console.log statements in AuthCallbackContent.tsx
- Create unified getApiBaseUrl() utility function - Remove hardcoded localhost fallbacks from all files - Production environment now requires API URL to be configured - Development environment allows localhost fallback with warning - Improves code quality and prevents production misconfigurations Files updated: - src/utils/api-config.ts (new) - src/services/places.ts - src/lib/axiosBaseQuery.ts - src/features/public/publicApiSlice.ts - src/components/GoogleOAuthButton.tsx - src/app/(public)/blogs/page.tsx - src/app/(public)/blogs/components/BlogList.tsx - src/app/(public)/blogs/[id]/page.tsx
- Remove unnecessary NEXT_PUBLIC_API_BASE_URL fallback - Use only NEXT_PUBLIC_API_URL as it's the actual configured variable - Simplify code and error messages
- Change from NEXT_PUBLIC_API_URL to NEXT_PUBLIC_API_BASE_URL - This matches the actual configured environment variable name
Contributor
Author
|
Closing to recreate after environment variable updates |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Onboarding UI Fixes
问题
解决方案
改动文件
关联 PR
测试