"use client"; import { usePathname } from "next/navigation"; import React, { createContext, useContext, useState, ReactNode } from "react"; interface LayoutState { title: string; description: string; showHeader: boolean; headerContent?: ReactNode; sidebarContent?: ReactNode; theme: "light" | "dark" | "auto"; agent: string; } interface LayoutContextType { layoutState: LayoutState; updateLayout: (updates: Partial) => void; } const defaultLayoutState: LayoutState = { title: "DeepMind × Gemini", description: "Powered by Google's most advanced AI models for generating LinkedIn and X posts", showHeader: true, theme: "light", agent: "post_generation_agent", }; const LayoutContext = createContext(undefined); export function LayoutProvider({ children }: { children: ReactNode }) { const pathname = usePathname(); console.log(pathname); const [layoutState, setLayoutState] = useState({ ...defaultLayoutState, agent: pathname == "/post-generator" ? "post_generation_agent" : "stack_analysis_agent", }); console.log(layoutState); const updateLayout = (updates: Partial) => { setLayoutState((prev) => ({ ...prev, ...updates })); }; return ( {children} ); } export function useLayout() { const context = useContext(LayoutContext); if (context === undefined) { throw new Error("useLayout must be used within a LayoutProvider"); } return context; }