added bknd admin config override to make it easier to include <Admin />

This commit is contained in:
dswbx
2024-11-28 11:15:07 +01:00
parent 54b38401d8
commit bdc6eb55bf
14 changed files with 103 additions and 59 deletions

View File

@@ -1,4 +1,5 @@
import { withApi } from "bknd/adapter/nextjs";
import type { BkndAdminProps } from "bknd/ui";
import type { InferGetServerSidePropsType } from "next";
import dynamic from "next/dynamic";
@@ -10,15 +11,10 @@ export const getServerSideProps = withApi(async (context) => {
};
});
export function adminPage() {
export function adminPage(adminProps?: BkndAdminProps) {
const Admin = dynamic(() => import("bknd/ui").then((mod) => mod.Admin), { ssr: false });
const ClientProvider = dynamic(() => import("bknd/ui").then((mod) => mod.ClientProvider));
return (props: InferGetServerSidePropsType<typeof getServerSideProps>) => {
if (typeof document === "undefined") return null;
return (
<ClientProvider user={props.user}>
<Admin />
</ClientProvider>
);
return <Admin withProvider={{ user: props.user }} {...adminProps} />;
};
}