import React from 'react';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import RouteName from '../Constants/RouteName.constants';
import { RootStackParamList } from '../Constants/RouteParamsList.contants';
import { UnauthorizedScreens, AuthorizedScreens } from './config';

const Stack = createNativeStackNavigator<RootStackParamList>();

interface Props {
  initialRoute: string;
}

const AppStack = ({ initialRoute }: Props) => {
  return (
    <Stack.Navigator
      initialRouteName={initialRoute as keyof RootStackParamList}
      screenOptions={{ headerShown: false }}>
      {[...UnauthorizedScreens, ...AuthorizedScreens].map(screen => (
        <Stack.Screen
          key={screen.name}
          name={screen.name as keyof RootStackParamList}
          component={screen.component}
          options={screen.options}
        />
      ))}
    </Stack.Navigator>
  );
};

export default AppStack;