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';
|
2023-08-05 17:18:05 +02:00
|
|
|
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(
|
2023-08-05 17:18:05 +02:00
|
|
|
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
|
|
|
};
|
|
|
|
|
};
|