Skip to content

Commit

Permalink
perf: move /teams route to (main-nav) route group (calcom#19037)
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj authored Jan 31, 2025
1 parent dde76ed commit 8dd05dd
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 48 deletions.
35 changes: 35 additions & 0 deletions apps/web/app/(use-page-wrapper)/(main-nav)/teams/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ShellMainAppDir } from "app/(use-page-wrapper)/(main-nav)/ShellMainAppDir";
import { withAppDirSsr } from "app/WithAppDirSsr";
import type { PageProps as ServerPageProps } from "app/_types";
import { _generateMetadata, getTranslate } from "app/_utils";
import { cookies, headers } from "next/headers";

import { buildLegacyCtx } from "@lib/buildLegacyCtx";
import { getServerSideProps } from "@lib/teams/getServerSideProps";

import type { PageProps as ClientPageProps } from "~/teams/teams-view";
import TeamsView, { TeamsCTA } from "~/teams/teams-view";

export const generateMetadata = async () =>
await _generateMetadata(
(t) => t("teams"),
(t) => t("create_manage_teams_collaborative")
);

const getData = withAppDirSsr<ClientPageProps>(getServerSideProps);

const ServerPage = async ({ params, searchParams }: ServerPageProps) => {
const context = buildLegacyCtx(headers(), cookies(), params, searchParams);
const props = await getData(context);
const t = await getTranslate();

return (
<ShellMainAppDir
CTA={<TeamsCTA />}
heading={t("teams")}
subtitle={t("create_manage_teams_collaborative")}>
<TeamsView {...props} />;
</ShellMainAppDir>
);
};
export default ServerPage;
20 changes: 0 additions & 20 deletions apps/web/app/teams/page.tsx

This file was deleted.

43 changes: 15 additions & 28 deletions apps/web/modules/teams/teams-view.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import { TeamsListing } from "@calcom/features/ee/teams/components";
import Shell from "@calcom/features/shell/Shell";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
Expand All @@ -11,36 +10,24 @@ import { Button } from "@calcom/ui";
import type { getServerSideProps } from "@lib/teams/getServerSideProps";

export type PageProps = inferSSRProps<typeof getServerSideProps>;
function Teams(props: PageProps) {

export const TeamsCTA = () => {
const { t } = useLocale();
const [user] = trpc.viewer.me.useSuspenseQuery();
return !user.organizationId || user.organization.isOrgAdmin ? (
<Button
data-testid="new-team-btn"
variant="fab"
StartIcon="plus"
type="button"
href={`${WEBAPP_URL}/settings/teams/new?returnTo=${WEBAPP_URL}/teams`}>
{t("new")}
</Button>
) : null;
};

return (
<Shell
withoutMain={false}
withoutSeo={true}
heading={t("teams")}
subtitle={t("create_manage_teams_collaborative")}
title={t("teams")}
description={t("create_manage_teams_collaborative")}
hideHeadingOnMobile
CTA={
(!user.organizationId || user.organization.isOrgAdmin) && (
<Button
data-testid="new-team-btn"
variant="fab"
StartIcon="plus"
type="button"
href={`${WEBAPP_URL}/settings/teams/new?returnTo=${WEBAPP_URL}/teams`}>
{t("new")}
</Button>
)
}>
<TeamsListing />
</Shell>
);
function Teams(props: PageProps) {
return <TeamsListing />;
}

Teams.requiresLicense = false;

export default Teams;

0 comments on commit 8dd05dd

Please sign in to comment.