Skip to content

fix: handle undefined values in onboarding components#246

Merged
magicmarc merged 13 commits intomainfrom
fix-onboarding
Dec 24, 2025
Merged

fix: handle undefined values in onboarding components#246
magicmarc merged 13 commits intomainfrom
fix-onboarding

Conversation

@Benbenzhouz
Copy link
Contributor

This PR handles undefined values in onboarding components and improves error handling.

Changes

  • Fixed undefined value handling in AddressAutocomplete
  • Improved error handling in UserInputArea
  • Enhanced OAuth callback data validation
  • Refactored to use getApiBaseUrl() utility function for consistency
  • Restored original dev script in package.json

Environment Variables

  • All environment variable names match main branch exactly
  • Using getApiBaseUrl() utility function for centralized API URL management

Ben Zhou and others added 13 commits December 20, 2025 15:13
- 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
- Keep same behavior as before: NEXT_PUBLIC_API_BASE_URL ?? localhost fallback
- Remove production environment check to match original usage
- Environment variable name unchanged: NEXT_PUBLIC_API_BASE_URL
- Function only provides centralized management, no behavior change
…upport

- Restore NEXT_PUBLIC_API_BASE_URL and NEXT_PUBLIC_API_URL support
- Keep function for centralized management
- Match original behavior exactly
- Replace getApiBaseUrl() with process.env.NEXT_PUBLIC_API_BASE_URL
- Ensure environment variable names match main branch exactly
- Change 'next dev -p 3000' back to 'next dev' to match main branch
…access

- Replace all direct process.env.NEXT_PUBLIC_API_BASE_URL usage with getApiBaseUrl()
- Centralize API base URL logic in api-config.ts
- Improve code consistency and maintainability
Copilot AI review requested due to automatic review settings December 24, 2025 07:26
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 introduces a centralized getApiBaseUrl() utility function and enhances undefined value handling in onboarding components, particularly in AddressAutocomplete and UserInputArea. It also adds validation for OAuth callback data to prevent invalid user data from being processed.

Key Changes:

  • Created getApiBaseUrl() utility function for consistent API URL management across the codebase
  • Updated component prop types to accept undefined values with appropriate guards and default values
  • Added validation in OAuth callback to verify user data contains required _id and email fields

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/utils/api-config.ts New utility function to centralize API base URL retrieval with fallback default
src/services/places.ts Refactored to use getApiBaseUrl() instead of direct environment variable access
src/lib/axiosBaseQuery.ts Refactored to use getApiBaseUrl() and improved nullish coalescing for method parameter
src/features/public/publicApiSlice.ts Updated to use centralized getApiBaseUrl() utility
src/components/ui/AddressAutocomplete.tsx Enhanced undefined handling for value prop, improved address formatting with validation, and added null guards
src/components/GoogleOAuthButton.tsx Simplified API URL retrieval using getApiBaseUrl() utility
src/app/onboarding/components/UserInputArea.tsx Updated to handle undefined userInput prop with appropriate guards and default values
src/app/auth/callback/AuthCallbackContent.tsx Added validation for OAuth user data and default values for optional fields
src/app/(public)/blogs/page.tsx Refactored to use getApiBaseUrl() for API calls
src/app/(public)/blogs/components/BlogList.tsx Updated to use centralized API URL utility function
src/app/(public)/blogs/[id]/page.tsx Simplified API URL retrieval using getApiBaseUrl()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@magicmarc magicmarc merged commit abaede3 into main Dec 24, 2025
12 checks passed
@magicmarc magicmarc deleted the fix-onboarding branch December 24, 2025 07:45
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.

3 participants