mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-05 13:52:40 +02:00
feat: add ZeroProvider and wire into app layout
- Create components/providers/ZeroProvider.tsx with schema, queries, userID, context, and cacheURL configuration - Wire ZeroProvider into app/layout.tsx wrapping GlobalLoadingProvider inside ReactQueryClientProvider (same position ElectricProvider had)
This commit is contained in:
parent
da8f90bfe2
commit
6143a91406
2 changed files with 25 additions and 1 deletions
21
surfsense_web/components/providers/ZeroProvider.tsx
Normal file
21
surfsense_web/components/providers/ZeroProvider.tsx
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
"use client";
|
||||
|
||||
import { currentUserAtom } from "@/atoms/user/user-query.atoms";
|
||||
import { queries } from "@/zero/queries";
|
||||
import { schema } from "@/zero/schema";
|
||||
import { ZeroProvider as ZeroReactProvider } from "@rocicorp/zero/react";
|
||||
import { useAtomValue } from "jotai";
|
||||
|
||||
const cacheURL = process.env.NEXT_PUBLIC_ZERO_CACHE_URL || "http://localhost:4848";
|
||||
|
||||
export function ZeroProvider({ children }: { children: React.ReactNode }) {
|
||||
const { data: user } = useAtomValue(currentUserAtom);
|
||||
const userID = user?.id ? String(user.id) : "";
|
||||
const context = user?.id ? { userId: String(user.id) } : undefined;
|
||||
|
||||
return (
|
||||
<ZeroReactProvider {...{ userID, context, cacheURL, schema, queries }}>
|
||||
{children}
|
||||
</ZeroReactProvider>
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue