diff --git a/client/src/components/layout/Header.tsx b/client/src/components/layout/Header.tsx index 24bbb30..be7547f 100644 --- a/client/src/components/layout/Header.tsx +++ b/client/src/components/layout/Header.tsx @@ -25,7 +25,7 @@ import { } from "lucide-react"; import { useTranslation } from "react-i18next"; -export default function Header() { +export function Header() { const { user, logout } = useAuth(); const { theme, toggleTheme } = useTheme(); const { t } = useTranslation(); @@ -160,3 +160,5 @@ export default function Header() { ); } + +export default Header; diff --git a/client/src/components/layout/Sidebar.tsx b/client/src/components/layout/Sidebar.tsx index 7e12795..a6f773a 100644 --- a/client/src/components/layout/Sidebar.tsx +++ b/client/src/components/layout/Sidebar.tsx @@ -233,3 +233,5 @@ export default function Sidebar({ className }: SidebarProps) { ); } + +export default Sidebar; diff --git a/client/src/pages/AIPage.tsx b/client/src/pages/AIPage.tsx index aac7928..aed43ac 100644 --- a/client/src/pages/AIPage.tsx +++ b/client/src/pages/AIPage.tsx @@ -18,14 +18,17 @@ export default function AIPage() { const { data: dailyJoke } = useQuery({ queryKey: ["/api/ai/daily-joke"], + select: (data: any) => data || { joke: "Why don't AI assistants ever get tired? Because they run on endless loops!" } }); const { data: status } = useQuery({ queryKey: ["/api/ai/status"], + select: (data: any) => data || { loaded: true } }); const { data: interactions = [] } = useQuery({ queryKey: ["/api/ai/interactions"], + select: (data: any) => Array.isArray(data) ? data : [] }); const handleSendMessage = async (e: React.FormEvent) => { @@ -60,12 +63,11 @@ export default function AIPage() { const generatePersonalizedJoke = async () => { try { - const response = await apiRequest("/api/ai/joke", { - method: "POST", - }); + const response = await apiRequest("POST", "/api/ai/generate-joke", {}); + const data = await response.json(); toast({ title: "Here's a joke for you!", - description: response.content || "Why don't tasks ever get lonely? Because they always have deadlines to meet!", + description: data.content || "Why don't tasks ever get lonely? Because they always have deadlines to meet!", }); } catch (error) { toast({ @@ -78,13 +80,13 @@ export default function AIPage() { const generateInsight = async (type: string) => { try { - const response = await apiRequest("/api/ai/insight", { - method: "POST", - body: JSON.stringify({ type }), + const response = await apiRequest("POST", "/api/ai/chat", { + message: `Generate an insight about my ${type} data` }); + const data = await response.json(); toast({ title: `${type.charAt(0).toUpperCase() + type.slice(1)} Insight`, - description: response.content || "Here's an insight based on your data!", + description: data.content || "Here's an insight based on your data!", }); } catch (error) { toast({ @@ -183,14 +185,14 @@ export default function AIPage() {
Model Status - - {status?.loaded ? "Ready" : "Loading"} + + {(status as any)?.loaded ? "Ready" : "Loading"}
Interactions Today - {interactions.length} + {Array.isArray(interactions) ? interactions.length : 0}
@@ -235,24 +237,24 @@ export default function AIPage() { -

"{dailyJoke.joke}"

+

"{(dailyJoke as any)?.joke || 'Why don\'t AI assistants ever get tired? Because they run on endless loops!'}"

)} {/* Recent Interactions */} - {interactions.length > 0 && ( + {Array.isArray(interactions) && interactions.length > 0 && ( Recent Interactions
- {interactions.slice(0, 5).map((interaction: any) => ( -
-
{interaction.type}
+ {(interactions as any[]).slice(0, 5).map((interaction: any, index: number) => ( +
+
{interaction.type || 'AI Interaction'}
- {new Date(interaction.createdAt).toLocaleDateString()} + {interaction.createdAt ? new Date(interaction.createdAt).toLocaleDateString() : 'Today'}
))}