import { Screen, Text, VStack } from "./src/core/ui";
import { useMigrations } from "./src/modules/db/hooks";
import {
  useIsIntroductionCompleted,
  useIsIntroductionCompletedGate,
} from "./src/modules/introduction/hooks";
import { AppNavigation } from "./src/modules/navigation/components";
import "expo-dev-client";

export default function App() {
  useIsIntroductionCompletedGate();

  const dbMigration = useMigrations();

  const { isLoading: isLoadingIsIsIntroductionCompleted } =
    useIsIntroductionCompleted();

  if (dbMigration.error)
    return (
      <Screen>
        <VStack alignX="center" alignY="center" fullWidth fullHeight>
          <Text content={dbMigration.error.message} />
        </VStack>
      </Screen>
    );

  if (isLoadingIsIsIntroductionCompleted || !dbMigration.success) return null;

  return <AppNavigation />;
}
