feat(www): Finish up on the onboarding (#210)

Merging this prematurely to make sure the team is on the same boat... like dang! We need to find a better way to do this. 

Plus it has become too big
This commit is contained in:
Wanjohi
2025-03-26 02:21:53 +03:00
committed by GitHub
parent 957eca7794
commit f62fc1fb4b
106 changed files with 6329 additions and 866 deletions

View File

@@ -0,0 +1,39 @@
import { useTeam } from "./context"
import { createEffect } from "solid-js"
import { schema } from "@nestri/zero/schema"
import { useQuery } from "@rocicorp/zero/solid"
import { useOpenAuth } from "@openauthjs/solid"
import { Query, Schema, Zero } from "@rocicorp/zero"
import { useAccount } from "@nestri/www/providers/account"
import { createInitializedContext } from "@nestri/www/common/context"
export const { use: useZero, provider: ZeroProvider } =
createInitializedContext("ZeroContext", () => {
const auth = useOpenAuth()
const account = useAccount()
const team = useTeam()
const zero = new Zero({
schema: schema,
auth: () => auth.access(),
userID: account.current.email,
storageKey: team().id,
server: import.meta.env.VITE_ZERO_URL,
})
return {
mutate: zero.mutate,
query: zero.query,
client: zero,
ready: true,
};
});
export function usePersistentQuery<TSchema extends Schema, TTable extends keyof TSchema['tables'] & string, TReturn>(querySignal: () => Query<TSchema, TTable, TReturn>) {
const team = useTeam()
//@ts-ignore
const q = () => querySignal().where("team_id", "=", team().id).where("time_deleted", "IS", null)
createEffect(() => {
q().preload()
})
return useQuery<TSchema, TTable, TReturn>(q)
}