feat: org types

This commit is contained in:
Bereket Engida
2024-09-14 01:20:12 +03:00
parent 7874e3816b
commit 22ddfcfe00
3 changed files with 22 additions and 15 deletions

View File

@@ -53,21 +53,7 @@ export function createAuthClient<Option extends ClientOptions>(
type InitialValue = ReturnType<(typeof $session)["get"]>["data"] | null;
function useSession(initialValue?: InitialValue) {
const [isClient, setIsClient] = useState(false);
const storeValue = useStore($session);
useEffect(() => {
setIsClient(true);
}, []);
if (!isClient && initialValue !== undefined) {
return {
data: initialValue || undefined,
loading: false,
error: undefined,
promise: () => Promise.resolve(),
} as unknown as typeof storeValue;
}
return storeValue;
}
const routes = {

View File

@@ -37,6 +37,26 @@ export const organizationClient = <O extends OrganizationClientOptions>(
$InferServerPlugin: {} as ReturnType<typeof organization>,
getActions: ($fetch) => ({
organization: {
$Infer: {
ActiveOrganization: {} as Prettify<
Organization & {
members: Prettify<
Member & {
user: {
id: string;
name: string;
email: string;
image: string;
};
}
>[];
invitations: Invitation[];
}
>,
Organization: {} as Organization,
Invitation: {} as Invitation,
Member: {} as Member,
},
setActive(orgId: string | null) {
activeOrgId.set(orgId);
},

View File

@@ -19,4 +19,5 @@
[ ] add a note about better-sqlite3 requiring to be added to webpack externals or find alternative that doesn't require it
[ ] add a section about updating user and changing password
[ ] mention how users can get user and session types
[ ] add a doc about account linking
[ ] add a doc about account linking
[ ] remove the section about using useSession in next with initialValue