Files
Homarr/src/pages/board/index.tsx

54 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-07-30 01:09:10 +02:00
import { GetServerSideProps, InferGetServerSidePropsType } from 'next';
2023-08-01 01:13:21 +02:00
import { SSRConfig } from 'next-i18next';
2023-07-30 01:09:10 +02:00
import { Dashboard } from '~/components/Dashboard/Dashboard';
2023-08-01 01:13:21 +02:00
import { BoardLayout } from '~/components/layout/Templates/BoardLayout';
2023-07-30 01:09:10 +02:00
import { useInitConfig } from '~/config/init';
import { getServerAuthSession } from '~/server/auth';
import { prisma } from '~/server/db';
import { getFrontendConfig } from '~/tools/config/getFrontendConfig';
import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations';
import { boardNamespaces } from '~/tools/server/translation-namespaces';
2023-07-30 01:09:10 +02:00
import { ConfigType } from '~/types/config';
export default function BoardPage({
config: initialConfig,
}: InferGetServerSidePropsType<typeof getServerSideProps>) {
useInitConfig(initialConfig);
2023-07-29 20:56:20 +02:00
return (
2023-08-01 01:13:21 +02:00
<BoardLayout>
2023-07-30 01:09:10 +02:00
<Dashboard />
2023-08-01 01:13:21 +02:00
</BoardLayout>
2023-07-29 20:56:20 +02:00
);
}
2023-07-30 01:09:10 +02:00
type BoardGetServerSideProps = {
config: ConfigType;
_nextI18Next?: SSRConfig['_nextI18Next'];
};
export const getServerSideProps: GetServerSideProps<BoardGetServerSideProps> = async (ctx) => {
const session = await getServerAuthSession(ctx);
const currentUserSettings = await prisma.userSettings.findFirst({
where: {
userId: session?.user?.id,
},
});
const translations = await getServerSideTranslations(
boardNamespaces,
2023-07-30 01:09:10 +02:00
ctx.locale,
ctx.req,
ctx.res
);
const boardName = currentUserSettings?.defaultBoard ?? 'default';
2023-07-30 20:17:35 +02:00
const config = await getFrontendConfig(boardName);
2023-07-30 01:09:10 +02:00
2023-07-29 20:56:20 +02:00
return {
2023-07-30 01:09:10 +02:00
props: {
config,
...translations,
},
2023-07-29 20:56:20 +02:00
};
};