set your twilio things from settings
This commit is contained in:
@ -1,17 +1,21 @@
|
||||
import { useSession, useQuery } from "blitz";
|
||||
|
||||
import getCurrentUser from "../../users/queries/get-current-user";
|
||||
import getCurrentPhoneNumber from "../../phone-numbers/queries/get-current-phone-number";
|
||||
|
||||
export default function useCurrentUser() {
|
||||
const session = useSession();
|
||||
const [user] = useQuery(getCurrentUser, null, { enabled: Boolean(session.userId) });
|
||||
const [user, userQuery] = useQuery(getCurrentUser, null, { enabled: Boolean(session.userId) });
|
||||
const organization = user?.memberships[0]!.organization;
|
||||
const hasFilledTwilioCredentials = Boolean(organization?.twilioAccountSid && organization?.twilioAuthToken);
|
||||
const [phoneNumber] = useQuery(getCurrentPhoneNumber, {}, { enabled: hasFilledTwilioCredentials });
|
||||
|
||||
return {
|
||||
user,
|
||||
organization,
|
||||
hasFilledTwilioCredentials: Boolean(
|
||||
organization && organization.twilioAccountSid && organization.twilioAuthToken,
|
||||
),
|
||||
hasFilledTwilioCredentials,
|
||||
hasPhoneNumber: Boolean(phoneNumber),
|
||||
hasActiveSubscription: organization && organization.subscriptions.length > 0,
|
||||
refetch: userQuery.refetch,
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user