mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
32 lines
905 B
TypeScript
32 lines
905 B
TypeScript
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>
|
|
);
|
|
}
|