package com.example.tasks.navigation

import androidx.compose.runtime.Composable
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import com.example.tasks.screens.AddTask
import com.example.tasks.screens.Entrance
import com.example.tasks.screens.Start
import com.example.tasks.screens.TasksChief

@Composable
fun Navigation() {
    val navController = rememberNavController()
    NavHost(navController = navController, startDestination = Screen.Start.route)
    {
        composable(route = Screen.Start.route)
        {
            Start(navController = navController)

        }
        composable(route = Screen.Entrance.route)
        {
            Entrance(navController)

        }
        composable(
            route = Screen.AppNavigationStaff.route + "/{surname}/{name}/{patronymic}",
            arguments = listOf(
                navArgument("surname") {
                    type = NavType.StringType
                },
                navArgument("name") {
                    type = NavType.StringType
                },
                navArgument("patronymic") {
                    type = NavType.StringType
                },
            )
        )
        {
            val surname = it.arguments!!.getString("surname")
            val name = it.arguments!!.getString("name")
            val patronymic = it.arguments!!.getString("patronymic")
            AppNavigationStaff(name = name!!, surname = surname!!, patronymic = patronymic!!, navController2 = navController)

        }

        composable(
            route = Screen.AddTask.route + "/{division}/{surname}/{name}/{patronymic}",
            arguments = listOf(
                navArgument("surname") {
                    type = NavType.StringType
                },
                navArgument("name") {
                    type = NavType.StringType
                },
                navArgument("patronymic") {
                    type = NavType.StringType
                },
                navArgument("division") {
                    type = NavType.StringType
                }
            ))
        {
            val surname = it.arguments!!.getString("surname")
            val name = it.arguments!!.getString("name")
            val patronymic = it.arguments!!.getString("patronymic")
            val division = it.arguments!!.getString("division")
            AddTask(
                name = name!!,
                surname = surname!!,
                patronymic = patronymic!!,
                division = division!!,
                navController = navController
            )

        }
        composable(
            route = Screen.AppNavigationChief.route + "/{surname}/{name}/{patronymic}/{division}",
            arguments = listOf(
                navArgument("surname") {
                    type = NavType.StringType
                },
                navArgument("name") {
                    type = NavType.StringType
                },
                navArgument("patronymic") {
                    type = NavType.StringType
                },
                navArgument("division") {
                    type = NavType.StringType
                },
            )
        )
        {
            val surname = it.arguments!!.getString("surname")
            val name = it.arguments!!.getString("name")
            val patronymic = it.arguments!!.getString("patronymic")
            val division = it.arguments!!.getString("division")
            AppNavigationChief(name = name!!, surname = surname!!, patronymic = patronymic!!, division = division!!, navController2 = navController)

        }


    }
}