Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
🎨 Get urlId during ssr (#521)
Luke Vella4ee3d7cc8b21
diff --git a/src/pages/admin/[urlId].tsx b/src/pages/admin/[urlId].tsxindex a42578e2c..b4456fb31 100644--- a/src/pages/admin/[urlId].tsx+++ b/src/pages/admin/[urlId].tsx@@ -1,6 +1,5 @@import { GetServerSideProps } from "next";import Head from "next/head";-import { useRouter } from "next/router";import { useTranslation } from "next-i18next";import FullPageLoader from "@/components/full-page-loader";@@ -16,10 +15,8 @@ import { AdminControls } from "../../components/admin-control";import ModalProvider from "../../components/modal/modal-provider";import { NextPageWithLayout } from "../../types";-const Page: NextPageWithLayout = () => {- const { query } = useRouter();+const Page: NextPageWithLayout<{ urlId: string }> = ({ urlId }) => {const { t } = useTranslation("app");- const urlId = query.urlId as string;const pollQuery = trpcNext.poll.getByAdminUrlId.useQuery({ urlId });@@ -53,7 +50,16 @@ const Page: NextPageWithLayout = () => {Page.getLayout = getStandardLayout;export const getServerSideProps: GetServerSideProps = withSessionSsr(- withPageTranslations(["common", "app", "errors"]),+ [+ withPageTranslations(["common", "app", "errors"]),+ async (ctx) => {+ return {+ props: {+ urlId: ctx.query.urlId as string,+ },+ };+ },+ ],{onPrefetch: async (ssg, ctx) => {await ssg.poll.getByAdminUrlId.fetch({diff --git a/src/pages/p/[urlId].tsx b/src/pages/p/[urlId].tsxindex a74c1e833..e516bd275 100644--- a/src/pages/p/[urlId].tsx+++ b/src/pages/p/[urlId].tsx@@ -1,7 +1,6 @@import { GetServerSideProps } from "next";import Head from "next/head";import Link from "next/link";-import { useRouter } from "next/router";import { useTranslation } from "next-i18next";import { ParticipantsProvider } from "@/components/participants-provider";@@ -16,10 +15,7 @@ import StandardLayout from "../../components/layouts/standard-layout";import ModalProvider from "../../components/modal/modal-provider";import { NextPageWithLayout } from "../../types";-const Page: NextPageWithLayout = () => {- const { query } = useRouter();- const urlId = query.urlId as string;-+const Page: NextPageWithLayout<{ urlId: string }> = ({ urlId }) => {const pollQuery = trpcNext.poll.getByParticipantUrlId.useQuery({ urlId });const { user } = useUser();@@ -62,7 +58,16 @@ Page.getLayout = function getLayout(page) {};export const getServerSideProps: GetServerSideProps = withSessionSsr(- withPageTranslations(["common", "app", "errors"]),+ [+ withPageTranslations(["common", "app", "errors"]),+ async (ctx) => {+ return {+ props: {+ urlId: ctx.query.urlId as string,+ },+ };+ },+ ],{onPrefetch: async (ssg, ctx) => {await ssg.poll.getByParticipantUrlId.fetch({