import { Navigate, createBrowserRouter } from "react-router-dom";
import AppLayout from "../components/layout/AppLayout";
import ClientConsentsPage from "../features/clients/ClientConsentsPage";
import ClientDetailsPage from "../features/clients/ClientDetailsPage";
import ClientGeneralPage from "../features/clients/ClientGeneralPage";
import ClientsPage from "../features/clients/ClientsPage";

export const router = createBrowserRouter(
  [
    {
      path: "/",
      element: <AppLayout />,
      children: [
        { index: true, element: <Navigate to="/clients" replace /> },
        { path: "clients", element: <ClientsPage /> },
        { path: "clients/new", element: <ClientGeneralPage /> },
        { path: "clients/:id", element: <ClientDetailsPage /> },
        { path: "clients/:id/consents", element: <ClientConsentsPage /> },
        { path: "clients/:id/settings", element: <ClientGeneralPage /> },
      ],
    },
  ],
  // React Router v7 플래그 사전 적용 (현재 타입 정의에 없어 any 캐스팅)
  {
    future: {
      v7_startTransition: true,
    },
  } as unknown as Parameters<typeof createBrowserRouter>[1],
);
