mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-26 08:56:40 -05:00
feat: org types
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
|
||||
3
todo.md
3
todo.md
@@ -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
|
||||
Reference in New Issue
Block a user