feat: add upgrade banners for teams and organizations (#27650)

This commit is contained in:
Eunjae Lee authored and GitHub committed 2026-03-05 18:19:01 +09:00
1 parent c197de147a
commit b7340f7151
74 files changed
+1834 -500

No files matched your search

@@ -1,56 +1,36 @@
"use client";
import { keepPreviousData } from "@tanstack/react-query";
import {
getCoreRowModel,
getFilteredRowModel,
getSortedRowModel,
useReactTable,
type ColumnDef,
} from "@tanstack/react-table";
import classNames from "classnames";
import { useSession } from "next-auth/react";
import { signIn } from "next-auth/react";
import { usePathname } from "next/navigation";
import { useQueryState, parseAsBoolean } from "nuqs";
import posthog from "posthog-js";
import { useMemo, useReducer, useRef, useState } from "react";
import type { Dispatch, SetStateAction } from "react";
import process from "node:process";
import { Dialog } from "@calcom/features/components/controlled-dialog";
import { convertFacetedValuesToMap } from "@calcom/features/data-table";
import { DataTableProvider } from "~/data-table/DataTableProvider";
import { useDataTable } from "~/data-table/hooks/useDataTable";
import { useFetchMoreOnBottomReached } from "~/data-table/hooks/useFetchMoreOnBottomReached";
import { useColumnFilters } from "~/data-table/hooks/useColumnFilters";
import {
DataTableToolbar,
DataTableFilters,
DataTableWrapper,
DataTableSelectionBar,
} from "~/data-table/components";
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
import type { MemberPermissions } from "@calcom/features/pbac/lib/team-member-permissions";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
import { useFillRemainingHeight } from "@calcom/lib/hooks/useFillRemainingHeight";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import type { RouterOutputs } from "@calcom/trpc/react";
import { trpc } from "@calcom/trpc/react";
import { Avatar } from "@calcom/ui/components/avatar";
import { Badge } from "@calcom/ui/components/badge";
import { Button } from "@calcom/ui/components/button";
import { ButtonGroup } from "@calcom/ui/components/buttonGroup";
import {
ConfirmationDialogContent,
DialogClose,
DialogContent,
DialogFooter,
DialogClose,
ConfirmationDialogContent,
} from "@calcom/ui/components/dialog";
import {
Dropdown,
DropdownItem,
DropdownMenuPortal,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuPortal,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@calcom/ui/components/dropdown";
@@ -59,8 +39,27 @@ import { showToast } from "@calcom/ui/components/toast";
import { Tooltip } from "@calcom/ui/components/tooltip";
import TeamAvailabilityModal from "@calcom/web/modules/ee/teams/components/TeamAvailabilityModal";
import { DynamicLink } from "@calcom/web/modules/users/components/UserTable/BulkActions/DynamicLink";
import type { MemberPermissions } from "@calcom/features/pbac/lib/team-member-permissions";
import { keepPreviousData } from "@tanstack/react-query";
import {
type ColumnDef,
getCoreRowModel,
getFilteredRowModel,
getSortedRowModel,
useReactTable,
} from "@tanstack/react-table";
import classNames from "classnames";
import { usePathname } from "next/navigation";
import { signIn, useSession } from "next-auth/react";
import { parseAsBoolean, useQueryState } from "nuqs";
import posthog from "posthog-js";
import type { Dispatch, SetStateAction } from "react";
import { useMemo, useReducer, useRef, useState } from "react";
import {
DataTableFilters,
DataTableSelectionBar,
DataTableToolbar,
DataTableWrapper,
} from "~/data-table/components";
import DeleteBulkTeamMembers from "./DeleteBulkTeamMembers";
import { EditMemberSheet } from "./EditMemberSheet";
import { EventTypesList } from "./EventTypesList";
@@ -690,13 +689,6 @@ function MemberListContent(props: Props) {
getRowId: (row) => `${row.id}`,
});
useFetchMoreOnBottomReached({
tableContainerRef,
hasNextPage,
fetchNextPage,
isFetching,
});
const numberOfSelectedRows = table.getSelectedRowModel().rows.length;
return (
@@ -85,7 +85,7 @@ export default function TeamList(props: Props) {
: t("consider_consolidating_multi_team_org")
}
actionButton={{
href: `/settings/organizations/new`,
href: `/onboarding/organization/details?migrate=true`,
child: t("set_up_your_organization"),
"data-testid": "setup_your_org_action_button",
}}
@@ -1,29 +1,18 @@
"use client";
import { useRouter, useSearchParams } from "next/navigation";
import { useEffect, useMemo } from "react";
import { APP_NAME, WEBAPP_URL } from "@calcom/lib/constants";
import { WEBAPP_URL } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { RouterOutputs } from "@calcom/trpc/react";
import { Button } from "@calcom/ui/components/button";
import { ButtonGroup } from "@calcom/ui/components/buttonGroup";
import { EmptyScreen } from "@calcom/ui/components/empty-screen";
import { Label } from "@calcom/ui/components/form";
import {
EyeOffIcon,
InfoIcon,
MailIcon,
RefreshCcwIcon,
UserPlusIcon,
UsersIcon,
VideoIcon,
} from "@coss/ui/icons";
import { InfoIcon } from "@coss/ui/icons";
import { showToast } from "@calcom/ui/components/toast";
import { useHasTeamPlan } from "@calcom/web/modules/billing/hooks/useHasPaidPlan";
import { FullscreenUpgradeBannerForTeamsPage } from "@calcom/web/modules/billing/upgrade-banners/FullscreenUpgradeBannerForTeamsPage";
import { useRouter, useSearchParams } from "next/navigation";
import { useEffect, useMemo } from "react";
import SkeletonLoaderTeamList from "~/ee/teams/components/SkeletonloaderTeamList";
import { UpgradeTip } from "~/shell/UpgradeTip";
import TeamList from "./TeamList";
type TeamsListingProps = {
@@ -66,38 +55,7 @@ export function TeamsListing({
const isCreateTeamButtonDisabled = !!(orgId && !permissions.canCreateTeam);
const features = [
{
icon: <UsersIcon className="h-5 w-5 text-red-500" />,
title: t("collective_scheduling"),
description: t("make_it_easy_to_book"),
},
{
icon: <RefreshCcwIcon className="h-5 w-5 text-blue-500" />,
title: t("round_robin"),
description: t("find_the_best_person"),
},
{
icon: <UserPlusIcon className="h-5 w-5 text-green-500" />,
title: t("fixed_round_robin"),
description: t("add_one_fixed_attendee"),
},
{
icon: <MailIcon className="h-5 w-5 text-orange-500" />,
title: t("sms_attendee_action"),
description: t("send_reminder_sms"),
},
{
icon: <VideoIcon className="h-5 w-5 text-purple-500" />,
title: `Cal Video ${t("recordings_title")}`,
description: t("upgrade_to_access_recordings_description"),
},
{
icon: <EyeOffIcon className="h-5 w-5 text-indigo-500" />,
title: t("disable_cal_branding", { appName: APP_NAME }),
description: t("disable_cal_branding_description", { appName: APP_NAME }),
},
];
const { isPending: isPendingTeamPlan } = useHasTeamPlan();
useEffect(() => {
if (!token) {
@@ -118,73 +76,36 @@ export function TeamsListing({
showToast(t("team_invite_received", { teamName: teamNameFromInvite }), "success");
return;
}
}, []);
}, [errorMsgFromInvite, invitationAccepted, t, teamNameFromInvite, token]);
return (
<>
{organizationInvites.length > 0 && (
<div className="bg-subtle mb-6 rounded-md p-5">
<Label className="text-emphasis pb-2 font-semibold">{t("pending_organization_invites")}</Label>
<div className="mb-6 rounded-md bg-subtle p-5">
<Label className="pb-2 font-semibold text-emphasis">{t("pending_organization_invites")}</Label>
<TeamList orgId={orgId} teams={organizationInvites} pending />
</div>
)}
{teamInvites.length > 0 && (
<div className="bg-subtle mb-6 rounded-md p-5">
<Label className="text-emphasis pb-2 font-semibold">{t("pending_invites")}</Label>
<div className="mb-6 rounded-md bg-subtle p-5">
<Label className="pb-2 font-semibold text-emphasis">{t("pending_invites")}</Label>
<TeamList orgId={orgId} teams={teamInvites} pending />
</div>
)}
{teams.length > 0 && <TeamList orgId={orgId} teams={teams} />}
{teams.length === 0 && (
<UpgradeTip
plan="team"
title={t("calcom_is_better_with_team", { appName: APP_NAME })}
description={t("add_your_team_members")}
features={features}
background="/tips/teams"
buttons={
!orgId || permissions.canCreateTeam ? (
<div className="stack-y-2 rtl:space-x-reverse sm:space-x-2">
<ButtonGroup>
<Button color="primary" href={`${WEBAPP_URL}/settings/teams/new`}>
{t("create_team")}
</Button>
<Button color="minimal" href="https://cal.com/teams" target="_blank">
{t("learn_more")}
</Button>
</ButtonGroup>
</div>
) : (
<p>{t("org_admins_can_create_new_teams")}</p>
)
}
isParentLoading={<SkeletonLoaderTeamList />}>
<EmptyScreen
Icon="users"
headline={t("create_team_to_get_started")}
description={t("create_first_team_and_invite_others")}
buttonRaw={
<Button
color="secondary"
data-testid="create-team-btn"
disabled={!!isCreateTeamButtonDisabled}
tooltip={
isCreateTeamButtonDisabled ? t("org_admins_can_create_new_teams") : t("create_new_team")
}
onClick={() => router.push(`${WEBAPP_URL}/settings/teams/new?returnTo=${WEBAPP_URL}/teams`)}>
{t(`create_new_team`)}
</Button>
}
/>
</UpgradeTip>
)}
{teams.length === 0 && isPendingTeamPlan && <SkeletonLoaderTeamList />}
<p className="text-subtle mb-8 mt-4 flex w-full items-center gap-1 text-sm md:justify-center md:text-center">
<InfoIcon className="hidden sm:block" /> {t("tip_username_plus")}
</p>
{teams.length === 0 && !isPendingTeamPlan && <FullscreenUpgradeBannerForTeamsPage />}
{/* Only show tip when not showing the upgrade banner */}
{teams.length > 0 && (
<p className="mt-4 mb-8 flex w-full items-center gap-1 text-sm text-subtle md:justify-center md:text-center">
<InfoIcon className="hidden sm:block" /> {t("tip_username_plus")}
</p>
)}
</>
);
}