diff --git a/src/components/layout/new-header/Header.tsx b/src/components/layout/new-header/Header.tsx index 771f23ce5..fa243b2ba 100644 --- a/src/components/layout/new-header/Header.tsx +++ b/src/components/layout/new-header/Header.tsx @@ -19,7 +19,7 @@ export const MainHeader = ({ showExperimental = false, logoHref = '/', headerActions, - leftIcon + leftIcon, }: MainHeaderProps) => { const { breakpoints } = useMantineTheme(); const isSmallerThanMd = useMediaQuery(`(max-width: ${breakpoints.sm})`); @@ -30,9 +30,9 @@ export const MainHeader = ({
- + {leftIcon} - + diff --git a/src/config/provider.tsx b/src/config/provider.tsx index d0002b67d..a1a5b79ca 100644 --- a/src/config/provider.tsx +++ b/src/config/provider.tsx @@ -24,13 +24,13 @@ const ConfigContext = createContext({ export const ConfigProvider = ({ children, config: fallbackConfig, - configName: initialConfigName, }: { children: ReactNode; config?: ConfigType; - configName?: string; }) => { - const [configName, setConfigName] = useState(initialConfigName || 'default'); + const [configName, setConfigName] = useState( + fallbackConfig?.configProperties.name || 'unknown' + ); const [configVersion, setConfigVersion] = useState(0); const { configs } = useConfigStore((s) => ({ configs: s.configs }), shallow); const { setPrimaryColor, setSecondaryColor, setPrimaryShade } = useColorTheme(); diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 9d8d567ee..191ec9e05 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -7,6 +7,7 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'; import Consola from 'consola'; import { getCookie, setCookie } from 'cookies-next'; +import 'flag-icons/css/flag-icons.min.css'; import { GetServerSidePropsContext } from 'next'; import { Session } from 'next-auth'; import { SessionProvider, getSession } from 'next-auth/react'; @@ -34,7 +35,6 @@ import { getServiceSidePackageAttributes, } from '../tools/server/getPackageVersion'; import { theme } from '../tools/server/theme/theme'; -import "/node_modules/flag-icons/css/flag-icons.min.css"; function App( this: any, @@ -44,7 +44,6 @@ function App( packageAttributes: ServerSidePackageAttributesType; editModeEnabled: boolean; config?: ConfigType; - configName?: string; session: Session; }> ) { diff --git a/src/pages/b/[id].tsx b/src/pages/b/[id].tsx deleted file mode 100644 index 28fd00146..000000000 --- a/src/pages/b/[id].tsx +++ /dev/null @@ -1 +0,0 @@ -export { default, getServerSideProps } from '../board/[id]'; diff --git a/src/pages/b/[slug].tsx b/src/pages/b/[slug].tsx new file mode 100644 index 000000000..84d38586a --- /dev/null +++ b/src/pages/b/[slug].tsx @@ -0,0 +1 @@ +export { default, getServerSideProps } from '../board/[slug]'; diff --git a/src/pages/board/[id].tsx b/src/pages/board/[id].tsx deleted file mode 100644 index 788b14bd6..000000000 --- a/src/pages/board/[id].tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { GetServerSideProps } from 'next'; - -export default function BoardPage() { - return ( -
-

BoardPage

-
- ); -} - -export const getServerSideProps: GetServerSideProps = async () => { - console.log('getServerSideProps'); - return { - props: {}, - }; -}; diff --git a/src/pages/board/[slug].tsx b/src/pages/board/[slug].tsx new file mode 100644 index 000000000..9bd697164 --- /dev/null +++ b/src/pages/board/[slug].tsx @@ -0,0 +1,65 @@ +import { GetServerSideProps, InferGetServerSidePropsType } from 'next'; +import { SSRConfig } from 'next-i18next'; +import { z } from 'zod'; +import { Dashboard } from '~/components/Dashboard/Dashboard'; +import { MainLayout } from '~/components/layout/main'; +import { useInitConfig } from '~/config/init'; +import { configExists } from '~/tools/config/configExists'; +import { getFrontendConfig } from '~/tools/config/getFrontendConfig'; +import { getServerSideTranslations } from '~/tools/server/getServerSideTranslations'; +import { dashboardNamespaces } from '~/tools/server/translation-namespaces'; +import { ConfigType } from '~/types/config'; + +import { HeaderActions } from '.'; + +export default function BoardPage({ + config: initialConfig, +}: InferGetServerSidePropsType) { + useInitConfig(initialConfig); + + return ( + }> + + + ); +} + +type BoardGetServerSideProps = { + config: ConfigType; + _nextI18Next?: SSRConfig['_nextI18Next']; +}; + +const routeParamsSchema = z.object({ + slug: z.string(), +}); + +export const getServerSideProps: GetServerSideProps = async ({ + params, + locale, + req, + res, +}) => { + const routeParams = routeParamsSchema.safeParse(params); + if (!routeParams.success) { + return { + notFound: true, + }; + } + + const isPresent = configExists(routeParams.data.slug); + if (!isPresent) { + return { + notFound: true, + }; + } + + const config = await getFrontendConfig(routeParams.data.slug); + const translations = await getServerSideTranslations(dashboardNamespaces, locale, req, res); + + return { + props: { + config, + ...translations, + }, + }; +}; diff --git a/src/pages/board/index.tsx b/src/pages/board/index.tsx index 50daefff9..fa7c7c3ec 100644 --- a/src/pages/board/index.tsx +++ b/src/pages/board/index.tsx @@ -55,7 +55,7 @@ export const getServerSideProps: GetServerSideProps = a ctx.res ); const boardName = currentUserSettings?.defaultBoard ?? 'default'; - const config = await getFrontendConfig(boardName as string); + const config = await getFrontendConfig(boardName); return { props: { @@ -65,7 +65,7 @@ export const getServerSideProps: GetServerSideProps = a }; }; -const HeaderActions = () => { +export const HeaderActions = () => { const { data: sessionData } = useSession(); if (!sessionData?.user?.isAdmin) return null;