import {createBrowserRouter, RouterProvider,} from "react-router-dom";
import {Suspense,} from "react";
import {ConfigProvider,App} from "antd";
import zhCN from 'antd/locale/zh_CN';
// for date-picker i18n
import 'dayjs/locale/zh-cn';

import ErrorBoundary from "./error.tsx";
import Loader from "@/components/loader.tsx";
import routes from "@/routes/routes.tsx";


const router = createBrowserRouter([
	...routes,
	{path: '*', element: <ErrorBoundary/>}
], {
	basename: import.meta.env.VITE_APP_BASE_NAME,
	future: {
		v7_fetcherPersist: true,
		v7_relativeSplatPath: true,
		v7_normalizeFormMethod: true,
		v7_skipActionErrorRevalidation: true,
		v7_partialHydration: true,
	}
})

// future={{v7_startTransition: true,v7_relativeSplatPath: true}}
const AppRouter = () => {
	return (<ConfigProvider
		locale={zhCN}
		theme={{
			token: {
				borderRadius: 4,
				
			},

		}}
	>
		<App>
			<Suspense fallback={<Loader/>}>
				<RouterProvider future={{v7_startTransition: true}} router={router}/>
			</Suspense>
		</App>
	</ConfigProvider>)
}

export default AppRouter;