"use client"; import { useAtom, useAtomValue } from "jotai"; import { LoaderIcon, PanelRight, TriangleAlert } from "lucide-react"; import { toast } from "sonner"; import { activeChatAtom } from "@/atoms/chats/chat-query.atoms"; import { activeChathatUIAtom, activeChatIdAtom } from "@/atoms/chats/ui.atoms"; import type { GeneratePodcastRequest } from "@/contracts/types/podcast.types"; import { podcastsApiService } from "@/lib/apis/podcasts-api.service"; import { cn } from "@/lib/utils"; import { ChatPanelView } from "./ChatPanelView"; export function ChatPanelContainer() { const { data: activeChatState, isLoading: isChatLoading, error: chatError, } = useAtomValue(activeChatAtom); const activeChatIdState = useAtomValue(activeChatIdAtom); const authToken = localStorage.getItem("surfsense_bearer_token"); const { isChatPannelOpen } = useAtomValue(activeChathatUIAtom); const handleGeneratePodcast = async (request: GeneratePodcastRequest) => { try { if (!authToken) { throw new Error("Authentication error. Please log in again."); } await podcastsApiService.generatePodcast(request); toast.success(`Podcast generation started!`); } catch (error) { toast.error("Error generating podcast. Please try again later."); console.error("Error generating podcast:", JSON.stringify(error)); } }; return activeChatIdState ? (