Skip to content

fix: handle undefined values in onboarding components#241

Closed
Benbenzhouz wants to merge 8 commits intomainfrom
fix-onboarding
Closed

fix: handle undefined values in onboarding components#241
Benbenzhouz wants to merge 8 commits intomainfrom
fix-onboarding

Conversation

@Benbenzhouz
Copy link
Contributor

Onboarding UI Fixes

问题

  • 地址自动完成组件中的 undefined 值导致错误
  • 用户输入区域未正确处理 undefined
  • OAuth 回调处理缺少数据验证
  • API base URL 配置不一致

解决方案

  • 添加 undefined 值检查到 Autocomplete 组件
  • 改进用户输入区域的错误处理
  • 增强 OAuth 回调数据验证
  • 统一 API base URL 配置

改动文件

  • src/components/ui/AddressAutocomplete.tsx
  • src/app/onboarding/components/UserInputArea.tsx
  • src/app/auth/callback/AuthCallbackContent.tsx
  • src/lib/axiosBaseQuery.ts
  • src/components/GoogleOAuthButton.tsx
  • src/features/public/publicApiSlice.ts
  • src/services/places.ts
  • package.json

关联 PR

测试

  • 地址输入 (各种格式)
  • Google 登录
  • 完整 onboarding 流程
  • 浏览器控制台无错误

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Ben Zhou and others added 7 commits December 20, 2025 20:24
- 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
@Benbenzhouz
Copy link
Contributor Author

Closing to recreate after environment variable updates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants