Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
removed SSR trpc calls instead SPA for logged in pages (calcom#6936)
Browse files Browse the repository at this point in the history
* removed SSR trpc

* Re added debug endpoint

* Update me.ts

* Fixes unused imports

* Rollback unrelated changes

---------

Co-authored-by: zomars <zomars@me.com>
Co-authored-by: Efraín Rochín <roae.85@gmail.com>
  • Loading branch information
3 people authored and fritterhoff committed Feb 26, 2023
1 parent 5e27fdc commit 5811e6e
Show file tree
Hide file tree
Showing 23 changed files with 3 additions and 301 deletions.
13 changes: 0 additions & 13 deletions apps/web/pages/availability/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useAutoAnimate } from "@formkit/auto-animate/react";
import type { GetServerSidePropsContext } from "next";

import { NewScheduleButton, ScheduleListItem } from "@calcom/features/schedules";
import Shell from "@calcom/features/shell/Shell";
Expand All @@ -14,8 +13,6 @@ import { HttpError } from "@lib/core/http/error";

import SkeletonLoader from "@components/availability/SkeletonLoader";

import { ssrInit } from "@server/lib/ssr";

export function AvailabilityList({ schedules }: RouterOutputs["viewer"]["availability"]["list"]) {
const { t } = useLocale();
const utils = trpc.useContext();
Expand Down Expand Up @@ -118,13 +115,3 @@ export default function AvailabilityPage() {
</div>
);
}

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);

return {
props: {
trpcState: ssr.dehydrate(),
},
};
};
20 changes: 3 additions & 17 deletions apps/web/pages/event-types/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useAutoAnimate } from "@formkit/auto-animate/react";
import type { GetServerSidePropsContext } from "next";
import Link from "next/link";
import { useRouter } from "next/router";
import type { FC } from "react";
Expand Down Expand Up @@ -60,8 +59,6 @@ import { HttpError } from "@lib/core/http/error";
import { EmbedButton, EmbedDialog } from "@components/Embed";
import SkeletonLoader from "@components/eventtype/SkeletonLoader";

import { ssrInit } from "@server/lib/ssr";

type EventTypeGroups = RouterOutputs["viewer"]["eventTypes"]["getByViewer"]["eventTypeGroups"];
type EventTypeGroupProfile = EventTypeGroups[number]["profile"];

Expand All @@ -73,6 +70,7 @@ interface EventTypeListHeadingProps {

type EventTypeGroup = EventTypeGroups[number];
type EventType = EventTypeGroup["eventTypes"][number];

interface EventTypeListProps {
group: EventTypeGroup;
groupIndex: number;
Expand Down Expand Up @@ -134,11 +132,9 @@ const Item = ({ type, group, readOnly }: { type: EventType; group: EventTypeGrou
data-testid={"event-type-slug-" + type.id}>
{`/${group.profile.slug}/${type.slug}`}
</small>
) : (
<></>
)}
) : null}
{readOnly && (
<span className="inline items-center rounded-sm bg-gray-100 px-1.5 py-0.5 text-xs font-medium text-gray-800 ltr:ml-2 ltr:mr-2 rtl:ml-2">
<span className="items-center rounded-sm bg-gray-100 px-1.5 py-0.5 text-xs font-medium text-gray-800 ltr:ml-2 ltr:mr-2 rtl:ml-2">
{t("readonly")}
</span>
)}
Expand Down Expand Up @@ -695,14 +691,4 @@ const EventTypesPage = () => {
);
};

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);

return {
props: {
trpcState: ssr.dehydrate(),
},
};
};

export default EventTypesPage;
14 changes: 0 additions & 14 deletions apps/web/pages/settings/admin/apps/[category].tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import type { GetServerSidePropsContext } from "next";

import AdminAppsList from "@calcom/features/apps/AdminAppsList";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Meta } from "@calcom/ui";

import { getLayout } from "@components/auth/layouts/AdminLayout";

import { ssrInit } from "@server/lib/ssr";

