64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
|
|
import Head from "next/head";
|
||
|
|
import { Sidebar } from "~/components/area-riservata/sidebar";
|
||
|
|
import { LoadingPage } from "~/components/loading";
|
||
|
|
import { useTranslation } from "~/providers/I18nProvider";
|
||
|
|
import { type NextPageWithLayout } from "~/pages/_app";
|
||
|
|
import { SiteHeader } from "~/components/navbar/site-header";
|
||
|
|
import { useSession } from "~/providers/SessionProvider";
|
||
|
|
import { Status500 } from "~/components/status-page";
|
||
|
|
import { api } from "~/utils/api";
|
||
|
|
import { ChatSidebar } from "~/components/chat/chat-sidebar";
|
||
|
|
|
||
|
|
const AdminChats: NextPageWithLayout = () => {
|
||
|
|
const { t } = useTranslation();
|
||
|
|
const session = useSession();
|
||
|
|
|
||
|
|
const { data: activeChats, isLoading: isLoadingActiveChats } =
|
||
|
|
api.chat.getActiveChats.useQuery();
|
||
|
|
|
||
|
|
const { data: inactiveUsers, isLoading: isLoadingInactiveUsers } =
|
||
|
|
api.users.getActiveUsersWithoutChat.useQuery();
|
||
|
|
|
||
|
|
if (
|
||
|
|
session.status === "pending" ||
|
||
|
|
isLoadingActiveChats ||
|
||
|
|
isLoadingInactiveUsers
|
||
|
|
)
|
||
|
|
return <LoadingPage />;
|
||
|
|
if (!session || !session.user || !activeChats || !inactiveUsers)
|
||
|
|
return <Status500 />;
|
||
|
|
|
||
|
|
return (
|
||
|
|
<>
|
||
|
|
<Head>
|
||
|
|
<title>{t.heads.area_riservata_titolo}</title>
|
||
|
|
<meta name="description" content={t.heads.area_riservata_description} />
|
||
|
|
</Head>
|
||
|
|
<div className="flex h-full w-full flex-col md:flex-row">
|
||
|
|
<Sidebar isAdmin />
|
||
|
|
|
||
|
|
<div className="h-full flex-1 grow">
|
||
|
|
<div className="flex h-full w-full flex-row">
|
||
|
|
<div className="h-full border-r">
|
||
|
|
<ChatSidebar chatId={null} />
|
||
|
|
</div>
|
||
|
|
<div className="w-full" />
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</>
|
||
|
|
);
|
||
|
|
};
|
||
|
|
export default AdminChats;
|
||
|
|
|
||
|
|
AdminChats.getLayout = function getLayout(page) {
|
||
|
|
return (
|
||
|
|
<div className="h-screen">
|
||
|
|
<div className="flex h-full flex-col">
|
||
|
|
<SiteHeader />
|
||
|
|
<div className="flex min-h-0 grow">{page}</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
};
|