fix: improved team upgrade screen to also show unpublished teams (#12492)
* improved team upgrade screen to also show unpublished teams * Update TeamsListing.tsx * bunch of stuff --------- Co-authored-by: Omar López <[email protected]>
This commit is contained in:
1 parent
33250652b3
commit
7f23ae156b
28 files changed
+207
-459
No files matched your search
@@ -75,22 +75,6 @@ export default function TeamList(props: Props) {
|
||||
child: t("invite"),
|
||||
}}
|
||||
/>
|
||||
{/* @TODO: uncomment once managed event types is live
|
||||
<Card
|
||||
icon={<Unlock className="h-5 w-5 text-blue-700" />}
|
||||
variant="basic"
|
||||
title={t("create_a_managed_event")}
|
||||
description={t("create_a_one_one_template")}
|
||||
actionButton={{
|
||||
href:
|
||||
"/event-types?dialog=new-eventtype&eventPage=team%2F" +
|
||||
team.slug +
|
||||
"&teamId=" +
|
||||
team.id +
|
||||
"&managed=true",
|
||||
child: t("create"),
|
||||
}}
|
||||
/> */}
|
||||
<Card
|
||||
icon={<Users className="h-5 w-5 text-orange-700" />}
|
||||
variant="basic"
|
||||
|
||||
@@ -13,6 +13,7 @@ import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
Button,
|
||||
ButtonGroup,
|
||||
ConfirmationDialogContent,
|
||||
@@ -104,11 +105,15 @@ export default function TeamListItem(props: Props) {
|
||||
<div className="ms-3 inline-block truncate">
|
||||
<span className="text-default text-sm font-bold">{team.name}</span>
|
||||
<span className="text-muted block text-xs">
|
||||
{team.slug
|
||||
? orgBranding
|
||||
? `${orgBranding.fullDomain}/${team.slug}`
|
||||
: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team/${team.slug}`
|
||||
: "Unpublished team"}
|
||||
{team.slug ? (
|
||||
orgBranding ? (
|
||||
`${orgBranding.fullDomain}/${team.slug}`
|
||||
) : (
|
||||
`${process.env.NEXT_PUBLIC_WEBSITE_URL}/team/${team.slug}`
|
||||
)
|
||||
) : (
|
||||
<Badge>{t("upgrade")}</Badge>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -180,13 +185,17 @@ export default function TeamListItem(props: Props) {
|
||||
)}
|
||||
<div className={classNames("flex items-center justify-between", !isInvitee && "hover:bg-muted group")}>
|
||||
{!isInvitee ? (
|
||||
<Link
|
||||
data-testid="team-list-item-link"
|
||||
href={`/settings/teams/${team.id}/profile`}
|
||||
className="flex-grow cursor-pointer truncate text-sm"
|
||||
title={`${team.name}`}>
|
||||
{teamInfo}
|
||||
</Link>
|
||||
team.slug ? (
|
||||
<Link
|
||||
data-testid="team-list-item-link"
|
||||
href={`/settings/teams/${team.id}/profile`}
|
||||
className="flex-grow cursor-pointer truncate text-sm"
|
||||
title={`${team.name}`}>
|
||||
{teamInfo}
|
||||
</Link>
|
||||
) : (
|
||||
<TeamPublishSection teamId={team.id}>{teamInfo}</TeamPublishSection>
|
||||
)
|
||||
) : (
|
||||
teamInfo
|
||||
)}
|
||||
@@ -388,3 +397,26 @@ const TeamPublishButton = ({ teamId }: { teamId: number }) => {
|
||||
</DropdownMenuItem>
|
||||
);
|
||||
};
|
||||
|
||||
const TeamPublishSection = ({ children, teamId }: { children: React.ReactNode; teamId: number }) => {
|
||||
const router = useRouter();
|
||||
const publishTeamMutation = trpc.viewer.teams.publish.useMutation({
|
||||
onSuccess(data) {
|
||||
router.push(data.url);
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(error.message, "error");
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<button
|
||||
className="block flex-grow cursor-pointer truncate text-left text-sm"
|
||||
type="button"
|
||||
onClick={() => {
|
||||
publishTeamMutation.mutate({ teamId });
|
||||
}}>
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
};
|
||||
@@ -102,7 +102,6 @@ export function TeamsListing() {
|
||||
<TeamList teams={invites} pending />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<UpgradeTip
|
||||
plan="team"
|
||||
title={t("calcom_is_better_with_team", { appName: APP_NAME })}
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { ReactNode } from "react";
|
||||
import { classNames } from "@calcom/lib";
|
||||
import { useHasTeamPlan } from "@calcom/lib/hooks/useHasPaidPlan";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc";
|
||||
|
||||
export function UpgradeTip({
|
||||
dark,
|
||||
@@ -29,10 +30,14 @@ export function UpgradeTip({
|
||||
}) {
|
||||
const { t } = useLocale();
|
||||
const { isLoading, hasTeamPlan } = useHasTeamPlan();
|
||||
const { data } = trpc.viewer.teams.getUpgradeable.useQuery();
|
||||
|
||||
const hasEnterprisePlan = false;
|
||||
//const { isLoading , hasEnterprisePlan } = useHasEnterprisePlan();
|
||||
|
||||
if (plan === "team" && hasTeamPlan) return children;
|
||||
const hasUnpublishedTeam = !!data?.[0];
|
||||
|
||||
if (plan === "team" && (hasTeamPlan || hasUnpublishedTeam)) return children;
|
||||
|
||||
if (plan === "enterprise" && hasEnterprisePlan) return children;
|
||||
|
||||
@@ -44,7 +49,7 @@ export function UpgradeTip({
|
||||
<picture className="absolute min-h-[295px] w-full rounded-lg object-cover">
|
||||
<source srcSet={`${background}-dark.jpg`} media="(prefers-color-scheme: dark)" />
|
||||
<img
|
||||
className="absolute min-h-[295px] w-full rounded-lg object-cover object-left md:object-center select-none"
|
||||
className="absolute min-h-[295px] w-full select-none rounded-lg object-cover object-left md:object-center"
|
||||
src={`${background}.jpg`}
|
||||
loading="lazy"
|
||||
alt={title}
|
||||
|
||||
Reference in new issue
Block a user