import React from 'react';
import { useSelector } from 'react-redux';
import { RootState, useAppSelector } from '../store';
import { AuthStack } from './authStack';
import { AppStack } from './appStack';
import { OnboardingStack } from './onboardingStack';

export const RootNavigator: React.FC = () => {
  const accessToken = useSelector((state: RootState) => state.auth.accessToken);
  const isOnboarding = useAppSelector(
    state => state.auth.user?.status === 'ONBOARDING',
  );

  if (!accessToken) {
    return <AuthStack />;
  }

  if (isOnboarding) {
    return <OnboardingStack />;
  }

  return <AppStack />;
};