function AdminAppsView() {
const { t } = useLocale();
return (
Expand All @@ -20,14 +16,4 @@ function AdminAppsView() {

AdminAppsView.getLayout = getLayout;

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);

return {
props: {
trpcState: ssr.dehydrate(),
},
};
};

export default AdminAppsView;
1 change: 0 additions & 1 deletion apps/web/pages/settings/admin/apps/index.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { getServerSideProps } from "./[category]";
export { default } from "./[category]";
13 changes: 0 additions & 13 deletions apps/web/pages/settings/admin/impersonation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { GetServerSidePropsContext } from "next";
import { signIn } from "next-auth/react";
import { useRef } from "react";

Expand All @@ -7,8 +6,6 @@ import { Button, Meta, TextField } from "@calcom/ui";

import { getLayout } from "@components/auth/layouts/AdminLayout";

import { ssrInit } from "@server/lib/ssr";

function AdminView() {
const { t } = useLocale();
const usernameRef = useRef<HTMLInputElement>(null);
Expand Down Expand Up @@ -41,14 +38,4 @@ function AdminView() {

AdminView.getLayout = getLayout;

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);

return {
props: {
trpcState: ssr.dehydrate(),
},
};
};

export default AdminView;
14 changes: 0 additions & 14 deletions apps/web/pages/settings/admin/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import type { GetServerSidePropsContext } from "next";

import { Meta } from "@calcom/ui";

import { getLayout } from "@components/auth/layouts/AdminLayout";

import { ssrInit } from "@server/lib/ssr";

function AdminAppsView() {
return (
<>
Expand All @@ -17,14 +13,4 @@ function AdminAppsView() {

AdminAppsView.getLayout = getLayout;

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);

return {
props: {
trpcState: ssr.dehydrate(),
},
};
};

export default AdminAppsView;
13 changes: 0 additions & 13 deletions apps/web/pages/settings/billing/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { GetServerSidePropsContext } from "next";
import { useRouter } from "next/router";
import { useState } from "react";
import { HelpScout, useChat } from "react-live-chat-loader";
Expand All @@ -10,8 +9,6 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Button, Meta } from "@calcom/ui";
import { FiExternalLink } from "@calcom/ui/components/icon";

import { ssrInit } from "@server/lib/ssr";

interface CtaRowProps {
title: string;
description: string;
Expand Down Expand Up @@ -72,14 +69,4 @@ const BillingView = () => {

BillingView.getLayout = getLayout;

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);

return {
props: {
trpcState: ssr.dehydrate(),
},
};
};

export default BillingView;
13 changes: 0 additions & 13 deletions apps/web/pages/settings/developer/api-keys.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { GetServerSidePropsContext } from "next";
import { useState } from "react";

import type { TApiKeys } from "@calcom/ee/api-keys/components/ApiKeyListItem";
Expand All @@ -19,8 +18,6 @@ import {
} from "@calcom/ui";
import { FiLink, FiPlus } from "@calcom/ui/components/icon";

import { ssrInit } from "@server/lib/ssr";

const ApiKeysView = () => {
const { t } = useLocale();

Expand Down Expand Up @@ -96,14 +93,4 @@ const ApiKeysView = () => {

ApiKeysView.getLayout = getLayout;

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);

return {
props: {
trpcState: ssr.dehydrate(),
},
};
};

export default ApiKeysView;
13 changes: 0 additions & 13 deletions apps/web/pages/settings/my-account/appearance.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { GetServerSidePropsContext } from "next";
import { Controller, useForm } from "react-hook-form";

import ThemeLabel from "@calcom/features/settings/ThemeLabel";
Expand All @@ -20,8 +19,6 @@ import {
UpgradeTeamsBadge,
} from "@calcom/ui";

import { ssrInit } from "@server/lib/ssr";

const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
return (
<SkeletonContainer>
Expand Down Expand Up @@ -215,14 +212,4 @@ const AppearanceView = () => {

AppearanceView.getLayout = getLayout;

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);

return {
props: {
trpcState: ssr.dehydrate(),
},
};
};

export default AppearanceView;
13 changes: 0 additions & 13 deletions apps/web/pages/settings/my-account/calendars.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { GetServerSidePropsContext } from "next";
import { Trans } from "next-i18next";
import Link from "next/link";
import { useRouter } from "next/router";
Expand Down Expand Up @@ -30,8 +29,6 @@ import { QueryCell } from "@lib/QueryCell";

import { CalendarSwitch } from "@components/settings/CalendarSwitch";

import { ssrInit } from "@server/lib/ssr";

const SkeletonLoader = () => {
return (
<SkeletonContainer>
Expand Down Expand Up @@ -228,14 +225,4 @@ const CalendarsView = () => {

CalendarsView.getLayout = getLayout;

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);

return {
props: {
trpcState: ssr.dehydrate(),
},
};
};

export default CalendarsView;
13 changes: 0 additions & 13 deletions apps/web/pages/settings/my-account/general.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { GetServerSidePropsContext } from "next";
import { useRouter } from "next/router";
import { useMemo } from "react";
import { Controller, useForm } from "react-hook-form";
Expand All @@ -23,8 +22,6 @@ import {

import { withQuery } from "@lib/QueryCell";

import { ssrInit } from "@server/lib/ssr";

const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
return (
<SkeletonContainer>
Expand Down Expand Up @@ -223,14 +220,4 @@ const GeneralView = ({ localeProp, user }: GeneralViewProps) => {

GeneralQueryView.getLayout = getLayout;

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);

return {
props: {
trpcState: ssr.dehydrate(),
},
};
};

export default GeneralQueryView;
13 changes: 0 additions & 13 deletions apps/web/pages/settings/my-account/profile.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { IdentityProvider } from "@prisma/client";
import crypto from "crypto";
import MarkdownIt from "markdown-it";
import type { GetServerSidePropsContext } from "next";
import { signOut } from "next-auth/react";
import type { BaseSyntheticEvent } from "react";
import { useRef, useState } from "react";
Expand Down Expand Up @@ -42,8 +41,6 @@ import { FiAlertTriangle, FiTrash2 } from "@calcom/ui/components/icon";
import TwoFactor from "@components/auth/TwoFactor";
import { UsernameAvailabilityField } from "@components/ui/UsernameAvailability";

import { ssrInit } from "@server/lib/ssr";

const md = new MarkdownIt("default", { html: true, breaks: true });

const SkeletonLoader = ({ title, description }: { title: string; description: string }) => {
Expand Down Expand Up @@ -385,14 +382,4 @@ const ProfileForm = ({

ProfileView.getLayout = getLayout;

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);

return {
props: {
trpcState: ssr.dehydrate(),
},
};
};

export default ProfileView;
13 changes: 0 additions & 13 deletions apps/web/pages/settings/security/password.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IdentityProvider } from "@prisma/client";
import type { GetServerSidePropsContext } from "next";
import { signOut, useSession } from "next-auth/react";
import { useForm } from "react-hook-form";

Expand All @@ -10,8 +9,6 @@ import { userMetadata } from "@calcom/prisma/zod-utils";
import { trpc } from "@calcom/trpc/react";
import { Alert, Button, Form, Meta, PasswordField, Select, SettingsToggle, showToast } from "@calcom/ui";

import { ssrInit } from "@server/lib/ssr";

type ChangePasswordSessionFormValues = {
oldPassword: string;
newPassword: string;
Expand Down Expand Up @@ -209,14 +206,4 @@ const PasswordView = () => {

PasswordView.getLayout = getLayout;

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);

return {
props: {
trpcState: ssr.dehydrate(),
},
};
};

export default PasswordView;
14 changes: 0 additions & 14 deletions apps/web/pages/settings/security/sso.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
import type { GetServerSidePropsContext } from "next";

import { ssrInit } from "@server/lib/ssr";

export { default } from "@calcom/features/ee/sso/page/user-sso-view";

export const getServerSideProps = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);

return {
props: {
trpcState: ssr.dehydrate(),
},
};
};
Loading

0 comments on commit 5811e6e

Please sign in to comment.