mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 12:37:20 +00:00
fixing imports and ssr support + updated remix/nextjs/astro examples
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
//import { notifications } from "@mantine/notifications";
|
||||
import { getDefaultConfig, getDefaultSchema } from "modules/ModuleManager";
|
||||
import { createContext, startTransition, useContext, useEffect, useRef, useState } from "react";
|
||||
import type { ModuleConfigs, ModuleSchemas } from "../../modules";
|
||||
@@ -101,20 +100,6 @@ export function BkndProvider({
|
||||
);
|
||||
}
|
||||
|
||||
type BkndWindowContext = {
|
||||
user?: object;
|
||||
logout_route: string;
|
||||
};
|
||||
export function useBkndWindowContext(): BkndWindowContext {
|
||||
if (typeof window !== "undefined" && window.__BKND__) {
|
||||
return window.__BKND__ as any;
|
||||
} else {
|
||||
return {
|
||||
logout_route: "/api/auth/logout"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function useBknd({ withSecrets }: { withSecrets?: boolean } = {}): BkndContext {
|
||||
const ctx = useContext(BkndContext);
|
||||
if (withSecrets) ctx.requireSecrets();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import type { TApiUser } from "Api";
|
||||
import { createContext, useContext, useEffect, useState } from "react";
|
||||
import { useBkndWindowContext } from "ui/client/BkndProvider";
|
||||
//import { useBkndWindowContext } from "ui/client/BkndProvider";
|
||||
import { AppQueryClient } from "./utils/AppQueryClient";
|
||||
|
||||
const ClientContext = createContext<{ baseUrl: string; client: AppQueryClient }>({
|
||||
@@ -89,3 +89,17 @@ export const useBaseUrl = () => {
|
||||
const context = useContext(ClientContext);
|
||||
return context.baseUrl;
|
||||
};
|
||||
|
||||
type BkndWindowContext = {
|
||||
user?: object;
|
||||
logout_route: string;
|
||||
};
|
||||
export function useBkndWindowContext(): BkndWindowContext {
|
||||
if (typeof window !== "undefined" && window.__BKND__) {
|
||||
return window.__BKND__ as any;
|
||||
} else {
|
||||
return {
|
||||
logout_route: "/api/auth/logout"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
1
app/src/ui/client/bknd.ts
Normal file
1
app/src/ui/client/bknd.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { BkndProvider, useBknd } from "./BkndProvider";
|
||||
@@ -1,5 +1,10 @@
|
||||
export { ClientProvider, type ClientProviderProps, useClient, useBaseUrl } from "./ClientProvider";
|
||||
export { BkndProvider, useBknd } from "./BkndProvider";
|
||||
export {
|
||||
ClientProvider,
|
||||
useBkndWindowContext,
|
||||
type ClientProviderProps,
|
||||
useClient,
|
||||
useBaseUrl
|
||||
} from "./ClientProvider";
|
||||
|
||||
export { useAuth } from "./schema/auth/use-auth";
|
||||
export { Api } from "../../Api";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useBknd } from "ui/client";
|
||||
import { useBknd } from "ui/client/bknd";
|
||||
|
||||
export function useBkndAuth() {
|
||||
//const client = useClient();
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
fieldsSchema,
|
||||
relationsSchema
|
||||
} from "data/data-schema";
|
||||
import { useBknd } from "ui/client";
|
||||
import { useBknd } from "ui/client/bknd";
|
||||
import type { TSchemaActions } from "ui/client/schema/actions";
|
||||
|
||||
export function useBkndData() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useBknd } from "ui/client";
|
||||
import { useBknd } from "ui/client/bknd";
|
||||
|
||||
export function useBkndSystem() {
|
||||
const { config, schema, actions: bkndActions } = useBknd();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useBknd } from "ui";
|
||||
import { useBknd } from "ui/client/bknd";
|
||||
|
||||
export function useTheme(): { theme: "light" | "dark" } {
|
||||
const b = useBknd();
|
||||
|
||||
Reference in New Issue
Block a user