Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed SSR trpc calls instead SPA for logged in pages #6936

Merged
merged 17 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(),
},
};
};
46 changes: 4 additions & 42 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 Down Expand Up @@ -128,17 +125,11 @@ const Item = ({ type, group, readOnly }: { type: EventType; group: EventTypeGrou
data-testid={"event-type-title-" + type.id}>
{type.title}
</span>
{group.profile.slug ? (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not from me :o

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before we merge can we undo this? i dont know where this came from @zomars @roae

<small
className="hidden font-normal leading-4 text-gray-600 sm:inline"
data-testid={"event-type-slug-" + type.id}>
{`/${group.profile.slug}/${type.slug}`}
</small>
) : (
<></>
)}
<small
className="hidden font-normal leading-4 text-gray-600 sm:inline"
data-testid={"event-type-slug-" + type.id}>{`/${group.profile.slug}/${type.slug}`}</small>
{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="rtl:ml-2inline 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">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here. also typo

Suggested change
<span className="rtl:ml-2inline 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">
<span className="rtl:ml-2 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">

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the span tag is already inline, it is redundant

{t("readonly")}
</span>
)}
Expand Down Expand Up @@ -564,18 +555,6 @@ const EventTypeListHeading = ({
membershipCount,
teamId,
}: EventTypeListHeadingProps): JSX.Element => {
const { t } = useLocale();
const router = useRouter();

const publishTeamMutation = trpc.viewer.teams.publish.useMutation({
onSuccess(data) {
router.push(data.url);
},
onError: (error) => {
showToast(error.message, "error");
},
});

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also not by me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return (
<div className="mb-4 flex items-center space-x-2">
<Avatar
Expand Down Expand Up @@ -607,13 +586,6 @@ const EventTypeListHeading = ({
</Link>
)}
</div>
{!profile?.slug && !!teamId && (
<button onClick={() => publishTeamMutation.mutate({ teamId })}>
<Badge variant="gray" className="mb-1 -ml-2">
{t("upgrade")}
</Badge>
</button>
)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change intended for this PR¡

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no not from me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

</div>
);
};
Expand Down Expand Up @@ -695,14 +667,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;
Loading