-
- {t("your_day_ends_at")} {convertMinsToHrsMins(user.endTime)}
+
+
+ {t("overview_of_day")}{" "}
+
{
+ setSelectedDate(dayjs(e.target.value));
+ }}
+ />
+
{t("hover_over_bold_times_tip")}
+
+
+
+ {t("your_day_starts_at")} {convertMinsToHrsMins(user.startTime)}
+
+
+ {loading ? (
+
+ ) : availability.length > 0 ? (
+ availability.map((slot) => (
+
+
+ {t("calendar_shows_busy_between")}{" "}
+
+ {dayjs(slot.start).format("HH:mm")}
+ {" "}
+ {t("and")}{" "}
+
+ {dayjs(slot.end).format("HH:mm")}
+ {" "}
+ {t("on")} {dayjs(slot.start).format("D")}{" "}
+ {t(dayjs(slot.start).format("MMMM").toLowerCase())} {dayjs(slot.start).format("YYYY")}
+ ))
+ ) : (
+
+
{t("calendar_no_busy_slots")}
+
+ )}
+
+
+
+ {t("your_day_ends_at")} {convertMinsToHrsMins(user.endTime)}
+
+
+ );
+};
+
+export default function Troubleshoot() {
+ const query = trpc.useQuery(["viewer.me"]);
+ const { t } = useLocale();
+ return (
+
);
}
-
-export const getServerSideProps = async (context: GetServerSidePropsContext) => {
- const session = await getSession(context);
- const locale = await getOrSetUserLocaleFromHeaders(context.req);
-
- if (!session?.user?.id) {
- return { redirect: { permanent: false, destination: "/auth/login" } };
- }
-
- const user = await prisma.user.findFirst({
- where: {
- id: session.user.id,
- },
- select: {
- startTime: true,
- endTime: true,
- username: true,
- },
- });
-
- if (!user) return { redirect: { permanent: false, destination: "/auth/login" } };
-
- return {
- props: {
- session,
- user,
- ...(await serverSideTranslations(locale, ["common"])),
- },
- };
-};
diff --git a/pages/bookings/[status].tsx b/pages/bookings/[status].tsx
index 6feaa6d5..d672e0f0 100644
--- a/pages/bookings/[status].tsx
+++ b/pages/bookings/[status].tsx
@@ -23,7 +23,11 @@ export default function Bookings() {
const router = useRouter();
const status = router.query?.status as BookingListingStatus;
- const query = trpc.useQuery(["viewer.bookings", { status }]);
+
+ const query = trpc.useQuery(["viewer.bookings", { status }], {
+ // first render has status `undefined`
+ enabled: !!status,
+ });
return (
diff --git a/pages/cancel/[uid].tsx b/pages/cancel/[uid].tsx
index 00aa8b82..870bec90 100644
--- a/pages/cancel/[uid].tsx
+++ b/pages/cancel/[uid].tsx
@@ -2,11 +2,9 @@ import { CalendarIcon, XIcon } from "@heroicons/react/solid";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import { getSession } from "next-auth/client";
-import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useRouter } from "next/router";
import { useState } from "react";
-import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
import { useLocale } from "@lib/hooks/useLocale";
import prisma from "@lib/prisma";
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry";
@@ -145,7 +143,6 @@ export default function Type(props) {
export async function getServerSideProps(context) {
const session = await getSession(context);
- const locale = await getOrSetUserLocaleFromHeaders(context.req);
const booking = await prisma.booking.findUnique({
where: {
uid: context.query.uid,
@@ -202,7 +199,6 @@ export async function getServerSideProps(context) {
booking: bookingObj,
cancellationAllowed:
(!!session?.user && session.user.id == booking.user?.id) || booking.startTime >= new Date(),
- ...(await serverSideTranslations(locale, ["common"])),
},
};
}
diff --git a/pages/event-types/[type].tsx b/pages/event-types/[type].tsx
index a2b61091..aea6f0ad 100644
--- a/pages/event-types/[type].tsx
+++ b/pages/event-types/[type].tsx
@@ -19,7 +19,6 @@ import dayjs from "dayjs";
import timezone from "dayjs/plugin/timezone";
import utc from "dayjs/plugin/utc";
import { GetServerSidePropsContext } from "next";
-import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useRouter } from "next/router";
import React, { useEffect, useRef, useState } from "react";
import { FormattedNumber, IntlProvider } from "react-intl";
@@ -37,7 +36,6 @@ import {
import { getSession } from "@lib/auth";
import classNames from "@lib/classNames";
import { HttpError } from "@lib/core/http/error";
-import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
import { useLocale } from "@lib/hooks/useLocale";
import getIntegrations, { hasIntegration } from "@lib/integrations/getIntegrations";
import { LocationType } from "@lib/location";
@@ -1097,8 +1095,6 @@ const EventTypePage = (props: inferSSRProps) => {
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const { req, query } = context;
const session = await getSession({ req });
- const locale = await getOrSetUserLocaleFromHeaders(context.req);
-
const typeParam = parseInt(asStringOrThrow(query.type));
if (!session?.user?.id) {
@@ -1278,7 +1274,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
return {
props: {
session,
- localeProp: locale,
eventType: eventTypeObject,
locationOptions,
availability,
@@ -1286,7 +1281,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
teamMembers,
hasPaymentIntegration,
currency,
- ...(await serverSideTranslations(locale, ["common"])),
},
};
};
diff --git a/pages/settings/billing.tsx b/pages/settings/billing.tsx
index a6ce3664..8a28bce5 100644
--- a/pages/settings/billing.tsx
+++ b/pages/settings/billing.tsx
@@ -1,11 +1,6 @@
import { ExternalLinkIcon } from "@heroicons/react/solid";
-import { GetServerSidePropsContext } from "next";
-import { serverSideTranslations } from "next-i18next/serverSideTranslations";
-import { getSession } from "@lib/auth";
-import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
import { useLocale } from "@lib/hooks/useLocale";
-import prisma from "@lib/prisma";
import SettingsShell from "@components/SettingsShell";
import Shell from "@components/Shell";
@@ -55,36 +50,3 @@ export default function Billing() {
);
}
-
-export async function getServerSideProps(context: GetServerSidePropsContext) {
- const session = await getSession(context);
- const locale = await getOrSetUserLocaleFromHeaders(context.req);
-
- if (!session) {
- return { redirect: { permanent: false, destination: "/auth/login" } };
- }
-
- const user = await prisma.user.findFirst({
- where: {
- email: session.user.email,
- },
- select: {
- id: true,
- username: true,
- name: true,
- email: true,
- bio: true,
- avatar: true,
- timeZone: true,
- weekStart: true,
- },
- });
-
- return {
- props: {
- session,
- user,
- ...(await serverSideTranslations(locale, ["common"])),
- },
- };
-}
diff --git a/pages/settings/embed.tsx b/pages/settings/embed.tsx
index 8b8044c0..77eeb03d 100644
--- a/pages/settings/embed.tsx
+++ b/pages/settings/embed.tsx
@@ -1,14 +1,9 @@
import { PlusIcon } from "@heroicons/react/outline";
-import { GetServerSidePropsContext } from "next";
import { useSession } from "next-auth/client";
-import { serverSideTranslations } from "next-i18next/serverSideTranslations";
-import { useEffect, useState, useRef } from "react";
+import { useEffect, useRef, useState } from "react";
-import { getSession } from "@lib/auth";
-import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
import { useLocale } from "@lib/hooks/useLocale";
-import prisma from "@lib/prisma";
-import { inferSSRProps } from "@lib/types/inferSSRProps";
+import { trpc } from "@lib/trpc";
import { Webhook } from "@lib/webhook";
import { Dialog, DialogClose, DialogContent, DialogHeader, DialogTrigger } from "@components/Dialog";
@@ -20,7 +15,8 @@ import Switch from "@components/ui/Switch";
import EditWebhook from "@components/webhook/EditWebhook";
import WebhookList from "@components/webhook/WebhookList";
-export default function Embed(props: inferSSRProps
) {
+export default function Embed() {
+ const user = trpc.useQuery(["viewer.me"]).data;
const [, loading] = useSession();
const { t } = useLocale();
@@ -51,11 +47,7 @@ export default function Embed(props: inferSSRProps) {
getWebhooks();
}, []);
- if (loading) {
- return ;
- }
-
- const iframeTemplate = ``;
+ const iframeTemplate = ``;
const htmlTemplate = `${t(
"schedule_a_meeting"
)}${iframeTemplate}`;
@@ -111,6 +103,10 @@ export default function Embed(props: inferSSRProps) {
setEditWebhookEnabled(false);
};
+ if (loading) {
+ return ;
+ }
+
return (
@@ -280,41 +276,10 @@ export default function Embed(props: inferSSRProps) {
)}
- {!!editWebhookEnabled &&
}
+ {!!editWebhookEnabled && webhookToEdit && (
+
+ )}
);
}
-
-export async function getServerSideProps(context: GetServerSidePropsContext) {
- const session = await getSession(context);
- const locale = await getOrSetUserLocaleFromHeaders(context.req);
-
- if (!session?.user?.email) {
- return { redirect: { permanent: false, destination: "/auth/login" } };
- }
-
- const user = await prisma.user.findFirst({
- where: {
- email: session?.user?.email,
- },
- select: {
- id: true,
- username: true,
- name: true,
- email: true,
- bio: true,
- avatar: true,
- timeZone: true,
- weekStart: true,
- },
- });
-
- return {
- props: {
- session,
- user,
- ...(await serverSideTranslations(locale, ["common"])),
- },
- };
-}
diff --git a/pages/settings/profile.tsx b/pages/settings/profile.tsx
index 63763cd3..e8f0d137 100644
--- a/pages/settings/profile.tsx
+++ b/pages/settings/profile.tsx
@@ -1,7 +1,6 @@
import { InformationCircleIcon } from "@heroicons/react/outline";
import crypto from "crypto";
import { GetServerSidePropsContext } from "next";
-import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { RefObject, useEffect, useRef, useState } from "react";
import Select from "react-select";
import TimezoneSelect from "react-timezone-select";
@@ -105,14 +104,12 @@ export default function Settings(props: Props) {
{ value: "dark", label: t("dark") },
];
- const usernameRef = useRef
(null);
- const nameRef = useRef(null);
- const descriptionRef = useRef();
- const avatarRef = useRef(null);
- const hideBrandingRef = useRef(null);
- const [selectedTheme, setSelectedTheme] = useState({
- value: props.user.theme,
- });
+ const usernameRef = useRef(null!);
+ const nameRef = useRef(null!);
+ const descriptionRef = useRef(null!);
+ const avatarRef = useRef(null!);
+ const hideBrandingRef = useRef(null!);
+ const [selectedTheme, setSelectedTheme] = useState(undefined);
const [selectedTimeZone, setSelectedTimeZone] = useState({ value: props.user.timeZone });
const [selectedWeekStartDay, setSelectedWeekStartDay] = useState({
value: props.user.weekStart,
@@ -128,25 +125,12 @@ export default function Settings(props: Props) {
useEffect(() => {
setSelectedTheme(
- props.user.theme ? themeOptions.find((theme) => theme.value === props.user.theme) : null
+ props.user.theme ? themeOptions.find((theme) => theme.value === props.user.theme) : undefined
);
setSelectedWeekStartDay({ value: props.user.weekStart, label: props.user.weekStart });
setSelectedLanguage({ value: props.localeProp, label: props.localeLabels[props.localeProp] });
}, []);
- const handleAvatarChange = (newAvatar) => {
- avatarRef.current.value = newAvatar;
- const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
- window.HTMLInputElement.prototype,
- "value"
- ).set;
- nativeInputValueSetter.call(avatarRef.current, newAvatar);
- const ev2 = new Event("input", { bubbles: true });
- avatarRef.current.dispatchEvent(ev2);
- updateProfileHandler(ev2);
- setImageSrc(newAvatar);
- };
-
async function updateProfileHandler(event) {
event.preventDefault();
@@ -273,7 +257,18 @@ export default function Settings(props: Props) {
target="avatar"
id="avatar-upload"
buttonMsg={t("change_avatar")}
- handleAvatarChange={handleAvatarChange}
+ handleAvatarChange={(newAvatar) => {
+ avatarRef.current.value = newAvatar;
+ const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
+ window.HTMLInputElement.prototype,
+ "value"
+ ).set;
+ nativeInputValueSetter.call(avatarRef.current, newAvatar);
+ const ev2 = new Event("input", { bubbles: true });
+ avatarRef.current.dispatchEvent(ev2);
+ updateProfileHandler(ev2);
+ setImageSrc(newAvatar);
+ }}
imageSrc={imageSrc}
/>
@@ -464,7 +459,6 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
...user,
emailMd5: crypto.createHash("md5").update(user.email).digest("hex"),
},
- ...(await serverSideTranslations(locale, ["common"])),
},
};
};
diff --git a/pages/settings/security.tsx b/pages/settings/security.tsx
index 4f1fbe7c..93b798d9 100644
--- a/pages/settings/security.tsx
+++ b/pages/settings/security.tsx
@@ -1,59 +1,22 @@
-import { GetServerSidePropsContext } from "next";
-import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import React from "react";
-import { getSession } from "@lib/auth";
-import { getOrSetUserLocaleFromHeaders } from "@lib/core/i18n/i18n.utils";
import { useLocale } from "@lib/hooks/useLocale";
-import prisma from "@lib/prisma";
-import { inferSSRProps } from "@lib/types/inferSSRProps";
+import { trpc } from "@lib/trpc";
import SettingsShell from "@components/SettingsShell";
import Shell from "@components/Shell";
import ChangePasswordSection from "@components/security/ChangePasswordSection";
import TwoFactorAuthSection from "@components/security/TwoFactorAuthSection";
-export default function Security({ user }: inferSSRProps