feat: User onboarding finished
This commit is contained in:
@@ -26,8 +26,12 @@ export const Auth0Provider: React.FC<Auth0ProviderProps> = ({ children }) => {
|
||||
|
||||
const onRedirectCallback = (appState?: { returnTo?: string }) => {
|
||||
console.log('[Auth0Provider] Redirect callback triggered', { appState, returnTo: appState?.returnTo });
|
||||
const target = appState?.returnTo || '/garage';
|
||||
navigate(target, { replace: true });
|
||||
// Route to callback page which will check user status and redirect appropriately
|
||||
// Pass the intended destination as state for after status check
|
||||
navigate('/callback', {
|
||||
replace: true,
|
||||
state: { returnTo: appState?.returnTo || '/garage' },
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
25
frontend/src/core/auth/useUserStatus.ts
Normal file
25
frontend/src/core/auth/useUserStatus.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @ai-summary React Query hook for user status (email verification + onboarding)
|
||||
* @ai-context Used by CallbackPage to determine routing after Auth0 callback
|
||||
*/
|
||||
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useAuth0 } from '@auth0/auth0-react';
|
||||
import { authApi } from '../../features/auth/api/auth.api';
|
||||
import { UserStatusResponse } from '../../features/auth/types/auth.types';
|
||||
|
||||
interface UseUserStatusOptions {
|
||||
enabled?: boolean;
|
||||
}
|
||||
|
||||
export const useUserStatus = (options?: UseUserStatusOptions) => {
|
||||
const { isAuthenticated, isLoading: isAuthLoading } = useAuth0();
|
||||
|
||||
return useQuery<UserStatusResponse>({
|
||||
queryKey: ['userStatus'],
|
||||
queryFn: authApi.getUserStatus,
|
||||
enabled: (options?.enabled !== false) && isAuthenticated && !isAuthLoading,
|
||||
retry: 2,
|
||||
staleTime: 30000, // Cache for 30 seconds
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user