import { useNavigate } from "@tanstack/react-router"; import { formatDistanceToNow } from "date-fns"; import { PlusCircle } from "lucide-react"; import { useAtom, useSetAtom } from "jotai"; import { selectedAppIdAtom } from "@/atoms/appAtoms"; import { SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarMenu, SidebarMenuItem, } from "@/components/ui/sidebar"; import { Button } from "@/components/ui/button"; import { selectedChatIdAtom } from "@/atoms/chatAtoms"; import { useLoadApps } from "@/hooks/useLoadApps"; export function AppList({ show }: { show?: boolean }) { const navigate = useNavigate(); const [selectedAppId, setSelectedAppId] = useAtom(selectedAppIdAtom); const setSelectedChatId = useSetAtom(selectedChatIdAtom); const { apps, loading, error } = useLoadApps(); if (!show) { return null; } const handleAppClick = (id: number) => { setSelectedAppId(id); setSelectedChatId(null); navigate({ to: "/", search: { appId: id }, }); }; const handleNewApp = () => { navigate({ to: "/" }); // We'll eventually need a create app workflow }; return ( Your Apps
{loading ? (
Loading apps...
) : error ? (
Error loading apps
) : apps.length === 0 ? (
No apps found
) : ( {apps.map((app) => ( ))} )}
); }