-
Notifications
You must be signed in to change notification settings - Fork 4
fix: improve onboarding and unify environment variables #242
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
Changes from all commits
41e67a4
755e8b5
f53122e
d1989ab
7e971c7
7ba06d1
c362809
8fb6596
a8d1562
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,18 +49,24 @@ export default function AuthCallbackContent() { | |
| // Clear any persisted auth state to prevent old user ID from being used | ||
| localStorage.removeItem('persist:root'); | ||
|
|
||
| console.log('[AuthCallback] Setting user with ID:', parsedUser._id); | ||
| // Validate parsed user data | ||
| if (!parsedUser._id || !parsedUser.email) { | ||
| // eslint-disable-next-line no-console | ||
| console.error('[AuthCallback] Invalid user data:', parsedUser); | ||
| router.replace('/login?error=oauth_invalid_data'); | ||
| return; | ||
| } | ||
|
|
||
| dispatch( | ||
| setCredentials({ | ||
| csrfToken, | ||
| user: { | ||
| _id: parsedUser._id, | ||
| email: parsedUser.email, | ||
| firstName: parsedUser.firstName, | ||
| lastName: parsedUser.lastName, | ||
| role: parsedUser.role, | ||
| status: parsedUser.status, | ||
| email: parsedUser.email ?? '', | ||
| firstName: parsedUser.firstName ?? '', | ||
| lastName: parsedUser.lastName ?? '', | ||
| role: parsedUser.role ?? 'user', | ||
| status: parsedUser.status ?? 'active', | ||
|
Comment on lines
+65
to
+69
|
||
| }, | ||
| }), | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,7 +28,7 @@ interface AddressComponents { | |||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| interface AddressAutocompleteProps { | ||||||||||||||||||||
| value: string; | ||||||||||||||||||||
| value: string | undefined; | ||||||||||||||||||||
| onChange: (value: string) => void; | ||||||||||||||||||||
| onAddressSelect: ( | ||||||||||||||||||||
| address: string, | ||||||||||||||||||||
|
|
@@ -87,19 +87,20 @@ const AddressAutocomplete: React.FC<AddressAutocompleteProps> = ({ | |||||||||||||||||||
| }) => { | ||||||||||||||||||||
| const [suggestions, setSuggestions] = useState<AutocompletePrediction[]>([]); | ||||||||||||||||||||
| const [loading, setLoading] = useState(false); | ||||||||||||||||||||
| const [inputValue, setInputValue] = useState(value); | ||||||||||||||||||||
| const [inputValue, setInputValue] = useState(value ?? ''); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Debounced fetch for autocomplete | ||||||||||||||||||||
| const debouncedFetch = useMemo( | ||||||||||||||||||||
| () => | ||||||||||||||||||||
| debounce(async (input: string) => { | ||||||||||||||||||||
| if (!input || input.trim().length < 2) { | ||||||||||||||||||||
| debounce(async (input: string | undefined) => { | ||||||||||||||||||||
| const inputStr = input ?? ''; | ||||||||||||||||||||
| if (!inputStr || inputStr.trim().length < 2) { | ||||||||||||||||||||
| setSuggestions([]); | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| setLoading(true); | ||||||||||||||||||||
| try { | ||||||||||||||||||||
| const data = await fetchPlaceAutocomplete(input, { | ||||||||||||||||||||
| const data = await fetchPlaceAutocomplete(inputStr, { | ||||||||||||||||||||
| country: 'au', | ||||||||||||||||||||
| types: 'address', | ||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
@@ -113,8 +114,15 @@ const AddressAutocomplete: React.FC<AddressAutocompleteProps> = ({ | |||||||||||||||||||
| [], | ||||||||||||||||||||
| ); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Sync inputValue with value prop when it changes externally | ||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||
| void debouncedFetch(inputValue); | ||||||||||||||||||||
| if (value !== undefined && value !== inputValue) { | ||||||||||||||||||||
| setInputValue(value ?? ''); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| }, [value, inputValue]); | ||||||||||||||||||||
|
||||||||||||||||||||
| }, [value, inputValue]); | |
| }, [value]); |
Copilot
AI
Dec 21, 2025
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.
The comment states "Ensure state is uppercase and 2-3 characters", but the code uses substring(0, 3) which always limits to a maximum of 3 characters. This doesn't enforce a minimum of 2 characters. If the state abbreviation is less than 2 characters, it should be validated or handled appropriately. Consider adding validation to ensure the state code meets the expected format (e.g., 2-3 uppercase letters).
| const state = components.administrativeAreaLevel1 | |
| .toUpperCase() | |
| .substring(0, 3); | |
| statePostcode.push(state); | |
| const rawState = components.administrativeAreaLevel1.toUpperCase(); | |
| if (rawState.length >= 2) { | |
| const state = rawState.substring(0, 3); | |
| statePostcode.push(state); | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; | ||
|
|
||
| import type { Plan } from '@/types/plan.types'; | ||
| import { getApiBaseUrl } from '@/utils/api-config'; | ||
|
|
||
| interface HealthResponse { | ||
| status: string; | ||
|
|
@@ -10,7 +11,7 @@ interface HealthResponse { | |
| export const publicApiSlice = createApi({ | ||
| reducerPath: 'publicApi', | ||
| baseQuery: fetchBaseQuery({ | ||
| baseUrl: process.env.NEXT_PUBLIC_API_BASE_URL, | ||
| baseUrl: getApiBaseUrl(), | ||
|
||
| responseHandler: 'content-type', | ||
| }), | ||
| endpoints: builder => ({ | ||
|
|
||
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.
This server component is calling getApiBaseUrl() which relies on process.env.NODE_ENV at runtime. In Next.js server components, this will always be 'production' during the build process, even in development mode. This means the localhost fallback in getApiBaseUrl() won't work, and the function will throw an error if NEXT_PUBLIC_API_BASE_URL is not set during development builds. For server components, you should directly access process.env.NEXT_PUBLIC_API_BASE_URL or use a different approach that doesn't rely on NODE_ENV.