- Updated Italian translations for "Area Riservata" description in it.ts - Added <Head> components with appropriate titles for the following pages: - Admin Annunci - Admin Banners - Admin Blacklist - Admin Chats - Admin Etichette - Admin Flags - Admin Impostazioni - Admin Ordini - Admin Potenziali - Admin Prezziario - Admin Storage - Admin Testi Stringhe - Admin Utenti - Allegati - User Chat - Comunicazioni - Ordini - Profilo - Removed unused translation hooks from several components
86 lines
2.2 KiB
TypeScript
86 lines
2.2 KiB
TypeScript
import { getCookie } from "cookies-next";
|
|
import type { GetServerSideProps } from "next";
|
|
import Head from "next/head";
|
|
import { Suspense } from "react";
|
|
import { Sidebar } from "~/components/area-riservata/sidebar";
|
|
import Chat from "~/components/chat/chat";
|
|
import { LoadingPage } from "~/components/loading";
|
|
import { SiteHeader } from "~/components/navbar/site-header";
|
|
import type { NextPageWithLayout } from "~/pages/_app";
|
|
import type { ChatsChatid } from "~/schemas/public/Chats";
|
|
import type { Session } from "~/server/api/trpc";
|
|
import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper";
|
|
|
|
type UserChatProps = {
|
|
chatId: ChatsChatid;
|
|
session: Session;
|
|
};
|
|
|
|
const UserChat: NextPageWithLayout<UserChatProps> = ({
|
|
chatId,
|
|
session,
|
|
}: UserChatProps) => {
|
|
return (
|
|
<>
|
|
<Head>
|
|
<title>Chat - Infoalloggi.it</title>
|
|
</Head>
|
|
<div className="h-full flex-1 grow">
|
|
<div className="flex h-full w-full flex-row">
|
|
<div className="h-full">
|
|
<Sidebar
|
|
className="h-full"
|
|
defaultOpen={getCookie("sidebar_minimized") === "true"}
|
|
isAdmin={false}
|
|
/>
|
|
</div>
|
|
<Suspense fallback={<LoadingPage />}>
|
|
<Chat chatId={chatId} userData={session} />
|
|
</Suspense>
|
|
</div>
|
|
</div>
|
|
</>
|
|
);
|
|
};
|
|
|
|
UserChat.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>
|
|
);
|
|
};
|
|
|
|
export const getServerSideProps = (async (context) => {
|
|
const access_token = context.req.cookies.access_token;
|
|
|
|
const helper = await TrpcAuthedFetchingIstance({ access_token });
|
|
if (helper) {
|
|
const chat = await helper.trpc.chat.getSessionChats.fetch();
|
|
await helper.trpc.messagesSSE.infinite.prefetchInfinite({
|
|
chatId: chat.chatid,
|
|
});
|
|
await helper.trpc.chat.getUserInfosByChat.prefetch({
|
|
chatId: chat.chatid,
|
|
});
|
|
|
|
return {
|
|
props: {
|
|
chatId: chat.chatid,
|
|
session: helper.session,
|
|
trpcState: helper.trpc.dehydrate(),
|
|
},
|
|
};
|
|
}
|
|
return {
|
|
redirect: {
|
|
destination: "/login",
|
|
permanent: false,
|
|
},
|
|
};
|
|
}) satisfies GetServerSideProps<UserChatProps>;
|
|
|
|
export default UserChat;
|