Reusable Upgrade component for teams only features (#6473)
Co-authored-by: CarinaWolli <[email protected]>
This commit is contained in:
1 parent
443329b99f
commit
1376f0991f
8 files changed
+80
-72
No files matched your search
@@ -7,7 +7,14 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { RecordingItemSchema } from "@calcom/prisma/zod-utils";
|
||||
import { RouterOutputs, trpc } from "@calcom/trpc/react";
|
||||
import type { PartialReference } from "@calcom/types/EventManager";
|
||||
import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader } from "@calcom/ui";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
UpgradeTeamsBadge,
|
||||
} from "@calcom/ui";
|
||||
import { Button, showToast, Icon } from "@calcom/ui";
|
||||
|
||||
import RecordingListSkeleton from "./components/RecordingListSkeleton";
|
||||
@@ -58,9 +65,7 @@ export const ViewRecordingsDialog = (props: IViewRecordingsDialog) => {
|
||||
const { t, i18n } = useLocale();
|
||||
const { isOpenDialog, setIsOpenDialog, booking, timeFormat } = props;
|
||||
const [downloadingRecordingId, setRecordingId] = useState<string | null>(null);
|
||||
const session = useSession();
|
||||
const belongsToActiveTeam = session?.data?.user?.belongsToActiveTeam ?? false;
|
||||
const [showUpgradeBanner, setShowUpgradeBanner] = useState<boolean>(false);
|
||||
const { data: dataHasTeamPlan, isLoading: isLoadingHasTeamPlan } = trpc.viewer.teams.hasTeamPlan.useQuery();
|
||||
const roomName =
|
||||
booking?.references?.find((reference: PartialReference) => reference.type === "daily_video")?.meetingId ??
|
||||
undefined;
|
||||
@@ -103,57 +108,48 @@ export const ViewRecordingsDialog = (props: IViewRecordingsDialog) => {
|
||||
<DialogContent>
|
||||
<DialogHeader title={t("recordings_title")} subtitle={subtitle} />
|
||||
<LicenseRequired>
|
||||
{showUpgradeBanner && <UpgradeRecordingBanner />}
|
||||
{!showUpgradeBanner && (
|
||||
<>
|
||||
{isLoading && <RecordingListSkeleton />}
|
||||
{recordings && "data" in recordings && recordings?.data?.length > 0 && (
|
||||
<div className="flex flex-col gap-3">
|
||||
{recordings.data.map((recording: RecordingItemSchema, index: number) => {
|
||||
return (
|
||||
<div
|
||||
className="flex w-full items-center justify-between rounded-md border py-2 px-4"
|
||||
key={recording.id}>
|
||||
<div className="flex flex-col">
|
||||
<h1 className="text-sm font-semibold">
|
||||
{t("recording")} {index + 1}
|
||||
</h1>
|
||||
<p className="text-sm font-normal text-gray-500">
|
||||
{convertSecondsToMs(recording.duration)}
|
||||
</p>
|
||||
</div>
|
||||
{belongsToActiveTeam ? (
|
||||
<Button
|
||||
StartIcon={Icon.FiDownload}
|
||||
className="ml-4 lg:ml-0"
|
||||
loading={downloadingRecordingId === recording.id}
|
||||
onClick={() => handleDownloadClick(recording.id)}>
|
||||
{t("download")}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
color="secondary"
|
||||
tooltip={t("recordings_are_part_of_the_teams_plan")}
|
||||
className="ml-4 lg:ml-0"
|
||||
onClick={() => setShowUpgradeBanner(true)}>
|
||||
{t("upgrade")}
|
||||
</Button>
|
||||
)}
|
||||
<>
|
||||
{isLoading && isLoadingHasTeamPlan && <RecordingListSkeleton />}
|
||||
{recordings && "data" in recordings && recordings?.data?.length > 0 && (
|
||||
<div className="flex flex-col gap-3">
|
||||
{recordings.data.map((recording: RecordingItemSchema, index: number) => {
|
||||
return (
|
||||
<div
|
||||
className="flex w-full items-center justify-between rounded-md border px-4 py-2"
|
||||
key={recording.id}>
|
||||
<div className="flex flex-col">
|
||||
<h1 className="text-sm font-semibold">
|
||||
{t("recording")} {index + 1}
|
||||
</h1>
|
||||
<p className="text-sm font-normal text-gray-500">
|
||||
{convertSecondsToMs(recording.duration)}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{dataHasTeamPlan?.hasTeamPlan ? (
|
||||
<Button
|
||||
StartIcon={Icon.FiDownload}
|
||||
className="ml-4 lg:ml-0"
|
||||
loading={downloadingRecordingId === recording.id}
|
||||
onClick={() => handleDownloadClick(recording.id)}>
|
||||
{t("download")}
|
||||
</Button>
|
||||
) : (
|
||||
<UpgradeTeamsBadge />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
{!isLoading &&
|
||||
(!recordings ||
|
||||
(recordings && "total_count" in recordings && recordings?.total_count === 0)) && (
|
||||
<h1 className="font-semibold">{t("no_recordings_found")}</h1>
|
||||
)}
|
||||
{!isLoading &&
|
||||
(!recordings ||
|
||||
(recordings && "total_count" in recordings && recordings?.total_count === 0)) && (
|
||||
<h1 className="font-semibold">No Recordings Found</h1>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
</LicenseRequired>
|
||||
<DialogFooter>
|
||||
<DialogClose onClick={() => setShowUpgradeBanner(false)} className="border" />
|
||||
<DialogClose className="border" />
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
Reference in new issue
Block a user