replaced remix with react-router

This commit is contained in:
dswbx
2025-03-14 15:32:43 +01:00
parent b3a0ecbe6d
commit b763826754
49 changed files with 562 additions and 488 deletions

View File

@@ -0,0 +1,31 @@
import { lazy, Suspense, useSyncExternalStore } from "react";
import { type LoaderFunctionArgs, useLoaderData } from "react-router";
import { getApi } from "~/bknd";
const Admin = lazy(() => import("bknd/ui").then((mod) => ({ default: mod.Admin })));
import "bknd/dist/styles.css";
export const loader = async (args: LoaderFunctionArgs) => {
const api = await getApi(args, { verify: true });
return {
user: api.getUser(),
};
};
export default function AdminPage() {
const { user } = useLoaderData<typeof loader>();
// derived from https://github.com/sergiodxa/remix-utils
const hydrated = useSyncExternalStore(
// @ts-ignore
() => {},
() => true,
() => false,
);
if (!hydrated) return null;
return (
<Suspense>
<Admin withProvider={{ user }} config={{ basepath: "/admin", logo_return_path: "/../" }} />
</Suspense>
);
}