Router.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { lazy } from "react";
  2. import { createBrowserRouter } from "react-router";
  3. import { RouterProvider } from "react-router/dom";
  4. const UsersSignIn = lazy(() => import("./pages/users/sign-in"));
  5. const UsersPersonal = lazy(() => import("./pages/users/personal"));
  6. const DashboardIndex = lazy(() => import("./pages/dashboard/index"));
  7. const Home = lazy(() => import("./pages/home"));
  8. const RootLayout = lazy(() => import("./layouts/Root"));
  9. const AnonymousLayout = lazy(() => import("./layouts/anonymous"));
  10. const DashboardLayout = lazy(() => import("./layouts/dashboard"));
  11. const router = createBrowserRouter(
  12. [
  13. {
  14. path: "/",
  15. Component: RootLayout,
  16. children: [
  17. { index: true, Component: Home },
  18. {
  19. path: "anonymous",
  20. Component: AnonymousLayout,
  21. children: [{ path: "sign-in", Component: UsersSignIn }],
  22. },
  23. {
  24. path: "dashboard",
  25. Component: DashboardLayout,
  26. children: [
  27. { index: true, Component: DashboardIndex },
  28. {
  29. path: "users",
  30. children: [{ path: "personal", Component: UsersPersonal }],
  31. },
  32. ],
  33. },
  34. ],
  35. },
  36. ],
  37. { basename: import.meta.env.BASE_URL }
  38. );
  39. const Widget = () => {
  40. return <RouterProvider router={router} />;
  41. };
  42. export default Widget;