fix i18n flicker on booking pages (#1013)
This commit is contained in:
1 parent
b8e8319b23
commit
c28d800aa9
8 files changed
+76
-44
No files matched your search
+13
-6
@@ -12,18 +12,22 @@ import EventTypeDescription from "@components/eventtype/EventTypeDescription";
|
||||
import { HeadSeo } from "@components/seo/head-seo";
|
||||
import Avatar from "@components/ui/Avatar";
|
||||
|
||||
import { ssrInit } from "@server/lib/ssr";
|
||||
|
||||
export default function User(props: inferSSRProps<typeof getServerSideProps>) {
|
||||
const { isReady } = useTheme(props.user.theme);
|
||||
const { user, eventTypes } = props;
|
||||
const { t } = useLocale();
|
||||
|
||||
const nameOrUsername = user.name || user.username || "";
|
||||
|
||||
return (
|
||||
<>
|
||||
<HeadSeo
|
||||
title={user.name || user.username}
|
||||
description={user.name || user.username}
|
||||
name={user.name || user.username}
|
||||
avatar={user.avatar}
|
||||
title={nameOrUsername}
|
||||
description={nameOrUsername}
|
||||
name={nameOrUsername}
|
||||
avatar={user.avatar || undefined}
|
||||
/>
|
||||
{isReady && (
|
||||
<div className="bg-neutral-50 dark:bg-black h-screen">
|
||||
@@ -31,11 +35,11 @@ export default function User(props: inferSSRProps<typeof getServerSideProps>) {
|
||||
<div className="mb-8 text-center">
|
||||
<Avatar
|
||||
imageSrc={user.avatar}
|
||||
displayName={user.name}
|
||||
className="mx-auto w-24 h-24 rounded-full mb-4"
|
||||
alt={nameOrUsername}
|
||||
/>
|
||||
<h1 className="font-cal text-3xl font-bold text-neutral-900 dark:text-white mb-1">
|
||||
{user.name || user.username}
|
||||
{nameOrUsername}
|
||||
</h1>
|
||||
<p className="text-neutral-500 dark:text-white">{user.bio}</p>
|
||||
</div>
|
||||
@@ -72,6 +76,8 @@ export default function User(props: inferSSRProps<typeof getServerSideProps>) {
|
||||
}
|
||||
|
||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
||||
const ssr = await ssrInit(context);
|
||||
|
||||
const username = (context.query.user as string).toLowerCase();
|
||||
|
||||
const user = await prisma.user.findUnique({
|
||||
@@ -138,6 +144,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
props: {
|
||||
user,
|
||||
eventTypes,
|
||||
trpcState: ssr.dehydrate(),
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -7,6 +7,8 @@ import { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||
|
||||
import AvailabilityPage from "@components/booking/pages/AvailabilityPage";
|
||||
|
||||
import { ssrInit } from "@server/lib/ssr";
|
||||
|
||||
export type AvailabilityPageProps = inferSSRProps<typeof getServerSideProps>;
|
||||
|
||||
export default function Type(props: AvailabilityPageProps) {
|
||||
@@ -14,6 +16,7 @@ export default function Type(props: AvailabilityPageProps) {
|
||||
}
|
||||
|
||||
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
||||
const ssr = await ssrInit(context);
|
||||
// get query params and typecast them to string
|
||||
// (would be even better to assert them instead of typecasting)
|
||||
const userParam = asStringOrNull(context.query.user);
|
||||
@@ -185,6 +188,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
|
||||
date: dateParam,
|
||||
eventType: eventTypeObject,
|
||||
workingHours,
|
||||
trpcState: ssr.dehydrate(),
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -9,6 +9,8 @@ import { inferSSRProps } from "@lib/types/inferSSRProps";
|
||||
|
||||
import BookingPage from "@components/booking/pages/BookingPage";
|
||||
|
||||
import { ssrInit } from "@server/lib/ssr";
|
||||
|
||||
dayjs.extend(utc);
|
||||
dayjs.extend(timezone);
|
||||
|
||||
@@ -19,6 +21,8 @@ export default function Book(props: BookPageProps) {
|
||||
}
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
const ssr = await ssrInit(context);
|
||||
|
||||
const user = await prisma.user.findUnique({
|
||||
where: {
|
||||
username: asStringOrThrow(context.query.user),
|
||||
@@ -107,6 +111,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
},
|
||||
eventType: eventTypeObject,
|
||||
booking,
|
||||
trpcState: ssr.dehydrate(),
|
||||
},
|
||||
};
|
||||
}
|
||||
+1
-8
@@ -1,8 +1,7 @@
|
||||
import { DefaultSeo } from "next-seo";
|
||||
import type { AppProps as NextAppProps } from "next/app";
|
||||
import superjson from "superjson";
|
||||
|
||||
import AppProviders from "@lib/app-providers";
|
||||
import AppProviders, { AppProps } from "@lib/app-providers";
|
||||
import { seoConfig } from "@lib/config/next-seo.config";
|
||||
|
||||
import I18nLanguageHandler from "@components/I18nLanguageHandler";
|
||||
@@ -16,12 +15,6 @@ import { Maybe } from "@trpc/server";
|
||||
|
||||
import "../styles/globals.css";
|
||||
|
||||
// Workaround for https://github.com/vercel/next.js/issues/8592
|
||||
export type AppProps = NextAppProps & {
|
||||
/** Will be defined only is there was an error */
|
||||
err?: Error;
|
||||
};
|
||||
|
||||
function MyApp(props: AppProps) {
|
||||
const { Component, pageProps, err } = props;
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user