import { createInertiaApp } from "@inertiajs/react";
import { createRoot } from "react-dom/client";
import type { ComponentType } from "react";

createInertiaApp({
  resolve: (name: string) => {
    const pages = import.meta.glob<{ default: ComponentType<unknown> }>(
      "./pages/**/*.tsx",
      { eager: true },
    );
    return pages[`./pages/${name}.tsx`];
  },
  setup({ el, App, props }) {
    createRoot(el).render(<App {...props} />);
  },
});
