--- import '../styles/global.css'; import { Icon } from 'astro-icon/components'; import { db } from '../db'; import { members, organizations } from '../db/schema'; import { eq } from 'drizzle-orm'; import Avatar from '../components/Avatar.astro'; import { ClientRouter } from "astro:transitions"; interface Props { title: string; } const { title } = Astro.props; const user = Astro.locals.user; if (!user) { return Astro.redirect('/login'); } // Get user's team memberships const userMemberships = await db.select({ membership: members, organization: organizations, }) .from(members) .innerJoin(organizations, eq(members.organizationId, organizations.id)) .where(eq(members.userId, user.id)) .all(); // Get current team from cookie or use first membership const currentTeamId = Astro.cookies.get('currentTeamId')?.value || userMemberships[0]?.organization.id; const currentTeam = userMemberships.find(m => m.organization.id === currentTeamId); ---