/** * @file app/(app)/page.tsx * @description Main application layout page featuring the FriendsView. */ import { auth } from "@/auth"; import { db } from "@/db"; import { friendships } from "@/db/schema"; import { or, eq } from "drizzle-orm"; import { AppHeader } from "@/components/layout/AppHeader"; import { FriendsView, Friendship } from "@/components/friends/FriendsView"; export default async function AppPage() { const session = await auth(); let initialFriendships: Friendship[] = []; if (session?.user?.id) { const currentUserId = session.user.id; const rawFriendships = await db.query.friendships.findMany({ where: or( eq(friendships.senderId, currentUserId), eq(friendships.receiverId, currentUserId), ), with: { sender: { columns: { id: true, username: true, color: true, status: true, }, }, receiver: { columns: { id: true, username: true, color: true, status: true, }, }, }, }); initialFriendships = rawFriendships as Friendship[]; } return (
{session?.user?.id ? ( ) : ( <>

Welcome back!

Please sign in to view your friends list or start a conversation.

)}
); }