From 7f26bc1060331f9b4e293ab15c03b3d5e5249dec Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Mon, 18 Mar 2024 10:09:37 -0400 Subject: [PATCH] feat: add sdk context and useSdk --- app/components/lib/sdk-context.tsx | 18 ++++++++++++++++++ app/root.tsx | 8 ++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 app/components/lib/sdk-context.tsx diff --git a/app/components/lib/sdk-context.tsx b/app/components/lib/sdk-context.tsx new file mode 100644 index 0000000..a2d455e --- /dev/null +++ b/app/components/lib/sdk-context.tsx @@ -0,0 +1,18 @@ +import React from "react"; +import {Sdk} from "@lumeweb/portal-sdk"; + +export const SdkContext = React.createContext< + Partial +>({}); + +export const SdkContextProvider: React.FC< {sdk: Sdk, children: React.ReactNode}> = ({sdk, children}) => { + return ( + + {children} + + ); +}; + +export function useSdk(): Partial{ + return React.useContext(SdkContext); +} diff --git a/app/root.tsx b/app/root.tsx index d4286cf..96d1531 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -15,6 +15,7 @@ import {Refine} from "@refinedev/core"; import {PortalAuthProvider} from "~/data/auth-provider.js"; import routerProvider from "@refinedev/remix-router"; import { defaultProvider } from "./data/file-provider"; +import {SdkContextProvider} from "~/components/lib/sdk-context.js"; export const links: LinksFunction = () => [ { rel: "stylesheet", href: stylesheet }, @@ -39,9 +40,10 @@ export function Layout({children}: { children: React.ReactNode }) { } export default function App() { + const auth = PortalAuthProvider.create("https://alpha.pinner.xyz") return ( - + + + ); }