generic <UpgradeScreen> component (#6594)
* first attempt of <UpgradeScreen> * changes to icons * reverted changes back to initial state, needs fix: teams not showing * WIP * Fix weird reactnode error * Fix loading text * added upgradeTip to routing forms * icon colors * create and use hook to check if user has team plan * use useTeamPlan for upgradeTeamsBadge * replace huge svg with compressed jpeg * responsive fixes * Update packages/ui/components/badge/UpgradeTeamsBadge.tsx Co-authored-by: sean-brydon <[email protected]> * Give team plan features to E2E tests * Allow option to make a user part of team int ests * Remove flash of paywall for team user * Add team user for typeform tests as well Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: Carina Wollendorfer <[email protected]> Co-authored-by: Alex van Andel <[email protected]> Co-authored-by: Hariom Balhara <[email protected]>
This commit is contained in:
13 files changed
+379
-204
No files matched your search
@@ -3,10 +3,10 @@ import { useState } from "react";
|
||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import isCalcom from "@calcom/lib/isCalcom";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Alert, Button, ButtonGroup, EmptyScreen, Icon } from "@calcom/ui";
|
||||
import { Alert, Button, ButtonGroup, Icon } from "@calcom/ui";
|
||||
|
||||
import { UpgradeTip } from "../../../tips";
|
||||
import SkeletonLoaderTeamList from "./SkeletonloaderTeamList";
|
||||
import TeamList from "./TeamList";
|
||||
|
||||
@@ -21,36 +21,35 @@ export function TeamsListing() {
|
||||
});
|
||||
|
||||
const teams = data?.filter((m) => m.accepted) || [];
|
||||
const invites = data?.filter((m) => !m.accepted) || [];
|
||||
|
||||
const features = [
|
||||
{
|
||||
icon: <Icon.FiUsers className="h-5 w-5 text-gray-700" />,
|
||||
icon: <Icon.FiUsers className="h-5 w-5 text-red-500" />,
|
||||
title: t("collective_scheduling"),
|
||||
description: t("make_it_easy_to_book"),
|
||||
},
|
||||
{
|
||||
icon: <Icon.FiRefreshCcw className="h-5 w-5 text-gray-700" />,
|
||||
icon: <Icon.FiRefreshCcw className="h-5 w-5 text-blue-500" />,
|
||||
title: t("round_robin"),
|
||||
description: t("find_the_best_person"),
|
||||
},
|
||||
{
|
||||
icon: <Icon.FiUserPlus className="h-5 w-5 text-gray-700" />,
|
||||
icon: <Icon.FiUserPlus className="h-5 w-5 text-green-500" />,
|
||||
title: t("fixed_round_robin"),
|
||||
description: t("add_one_fixed_attendee"),
|
||||
},
|
||||
{
|
||||
icon: <Icon.FiMail className="h-5 w-5 text-gray-700" />,
|
||||
icon: <Icon.FiMail className="h-5 w-5 text-orange-500" />,
|
||||
title: t("sms_attendee_action"),
|
||||
description: t("make_it_easy_to_book"),
|
||||
},
|
||||
{
|
||||
icon: <Icon.FiVideo className="h-5 w-5 text-gray-700" />,
|
||||
icon: <Icon.FiVideo className="h-5 w-5 text-purple-500" />,
|
||||
title: "Cal Video" + " " + t("recordings_title"),
|
||||
description: t("upgrade_to_access_recordings_description"),
|
||||
},
|
||||
{
|
||||
icon: <Icon.FiEyeOff className="h-5 w-5 text-gray-700" />,
|
||||
icon: <Icon.FiEyeOff 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 }),
|
||||
},
|
||||
@@ -59,66 +58,26 @@ export function TeamsListing() {
|
||||
return (
|
||||
<>
|
||||
{!!errorMessage && <Alert severity="error" title={errorMessage} />}
|
||||
{invites.length > 0 && (
|
||||
<div className="mb-4">
|
||||
<h1 className="mb-2 text-lg font-medium">{t("open_invitations")}</h1>
|
||||
<TeamList teams={invites} />
|
||||
</div>
|
||||
)}
|
||||
{isLoading && <SkeletonLoaderTeamList />}
|
||||
{!teams.length && !isLoading && (
|
||||
<>
|
||||
{!isCalcom ? (
|
||||
<div className="-mt-6 rtl:ml-4 md:rtl:ml-0">
|
||||
<div
|
||||
className="flex w-full justify-between overflow-hidden rounded-lg pt-4 pb-10 md:min-h-[295px] md:pt-10"
|
||||
style={{
|
||||
background: "url(/team-banner-background.jpg)",
|
||||
backgroundSize: "cover",
|
||||
backgroundRepeat: "no-repeat",
|
||||
}}>
|
||||
<div className="mt-3 px-8 sm:px-14">
|
||||
<h1 className="font-cal text-3xl">{t("calcom_is_better_with_team")}</h1>
|
||||
<p className="my-4 max-w-sm text-gray-600">{t("add_your_team_members")}</p>
|
||||
<div className="space-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="secondary" href="https://go.cal.com/teams-video" target="_blank">
|
||||
{t("learn_more")}
|
||||
</Button>
|
||||
</ButtonGroup>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 grid-cols-3 md:grid md:gap-4">
|
||||
{features.map((feature) => (
|
||||
<div
|
||||
key={feature.title}
|
||||
className="mb-4 min-h-[180px] w-full rounded-md bg-gray-50 p-8 md:mb-0">
|
||||
{feature.icon}
|
||||
<h2 className="font-cal mt-4 text-lg">{feature.title}</h2>
|
||||
<p className="text-gray-700">{feature.description}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<EmptyScreen
|
||||
Icon={Icon.FiUsers}
|
||||
headline={t("no_teams")}
|
||||
description={t("no_teams_description")}
|
||||
buttonRaw={
|
||||
<Button color="secondary" href={`${WEBAPP_URL}/settings/teams/new`}>
|
||||
{t("create_team")}
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{teams.length > 0 && <TeamList teams={teams} />}
|
||||
<UpgradeTip
|
||||
title="calcom_is_better_with_team"
|
||||
description="add_your_team_members"
|
||||
features={features}
|
||||
background="/team-banner-background.jpg"
|
||||
isParentLoading={isLoading && <SkeletonLoaderTeamList />}
|
||||
buttons={
|
||||
<div className="space-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="secondary" href="https://go.cal.com/teams-video" target="_blank">
|
||||
{t("learn_more")}
|
||||
</Button>
|
||||
</ButtonGroup>
|
||||
</div>
|
||||
}>
|
||||
<TeamList teams={teams} />
|
||||
</UpgradeTip>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useState } from "react";
|
||||
|
||||
import dayjs from "@calcom/dayjs";
|
||||
import LicenseRequired from "@calcom/features/ee/common/components/v2/LicenseRequired";
|
||||
import useHasTeamPlan from "@calcom/lib/hooks/useHasTeamPlan";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { RecordingItemSchema } from "@calcom/prisma/zod-utils";
|
||||
import { RouterOutputs, trpc } from "@calcom/trpc/react";
|
||||
@@ -18,7 +18,6 @@ import {
|
||||
import { Button, showToast, Icon } from "@calcom/ui";
|
||||
|
||||
import RecordingListSkeleton from "./components/RecordingListSkeleton";
|
||||
import UpgradeRecordingBanner from "./components/UpgradeRecordingBanner";
|
||||
|
||||
type BookingItem = RouterOutputs["viewer"]["bookings"]["get"]["bookings"][number];
|
||||
|
||||
@@ -65,7 +64,9 @@ export const ViewRecordingsDialog = (props: IViewRecordingsDialog) => {
|
||||
const { t, i18n } = useLocale();
|
||||
const { isOpenDialog, setIsOpenDialog, booking, timeFormat } = props;
|
||||
const [downloadingRecordingId, setRecordingId] = useState<string | null>(null);
|
||||
const { data: dataHasTeamPlan, isLoading: isLoadingHasTeamPlan } = trpc.viewer.teams.hasTeamPlan.useQuery();
|
||||
|
||||
const { hasTeamPlan, isLoading: isTeamPlanStatusLoading } = useHasTeamPlan();
|
||||
|
||||
const roomName =
|
||||
booking?.references?.find((reference: PartialReference) => reference.type === "daily_video")?.meetingId ??
|
||||
undefined;
|
||||
@@ -109,7 +110,7 @@ export const ViewRecordingsDialog = (props: IViewRecordingsDialog) => {
|
||||
<DialogHeader title={t("recordings_title")} subtitle={subtitle} />
|
||||
<LicenseRequired>
|
||||
<>
|
||||
{(isLoading || isLoadingHasTeamPlan) && <RecordingListSkeleton />}
|
||||
{(isLoading || isTeamPlanStatusLoading) && <RecordingListSkeleton />}
|
||||
{recordings && "data" in recordings && recordings?.data?.length > 0 && (
|
||||
<div className="flex flex-col gap-3">
|
||||
{recordings.data.map((recording: RecordingItemSchema, index: number) => {
|
||||
@@ -125,7 +126,7 @@ export const ViewRecordingsDialog = (props: IViewRecordingsDialog) => {
|
||||
{convertSecondsToMs(recording.duration)}
|
||||
</p>
|
||||
</div>
|
||||
{dataHasTeamPlan?.hasTeamPlan ? (
|
||||
{hasTeamPlan ? (
|
||||
<Button
|
||||
StartIcon={Icon.FiDownload}
|
||||
className="ml-4 lg:ml-0"
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import { useMemo } from "react";
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import { classNames } from "@calcom/lib";
|
||||
import { useHasTeamPlan } from "@calcom/lib/hooks/useHasTeamPlan";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
// import isCalcom from "@calcom/lib/isCalcom";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { EmptyScreen, Icon } from "@calcom/ui";
|
||||
|
||||
import TeamList from "../ee/teams/components/TeamList";
|
||||
|
||||
const isCalcom = true;
|
||||
export function UpgradeTip({
|
||||
dark,
|
||||
title,
|
||||
description,
|
||||
background,
|
||||
features,
|
||||
buttons,
|
||||
isParentLoading,
|
||||
children,
|
||||
}: {
|
||||
dark?: boolean;
|
||||
title: string;
|
||||
description: string;
|
||||
background: string;
|
||||
features: Array<{ icon: JSX.Element; title: string; description: string }>;
|
||||
buttons?: JSX.Element;
|
||||
/**Chldren renders when the user is in a team */
|
||||
children: JSX.Element;
|
||||
isParentLoading?: ReactNode;
|
||||
}) {
|
||||
const { data } = trpc.viewer.teams.list.useQuery();
|
||||
|
||||
const invites = useMemo(() => data?.filter((m) => !m.accepted) || [], [data]);
|
||||
const { t } = useLocale();
|
||||
const { isLoading, hasTeamPlan } = useHasTeamPlan();
|
||||
|
||||
if (hasTeamPlan) return children;
|
||||
|
||||
if (!isCalcom)
|
||||
return <EmptyScreen Icon={Icon.FiUsers} headline={title} description={description} buttonRaw={buttons} />;
|
||||
|
||||
if (isParentLoading || isLoading) return <>{isParentLoading}</>;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="-mt-10 rtl:ml-4 sm:mt-0 md:rtl:ml-0 lg:-mt-6">
|
||||
<div
|
||||
className="flex w-full justify-between overflow-hidden rounded-lg pt-4 pb-10 md:min-h-[295px] md:pt-10"
|
||||
style={{
|
||||
background: `url(${background})`,
|
||||
backgroundSize: "cover",
|
||||
backgroundRepeat: "no-repeat",
|
||||
}}>
|
||||
<div className="mt-3 px-8 sm:px-14">
|
||||
<h1 className={classNames("font-cal text-3xl", dark && "text-white")}>{t(title)}</h1>
|
||||
<p className={classNames("my-4 max-w-sm", dark ? "text-white" : "text-gray-600")}>
|
||||
{t(description)}
|
||||
</p>
|
||||
{buttons}
|
||||
</div>
|
||||
</div>
|
||||
{invites.length > 0 && (
|
||||
<div className="my-4">
|
||||
<h3 className="font-cal mb-4 text-xl">{t("open_invitations")}</h3>
|
||||
<TeamList teams={invites} />
|
||||
</div>
|
||||
)}
|
||||
<div className="mt-4 grid-cols-3 md:grid md:gap-4">
|
||||
{invites.length === 0 &&
|
||||
features.map((feature) => (
|
||||
<div
|
||||
key={feature.title}
|
||||
className="mb-4 min-h-[180px] w-full rounded-md bg-gray-50 p-8 md:mb-0">
|
||||
{feature.icon}
|
||||
<h2 className="font-cal mt-4 text-lg">{feature.title}</h2>
|
||||
<p className="text-gray-700">{feature.description}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export { default as Tips } from "./Tips";
|
||||
export { UpgradeTip } from "./UpgradeTip";
|
||||
Reference in new issue
Block a user