shellphone.app/app/core/hooks/use-current-user.ts

18 lines
579 B
TypeScript
Raw Normal View History

2021-08-05 17:07:15 +00:00
import { useSession, useQuery } from "blitz";
import getCurrentUser from "../../users/queries/get-current-user";
export default function useCurrentUser() {
const session = useSession();
const [user] = useQuery(getCurrentUser, null, { enabled: Boolean(session.userId) });
const organization = user?.memberships[0]!.organization;
return {
user,
organization,
2021-10-15 22:24:28 +00:00
hasFilledTwilioCredentials: Boolean(
organization && organization.twilioAccountSid && organization.twilioAuthToken,
),
hasActiveSubscription: organization && organization.subscriptions.length > 0,
2021-08-05 17:07:15 +00:00
};
}