import Image from "next/image"; import { useRouter } from "next/router"; import { useTranslation } from "next-i18next"; import { FaBars } from "react-icons/fa"; import { DrawerItemButton, DrawerItemButtonLoader } from "./DrawerItemButton"; import type { DisplayProps } from "./Sidebar"; import Sidebar from "./Sidebar"; import { useAuth } from "../../hooks/useAuth"; import { api } from "../../utils/api"; import AuthItem from "../sidebar/AuthItem"; import LinkIconItem from "../sidebar/LinkIconItem"; import LinkItem from "../sidebar/LinkItem"; import { PAGE_LINKS, SOCIAL_LINKS } from "../sidebar/links"; const LeftSidebar = ({ show, setShow, onReload }: DisplayProps & { onReload?: () => void }) => { const router = useRouter(); const { session, signIn, signOut, status } = useAuth(); const [t] = useTranslation("drawer"); const { isLoading, data } = api.agent.getAll.useQuery(undefined, { enabled: status === "authenticated", }); const userAgents = data ?? []; const navigateToPage = (href: string) => { if (router.pathname === href) { onReload?.(); return; } void router.push(href); }; return (
Reworkd AI

Reworkd

{status === "unauthenticated" && (
void signIn()}> {t("SIGN_IN")} {" "} {t("SIGN_IN_NOTICE")}
)} {status === "authenticated" && !isLoading && userAgents.length === 0 && (
{t("NEED_TO_SIGN_IN_AND_CREATE_AGENT_FIRST")}
)} {(status === "loading" || (status === "authenticated" && isLoading)) && (
{Array(13) .fill(0) .map((_, index) => ( ))}
)} {userAgents.map((agent, index) => ( void router.push(`/agent?id=${agent.id}`)} /> ))}
); }; export default LeftSidebar;