user organization can be null

This commit is contained in:
Nate Kelley 2025-01-23 09:29:07 -07:00
parent de85b20627
commit f07d5425b9
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
3 changed files with 3 additions and 3 deletions

View File

@ -67,7 +67,7 @@ export interface BusterUser {
export interface BusterUserResponse {
user: BusterUser;
teams: BusterUserTeam[];
organizations: BusterOrganization[];
organizations: BusterOrganization[] | null;
}
export interface BusterOrganization {

View File

@ -26,7 +26,7 @@ export default async function Layout({
const newUserRoute = createBusterRoute({ route: BusterAppRoutes.NEW_USER });
if (
(!userInfo?.organizations[0]?.id || !userInfo?.user?.name) &&
(!userInfo?.organizations?.[0]?.id || !userInfo?.user?.name) &&
!cookiePathname?.includes(newUserRoute) &&
pathname !== newUserRoute &&
supabaseContext.accessToken //added to avoid bug with anon user

View File

@ -26,7 +26,7 @@ export const useUserConfigProvider = ({ userInfo }: { userInfo: BusterUserRespon
const user = userResponse?.user;
const userTeams = userResponse?.teams || [];
const userOrganizations = userResponse?.organizations[0];
const userOrganizations = userResponse?.organizations?.[0];
const userRole = userOrganizations?.role;
const isUserRegistered =
!!userResponse && !!userResponse?.organizations?.[0]?.id && !!userResponse?.user?.name;