import {TooltipProvider} from "@/components/ui/tooltip";
import {Separator} from "@/components/ui/separator";
import SessionHeader from "@/app/(patients)/app/sessions/[sessionId]/_components/_session_header";
import {getSessionById, getSessionMessages} from "@/lib/backend/api-sessions";
import SessionDetailsPage from "@/app/(patients)/app/sessions/[sessionId]/_components/_session_details_page";
import {useUser} from "@/lib/hooks/useUser";


export default async function SessionPage({params}: { params: { sessionId: string } }) {

    if (!params.sessionId) throw new Error("failed to get session id from url");
    const currentUser = await useUser();
    const session = await getSessionById(params.sessionId);
    const messages = await getSessionMessages(params.sessionId);

    return (
        <TooltipProvider>
            <div className="flex h-[calc(100dvh_-_5rem)] flex-col">
                <SessionHeader/>
                <Separator/>

                <SessionDetailsPage
                    sessionMessages={messages}
                    session={session}
                    currentUser={currentUser}/>
            </div>
        </TooltipProvider>
    )
}