feat: add upgrade banners for teams and organizations (#27650)
This commit is contained in:
1 parent
c197de147a
commit
b7340f7151
74 files changed
+1834
-500
No files matched your search
@@ -0,0 +1,318 @@
|
||||
"use client";
|
||||
|
||||
import { useFillRemainingHeight } from "@calcom/lib/hooks/useFillRemainingHeight";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import useMediaQuery from "@calcom/lib/hooks/useMediaQuery";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { OrgBadge, TeamBadge } from "@calcom/web/modules/billing/components/PlanBadge";
|
||||
import { UpgradePlanDialog } from "@calcom/web/modules/billing/components/UpgradePlanDialog";
|
||||
import { Badge } from "@coss/ui/components/badge";
|
||||
import { Button } from "@coss/ui/components/button";
|
||||
import {
|
||||
Dialog,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogPopup,
|
||||
DialogTitle,
|
||||
} from "@coss/ui/components/dialog";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import posthog from "posthog-js";
|
||||
import { useState } from "react";
|
||||
import type { UpgradeTarget } from "./types";
|
||||
|
||||
export type { UpgradeTarget };
|
||||
|
||||
export type FullScreenUpgradeBannerProps = {
|
||||
tracking: string;
|
||||
name: string;
|
||||
title: string;
|
||||
subtitle: string;
|
||||
features?: string[];
|
||||
target: UpgradeTarget;
|
||||
learnMoreButton?: {
|
||||
text: string;
|
||||
href?: string;
|
||||
onClick?: () => void;
|
||||
};
|
||||
extraOffset?:
|
||||
| number
|
||||
| {
|
||||
mobile?: number;
|
||||
tablet?: number;
|
||||
desktop?: number;
|
||||
};
|
||||
image: {
|
||||
src: string;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
youtubeId?: string;
|
||||
};
|
||||
|
||||
function useResponsiveOffset(
|
||||
extraOffset?:
|
||||
| number
|
||||
| {
|
||||
mobile?: number;
|
||||
tablet?: number;
|
||||
desktop?: number;
|
||||
}
|
||||
) {
|
||||
const isMobile = useMediaQuery("(max-width: 639px)");
|
||||
const isTablet = useMediaQuery("(max-width: 767px)");
|
||||
|
||||
if (isMobile) {
|
||||
return typeof extraOffset === "number" ? extraOffset : (extraOffset?.mobile ?? 74);
|
||||
} else if (isTablet) {
|
||||
return typeof extraOffset === "number" ? extraOffset : (extraOffset?.tablet ?? 85);
|
||||
} else {
|
||||
return typeof extraOffset === "number" ? extraOffset : (extraOffset?.desktop ?? 24);
|
||||
}
|
||||
}
|
||||
|
||||
function BannerImage({
|
||||
image,
|
||||
name,
|
||||
youtubeId,
|
||||
tracking,
|
||||
target,
|
||||
onPlayVideo,
|
||||
}: {
|
||||
image: { src: string; width: number; height: number };
|
||||
name: string;
|
||||
youtubeId?: string;
|
||||
tracking: string;
|
||||
target: UpgradeTarget;
|
||||
onPlayVideo: () => void;
|
||||
}): JSX.Element {
|
||||
const { t } = useLocale();
|
||||
return (
|
||||
<>
|
||||
<Image
|
||||
src={image.src}
|
||||
alt={name}
|
||||
width={image.width}
|
||||
height={image.height}
|
||||
className="h-full w-full object-cover object-top"
|
||||
/>
|
||||
{youtubeId && (
|
||||
<button
|
||||
type="button"
|
||||
className="absolute inset-0 flex items-center justify-center cursor-pointer"
|
||||
onClick={() => {
|
||||
posthog.capture("fullscreen_upgrade_banner_video_played", { source: tracking, target });
|
||||
onPlayVideo();
|
||||
}}>
|
||||
<Image src="/play_button.svg" alt={t("play_video")} width={48} height={48} />
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function FullScreenUpgradeBanner({
|
||||
tracking,
|
||||
name,
|
||||
title,
|
||||
subtitle,
|
||||
features,
|
||||
target,
|
||||
learnMoreButton,
|
||||
extraOffset,
|
||||
image,
|
||||
youtubeId,
|
||||
}: FullScreenUpgradeBannerProps): JSX.Element {
|
||||
const [videoOpen, setVideoOpen] = useState(false);
|
||||
const [showFeatures, setShowFeatures] = useState(false);
|
||||
const deviceSpecificOffset = useResponsiveOffset(extraOffset);
|
||||
const { t } = useLocale();
|
||||
const ref = useFillRemainingHeight(deviceSpecificOffset);
|
||||
|
||||
const bannerImageProps = {
|
||||
image,
|
||||
name,
|
||||
youtubeId,
|
||||
tracking,
|
||||
target,
|
||||
onPlayVideo: () => setVideoOpen(true),
|
||||
};
|
||||
|
||||
return (
|
||||
<div ref={ref} className="flex w-full shrink-0 items-center justify-center rounded-xl bg-subtle p-8">
|
||||
<div className="flex w-full h-full md:h-auto max-w-3xl gap-2 overflow-hidden rounded-3xl bg-default p-5 md:py-8 md:pl-8 md:pr-0 shadow-sm">
|
||||
{/* Left Content */}
|
||||
<div className="flex flex-1 flex-col justify-between overflow-hidden">
|
||||
<div className={`${showFeatures ? "overflow-y-auto" : ""} md:overflow-visible`}>
|
||||
<div>
|
||||
<Badge
|
||||
variant="outline"
|
||||
className="text-sm text-default font-medium bg-subtle px-2 py-1 h-fit! border-0">
|
||||
{name}
|
||||
</Badge>
|
||||
</div>
|
||||
<h2 className="mt-3 font-cal font-semibold text-emphasis text-xl leading-none">{title}</h2>
|
||||
<p className="mt-2 text-subtle text-sm">{subtitle}</p>
|
||||
|
||||
{/* Features List */}
|
||||
{features && (
|
||||
<>
|
||||
<ul className="mt-4 space-y-2 hidden md:block">
|
||||
{features.map((feature) => (
|
||||
<li key={feature} className="flex items-center gap-2 text-sm text-subtle">
|
||||
<span className="text-subtle">•</span>
|
||||
{feature}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<div className="md:hidden mt-4">
|
||||
{showFeatures ? (
|
||||
<>
|
||||
<ul className="space-y-2">
|
||||
{features.map((feature) => (
|
||||
<li key={feature} className="flex items-center gap-2 text-sm text-subtle">
|
||||
<span className="text-subtle">•</span>
|
||||
{feature}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<button
|
||||
type="button"
|
||||
className="mt-2 text-sm text-emphasis font-medium cursor-pointer underline"
|
||||
onClick={() => setShowFeatures(false)}>
|
||||
{t("hide")}
|
||||
</button>
|
||||
</>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
className="text-sm text-emphasis font-medium cursor-pointer underline"
|
||||
onClick={() => setShowFeatures(true)}>
|
||||
{t("show_more")}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Image - mobile only, hidden when features are expanded */}
|
||||
<div className={`${showFeatures ? "hidden" : ""} md:hidden my-4 flex items-center justify-center rounded-xl bg-subtle aspect-[3/4] overflow-hidden relative`}>
|
||||
<BannerImage {...bannerImageProps} />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div className="hidden md:flex items-center gap-2 mt-4">
|
||||
<p className="text-sm font-medium text-subtle">{t("available_on")}</p>
|
||||
{target === "team" && <TeamBadge />}
|
||||
{(target === "team" || target === "organization") && <OrgBadge />}
|
||||
</div>
|
||||
<div className="mt-4 h-px w-full border border-t-subtle border-dashed" />
|
||||
{/* Buttons */}
|
||||
<div className="mt-6 flex items-center justify-between md:justify-start gap-2">
|
||||
<UpgradePlanDialog
|
||||
tracking={tracking}
|
||||
info={{
|
||||
title,
|
||||
description: subtitle,
|
||||
}}
|
||||
target={target}>
|
||||
<Button
|
||||
onClick={() =>
|
||||
posthog.capture("fullscreen_upgrade_banner_cta_clicked", { source: tracking, target })
|
||||
}>
|
||||
{t("try_for_free")}
|
||||
<Icon name="arrow-right" />
|
||||
</Button>
|
||||
</UpgradePlanDialog>
|
||||
{learnMoreButton &&
|
||||
(learnMoreButton.href ? (
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="text-subtle"
|
||||
onClick={() =>
|
||||
posthog.capture("fullscreen_upgrade_banner_learn_more_clicked", {
|
||||
source: tracking,
|
||||
target,
|
||||
})
|
||||
}
|
||||
render={<Link href={learnMoreButton.href} target="_blank" rel="noopener noreferrer" />}>
|
||||
{learnMoreButton.text}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="text-subtle"
|
||||
onClick={() => {
|
||||
posthog.capture("fullscreen_upgrade_banner_learn_more_clicked", {
|
||||
source: tracking,
|
||||
target,
|
||||
});
|
||||
learnMoreButton.onClick?.();
|
||||
}}>
|
||||
{learnMoreButton.text}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right Content - Image */}
|
||||
<div className="-my-2 hidden md:flex flex-1 items-center justify-center rounded-l-xl bg-subtle aspect-[3/4] overflow-hidden border border-muted border-r-0 relative">
|
||||
<BannerImage {...bannerImageProps} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{youtubeId && (
|
||||
<Dialog open={videoOpen} onOpenChange={setVideoOpen}>
|
||||
<DialogPopup className="max-w-3xl overflow-hidden">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{name}</DialogTitle>
|
||||
<DialogDescription>
|
||||
{t("available_on_plan", { plan: target === "organization" ? t("organization") : t("team") })}
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<div className="aspect-video w-full px-6 pb-6">
|
||||
<iframe
|
||||
src={`https://www.youtube.com/embed/${youtubeId}`}
|
||||
title={title}
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allowFullScreen
|
||||
className="h-full w-full rounded-lg border border-muted"
|
||||
/>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
posthog.capture("fullscreen_upgrade_banner_video_dismissed", { source: tracking, target });
|
||||
setVideoOpen(false);
|
||||
}}>
|
||||
{t("dismiss")}
|
||||
</Button>
|
||||
<UpgradePlanDialog
|
||||
tracking={tracking}
|
||||
info={{
|
||||
title,
|
||||
description: subtitle,
|
||||
}}
|
||||
target={target}>
|
||||
<Button
|
||||
onClick={() =>
|
||||
posthog.capture("fullscreen_upgrade_banner_video_cta_clicked", {
|
||||
source: tracking,
|
||||
target,
|
||||
})
|
||||
}>
|
||||
{t("get_started")}
|
||||
<Icon name="arrow-right" />
|
||||
</Button>
|
||||
</UpgradePlanDialog>
|
||||
</DialogFooter>
|
||||
</DialogPopup>
|
||||
</Dialog>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Badge } from "@coss/ui/components/badge";
|
||||
|
||||
export function TeamBadge() {
|
||||
const { t } = useLocale();
|
||||
return <Badge variant="warning" className="bg-orange-200! text-orange-900">{t("teams")}</Badge>;
|
||||
}
|
||||
|
||||
export function OrgBadge() {
|
||||
const { t } = useLocale();
|
||||
return (
|
||||
<Badge variant="warning" className="bg-purple-200! text-purple-900">
|
||||
{t("orgs")}
|
||||
</Badge>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
"use client";
|
||||
|
||||
import { BILLING_PLANS, BILLING_PRICING } from "@calcom/features/ee/billing/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { Alert, AlertDescription, AlertTitle } from "@coss/ui/components/alert";
|
||||
import { Badge } from "@coss/ui/components/badge";
|
||||
import { Button } from "@coss/ui/components/button";
|
||||
import { Card, CardPanel } from "@coss/ui/components/card";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogHeader,
|
||||
DialogPanel,
|
||||
DialogPopup,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@coss/ui/components/dialog";
|
||||
import { Toggle, ToggleGroup } from "@coss/ui/components/toggle-group";
|
||||
import Link from "next/link";
|
||||
import posthog from "posthog-js";
|
||||
import { useState } from "react";
|
||||
|
||||
type BillingPeriodToggle = "annual" | "monthly";
|
||||
|
||||
interface PlanFeature {
|
||||
text: string;
|
||||
}
|
||||
|
||||
interface PlanColumnProps {
|
||||
name: string;
|
||||
badge?: string;
|
||||
price: string;
|
||||
priceSubtext: string;
|
||||
description: string;
|
||||
features: PlanFeature[];
|
||||
buttonText: string;
|
||||
buttonHref: string;
|
||||
buttonTarget?: string;
|
||||
primaryButton?: boolean;
|
||||
onCtaClick?: () => void;
|
||||
}
|
||||
|
||||
function PlanColumn({
|
||||
name,
|
||||
badge,
|
||||
price,
|
||||
priceSubtext,
|
||||
description,
|
||||
features,
|
||||
buttonText,
|
||||
buttonHref,
|
||||
buttonTarget,
|
||||
primaryButton,
|
||||
onCtaClick,
|
||||
}: PlanColumnProps): JSX.Element {
|
||||
return (
|
||||
<Card className="flex-1 gap-0 rounded-xl border-subtle p-4 py-0">
|
||||
<CardPanel className="px-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<h3 className="font-medium text-sm text-emphasis">{name}</h3>
|
||||
{badge && (
|
||||
<Badge variant="outline" className="rounded-lg py-0.5 px-2 h-fit!">
|
||||
{badge}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
<p className="font-cal mt-2 leading-none font-semibold text-2xl text-emphasis">{price}</p>
|
||||
<p className="mt-2 leading-none font-medium text-sm text-subtle h-4">{priceSubtext}</p>
|
||||
|
||||
<Button
|
||||
className="mt-4 w-full"
|
||||
variant={primaryButton ? "default" : "outline"}
|
||||
onClick={onCtaClick}
|
||||
render={
|
||||
<Link
|
||||
href={buttonHref}
|
||||
target={buttonTarget}
|
||||
rel={buttonTarget === "_blank" ? "noopener noreferrer" : undefined}
|
||||
/>
|
||||
}>
|
||||
<Icon name="circle-arrow-up" />
|
||||
<span>{buttonText}</span>
|
||||
</Button>
|
||||
|
||||
<p className="mt-4 text-sm text-subtle">{description}</p>
|
||||
|
||||
<ul className="mt-3 space-y-2">
|
||||
{features.map((feature) => (
|
||||
<li key={feature.text} className="flex items-start gap-2 text-sm">
|
||||
<Icon name="dot" className="relative top-0.5 h-4 w-4 shrink-0 text-default" />
|
||||
<span className="text-default">{feature.text}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</CardPanel>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export type UpgradePlanDialogProps = {
|
||||
tracking: string;
|
||||
target: "team" | "organization";
|
||||
info?: {
|
||||
title: string;
|
||||
description: string;
|
||||
};
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
export function UpgradePlanDialog({ tracking, target, info, children }: UpgradePlanDialogProps): JSX.Element {
|
||||
const { t } = useLocale();
|
||||
const [billingPeriod, setBillingPeriod] = useState<"annual" | "monthly">("annual");
|
||||
|
||||
const { data: activeTeamPlan } = trpc.viewer.teams.hasActiveTeamPlan.useQuery();
|
||||
|
||||
const formatCents = (cents: number) => {
|
||||
const dollars = cents / 100;
|
||||
return `$${cents % 100 === 0 ? dollars : dollars.toFixed(2)}`;
|
||||
};
|
||||
|
||||
const teamPrice = formatCents(BILLING_PRICING[BILLING_PLANS.TEAMS][billingPeriod]);
|
||||
const orgPrice = formatCents(BILLING_PRICING[BILLING_PLANS.ORGANIZATIONS][billingPeriod]);
|
||||
|
||||
const currentPlanPricingKey = activeTeamPlan?.billingPeriod === "ANNUALLY" ? "annual" : "monthly";
|
||||
const currentTeamPrice = formatCents(BILLING_PRICING[BILLING_PLANS.TEAMS][currentPlanPricingKey]);
|
||||
|
||||
const bpParam = billingPeriod === "annual" ? "a" : "m";
|
||||
const teamHref = `/settings/teams/new?bp=${bpParam}`;
|
||||
const organizationHref = `/onboarding/organization/details?migrate=true&bp=${bpParam}`;
|
||||
|
||||
const teamFeatures: PlanFeature[] = [
|
||||
{ text: t("upgrade_feature_round_robin") },
|
||||
{ text: t("upgrade_feature_collective_events") },
|
||||
{ text: t("routing_forms") },
|
||||
{ text: t("upgrade_feature_workflows") },
|
||||
{ text: t("upgrade_feature_insights") },
|
||||
{ text: t("upgrade_feature_remove_branding") },
|
||||
];
|
||||
|
||||
const orgFeatures: PlanFeature[] = [
|
||||
{ text: t("upgrade_feature_everything_in_team") },
|
||||
{ text: t("unlimited_teams") },
|
||||
{ text: t("upgrade_feature_verified_domain") },
|
||||
{ text: t("upgrade_feature_directory_sync") },
|
||||
{ text: t("upgrade_feature_sso") },
|
||||
{ text: t("upgrade_feature_admin_panel") },
|
||||
];
|
||||
|
||||
const enterpriseFeatures: PlanFeature[] = [
|
||||
{ text: t("upgrade_feature_everything_in_org") },
|
||||
{ text: t("upgrade_feature_dedicated_support") },
|
||||
{ text: t("upgrade_feature_custom_sla") },
|
||||
{ text: t("upgrade_feature_custom_integrations") },
|
||||
{ text: t("upgrade_feature_compliance") },
|
||||
];
|
||||
|
||||
return (
|
||||
<Dialog>
|
||||
<DialogTrigger render={children as React.ReactElement} />
|
||||
<DialogPopup className="max-w-3xl" showCloseButton={false} bottomStickOnMobile={false}>
|
||||
<DialogHeader>
|
||||
<div className="flex flex-wrap items-center justify-between gap-2">
|
||||
<DialogTitle>{t("upgrade_dialog_title")}</DialogTitle>
|
||||
<div className="flex items-center gap-1 max-sm:order-last">
|
||||
<ToggleGroup
|
||||
value={[billingPeriod]}
|
||||
onValueChange={(value): void => {
|
||||
if (value.length > 0) {
|
||||
const newPeriod = value[0] as BillingPeriodToggle;
|
||||
setBillingPeriod(newPeriod);
|
||||
posthog.capture("upgrade_plan_dialog_billing_period_changed", {
|
||||
source: tracking,
|
||||
target,
|
||||
billingPeriod: newPeriod,
|
||||
});
|
||||
}
|
||||
}}
|
||||
className="rounded-lg bg-muted p-1"
|
||||
size="sm">
|
||||
<Toggle
|
||||
value="annual"
|
||||
className="gap-1 rounded-md data-pressed:bg-default data-pressed:shadow-sm">
|
||||
{t("upgrade_billing_annual")}
|
||||
<Badge variant="info" size="sm">
|
||||
{t("discount_25")}
|
||||
</Badge>
|
||||
</Toggle>
|
||||
<Toggle
|
||||
value="monthly"
|
||||
className="ml-1 rounded-md data-pressed:bg-default data-pressed:shadow-sm">
|
||||
{t("monthly")}
|
||||
</Toggle>
|
||||
</ToggleGroup>
|
||||
<DialogClose render={<Button size="icon" variant="ghost" />}>
|
||||
<Icon name="x" />
|
||||
</DialogClose>
|
||||
</div>
|
||||
{info && (
|
||||
<Alert variant="info" className="w-full">
|
||||
<AlertTitle>{info.title}</AlertTitle>
|
||||
<AlertDescription>{info.description}</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
</div>
|
||||
</DialogHeader>
|
||||
|
||||
<DialogPanel>
|
||||
<div className="mt-3 overflow-x-auto">
|
||||
<div className="flex gap-2 sm:gap-4 max-sm:grid max-sm:grid-flow-col max-sm:auto-cols-fr max-sm:w-max">
|
||||
{target === "team" && (
|
||||
<PlanColumn
|
||||
name={t("team")}
|
||||
badge={t("upgrade_badge_free_trial")}
|
||||
price={teamPrice}
|
||||
priceSubtext={t("upgrade_price_per_month_user")}
|
||||
description={t("upgrade_plan_team_tagline")}
|
||||
features={teamFeatures}
|
||||
buttonText={t("upgrade_cta_teams")}
|
||||
buttonHref={teamHref}
|
||||
primaryButton={target === "team"}
|
||||
onCtaClick={() =>
|
||||
posthog.capture("upgrade_plan_dialog_cta_clicked", {
|
||||
source: tracking,
|
||||
plan: "team",
|
||||
target,
|
||||
billingPeriod,
|
||||
})
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
<PlanColumn
|
||||
name={t("organization")}
|
||||
badge={t("upgrade_badge_free_trial")}
|
||||
price={orgPrice}
|
||||
priceSubtext={t("upgrade_price_per_month_user")}
|
||||
description={t("upgrade_plan_org_tagline")}
|
||||
features={orgFeatures}
|
||||
buttonText={t("upgrade_cta_orgs")}
|
||||
buttonHref={organizationHref}
|
||||
primaryButton={target === "organization"}
|
||||
onCtaClick={() =>
|
||||
posthog.capture("upgrade_plan_dialog_cta_clicked", {
|
||||
source: tracking,
|
||||
plan: "organization",
|
||||
target,
|
||||
billingPeriod,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
<PlanColumn
|
||||
name={t("enterprise")}
|
||||
price={t("custom")}
|
||||
priceSubtext=""
|
||||
description={t("upgrade_plan_enterprise_tagline")}
|
||||
features={enterpriseFeatures}
|
||||
buttonText={t("upgrade_cta_enterprise")}
|
||||
buttonHref="https://cal.com/sales"
|
||||
buttonTarget="_blank"
|
||||
onCtaClick={() =>
|
||||
posthog.capture("upgrade_plan_dialog_cta_clicked", {
|
||||
source: tracking,
|
||||
plan: "enterprise",
|
||||
target,
|
||||
billingPeriod,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Card className="bg-muted mt-4 py-3 px-4 flex-row justify-between items-center">
|
||||
{target === "team" && (
|
||||
<div>
|
||||
<p className="font-medium text-sm text-emphasis">{t("individual")}</p>
|
||||
<p className="font-cal mt-1 font-semibold text-emphasis text-2xl leading-none">{t("free")}</p>
|
||||
</div>
|
||||
)}
|
||||
{target === "organization" && (
|
||||
<div>
|
||||
<p className="font-medium text-sm text-emphasis">{t("team")}</p>
|
||||
<p className="mt-1">
|
||||
<span className="font-cal font-semibold text-emphasis text-2xl leading-none">
|
||||
{currentTeamPrice}
|
||||
</span>
|
||||
<span className="ml-1 leading-none font-medium text-sm text-subtle">
|
||||
{t("upgrade_price_per_month_user")}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
<Badge variant="outline" size="lg" className="rounded-lg py-1.5 px-2.5 h-fit!">
|
||||
<span className="text-emphasis opacity-50 leading-none">{t("upgrade_badge_current_plan")}</span>
|
||||
</Badge>
|
||||
</Card>
|
||||
</DialogPanel>
|
||||
</DialogPopup>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
"use client";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { localStorage } from "@calcom/lib/webstorage";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { OrgBadge, TeamBadge } from "@calcom/web/modules/billing/components/PlanBadge";
|
||||
import { Button } from "@coss/ui/components/button";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import posthog from "posthog-js";
|
||||
import { useClientOnly } from "@calcom/lib/hooks/useClientOnly";
|
||||
import { useState } from "react";
|
||||
import type { UpgradeTarget } from "./types";
|
||||
|
||||
const STORAGE_KEY = "dismissed-large-upgrade-banners";
|
||||
|
||||
function isDismissed(tracking: string): boolean {
|
||||
const raw = localStorage.getItem(STORAGE_KEY);
|
||||
if (!raw) return false;
|
||||
try {
|
||||
const dismissed = JSON.parse(raw) as Record<string, boolean>;
|
||||
return dismissed[tracking] === true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function dismiss(tracking: string): void {
|
||||
const raw = localStorage.getItem(STORAGE_KEY);
|
||||
let dismissed: Record<string, boolean> = {};
|
||||
if (raw) {
|
||||
try {
|
||||
dismissed = JSON.parse(raw) as Record<string, boolean>;
|
||||
} catch {
|
||||
// corrupted data, start fresh
|
||||
}
|
||||
}
|
||||
dismissed[tracking] = true;
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(dismissed));
|
||||
}
|
||||
|
||||
export type WideUpgradeBannerProps = {
|
||||
tracking: string;
|
||||
title: string;
|
||||
subtitle: string;
|
||||
target: UpgradeTarget;
|
||||
size?: "md" | "sm";
|
||||
image: {
|
||||
src: string;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
learnMoreButton?: {
|
||||
text: string;
|
||||
href?: string;
|
||||
onClick?: () => void;
|
||||
};
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
export function WideUpgradeBanner({
|
||||
tracking,
|
||||
title,
|
||||
subtitle,
|
||||
target,
|
||||
size = "md",
|
||||
image,
|
||||
learnMoreButton,
|
||||
children,
|
||||
}: WideUpgradeBannerProps) {
|
||||
const { t } = useLocale();
|
||||
const [visible, setVisible] = useState(false);
|
||||
useClientOnly(() => {
|
||||
setVisible(!isDismissed(tracking));
|
||||
});
|
||||
|
||||
if (!visible) return null;
|
||||
|
||||
return (
|
||||
<div className="relative flex w-full overflow-hidden rounded-xl bg-muted border-muted border">
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="absolute right-2 top-2 z-10"
|
||||
onClick={() => {
|
||||
dismiss(tracking);
|
||||
setVisible(false);
|
||||
posthog.capture("large_upgrade_banner_dismissed", { source: tracking, target });
|
||||
}}>
|
||||
{/* This button goes on top of the image, so it's better to force this color */}
|
||||
<Icon name="x" className="h-4 w-4 text-gray-700" />
|
||||
</Button>
|
||||
{/* Left Content */}
|
||||
<div className="flex flex-1 flex-col p-6">
|
||||
{size === "sm" ? (
|
||||
<div className="flex items-start gap-1.5">
|
||||
<h2 className="font-cal text-base font-semibold leading-none text-default">{title}</h2>
|
||||
<div className="relative -top-1">
|
||||
{target === "team" ? <TeamBadge /> : <OrgBadge />}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
{target === "team" ? <TeamBadge /> : <OrgBadge />}
|
||||
<h2 className="mt-1 font-cal text-lg font-semibold leading-none text-default">{title}</h2>
|
||||
</div>
|
||||
)}
|
||||
<p className="mt-2 text-sm font-normal text-subtle">{subtitle}</p>
|
||||
|
||||
{/* Buttons */}
|
||||
<div className={`${size === "sm" ? "mt-4" : "mt-9"} flex items-center gap-2`}>
|
||||
{children}
|
||||
{learnMoreButton &&
|
||||
(learnMoreButton.href ? (
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="text-subtle"
|
||||
onClick={() =>
|
||||
posthog.capture("large_upgrade_banner_learn_more_clicked", { source: tracking, target })
|
||||
}
|
||||
render={<Link href={learnMoreButton.href} target="_blank" rel="noopener noreferrer" />}>
|
||||
{learnMoreButton.text}
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="text-subtle"
|
||||
onClick={() => {
|
||||
posthog.capture("large_upgrade_banner_learn_more_clicked", { source: tracking, target });
|
||||
learnMoreButton.onClick?.();
|
||||
}}>
|
||||
{learnMoreButton.text}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right Content - Image */}
|
||||
<div
|
||||
className={`relative hidden w-1/2 overflow-hidden md:block${size === "sm" ? " max-w-64" : " max-w-[520px]"}`}>
|
||||
<Image
|
||||
src={image.src}
|
||||
alt={title}
|
||||
fill
|
||||
className="object-cover object-left"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export type UpgradeTarget = "team" | "organization";
|
||||
@@ -0,0 +1,34 @@
|
||||
"use client";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { FullScreenUpgradeBanner } from "@calcom/web/modules/billing/components/FullScreenUpgradeBanner";
|
||||
|
||||
export function FullscreenUpgradeBannerForInsightsPage() {
|
||||
const { t } = useLocale();
|
||||
|
||||
const features = [
|
||||
t("upgrade_banner_insights_feature1"),
|
||||
t("upgrade_banner_insights_feature2"),
|
||||
t("upgrade_banner_insights_feature3"),
|
||||
];
|
||||
|
||||
return (
|
||||
<FullScreenUpgradeBanner
|
||||
tracking="fullscreen-upgrade-banner-for-insights-page"
|
||||
name={t("upgrade_banner_insights_name")}
|
||||
title={t("upgrade_banner_insights_title")}
|
||||
subtitle={t("upgrade_banner_insights_subtitle")}
|
||||
features={features}
|
||||
target="team"
|
||||
image={{
|
||||
src: "/upgrade/full_insights.png",
|
||||
width: 572,
|
||||
height: 744,
|
||||
}}
|
||||
learnMoreButton={{
|
||||
text: t("learn_more"),
|
||||
href: "https://cal.com/blog/insight-2-0-calcom-scheduling",
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
"use client";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { FullScreenUpgradeBanner } from "@calcom/web/modules/billing/components/FullScreenUpgradeBanner";
|
||||
|
||||
export function FullscreenUpgradeBannerForRolesAndPermissions() {
|
||||
const { t } = useLocale();
|
||||
|
||||
return (
|
||||
<FullScreenUpgradeBanner
|
||||
tracking="fullscreen-upgrade-banner-for-roles-and-permissions"
|
||||
name={t("upgrade_banner_roles_name")}
|
||||
title={t("upgrade_banner_roles_title")}
|
||||
subtitle={t("upgrade_banner_roles_subtitle")}
|
||||
target="organization"
|
||||
extraOffset={20}
|
||||
image={{
|
||||
src: "/upgrade/full_roles.png",
|
||||
width: 572,
|
||||
height: 744,
|
||||
}}
|
||||
youtubeId="J8HsK-8W39U"
|
||||
learnMoreButton={{
|
||||
text: t("learn_more"),
|
||||
href: "https://cal.com/blog/role-based-access-control",
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
"use client";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { FullScreenUpgradeBanner } from "@calcom/web/modules/billing/components/FullScreenUpgradeBanner";
|
||||
|
||||
export function FullscreenUpgradeBannerForRoutingFormPage() {
|
||||
const { t } = useLocale();
|
||||
|
||||
return (
|
||||
<FullScreenUpgradeBanner
|
||||
tracking="fullscreen-upgrade-banner-for-routing-form-page"
|
||||
name={t("upgrade_banner_routing_form_name")}
|
||||
title={t("upgrade_banner_routing_form_title")}
|
||||
subtitle={t("upgrade_banner_routing_form_subtitle")}
|
||||
target="team"
|
||||
image={{
|
||||
src: "/upgrade/full_insights_routing.png",
|
||||
width: 572,
|
||||
height: 744,
|
||||
}}
|
||||
youtubeId="omM89sE7Jpg"
|
||||
learnMoreButton={{
|
||||
text: t("learn_more"),
|
||||
href: "https://cal.com/routing",
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
"use client";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { FullScreenUpgradeBanner } from "@calcom/web/modules/billing/components/FullScreenUpgradeBanner";
|
||||
|
||||
export function FullscreenUpgradeBannerForTeamsPage() {
|
||||
const { t } = useLocale();
|
||||
|
||||
const features = [
|
||||
t("upgrade_banner_teams_feature1"),
|
||||
t("upgrade_banner_teams_feature2"),
|
||||
t("upgrade_banner_teams_feature3"),
|
||||
t("upgrade_banner_teams_feature4"),
|
||||
];
|
||||
|
||||
return (
|
||||
<FullScreenUpgradeBanner
|
||||
tracking="fullscreen-upgrade-banner-for-teams-page"
|
||||
name={t("upgrade_banner_teams_name")}
|
||||
title={t("upgrade_banner_teams_title")}
|
||||
subtitle={t("upgrade_banner_teams_subtitle")}
|
||||
features={features}
|
||||
target="team"
|
||||
image={{
|
||||
src: "/upgrade/full_teams.png",
|
||||
width: 572,
|
||||
height: 744,
|
||||
}}
|
||||
youtubeId="hp-l5oRVD-U"
|
||||
learnMoreButton={{
|
||||
text: t("learn_more"),
|
||||
href: "https://cal.com/teams",
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
"use client";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { UpgradePlanDialog } from "@calcom/web/modules/billing/components/UpgradePlanDialog";
|
||||
import { WideUpgradeBanner } from "@calcom/web/modules/billing/components/WideUpgradeBanner";
|
||||
import { Button } from "@coss/ui/components/button";
|
||||
|
||||
export function WideUpgradeBannerForMembers() {
|
||||
const { t } = useLocale();
|
||||
|
||||
return (
|
||||
<WideUpgradeBanner
|
||||
tracking="large-upgrade-banner-for-members"
|
||||
title={t("upgrade_banner_team_attributes_title")}
|
||||
subtitle={t("upgrade_banner_team_attributes_subtitle")}
|
||||
target="organization"
|
||||
image={{
|
||||
src: "/upgrade/large_members.png",
|
||||
width: 1010,
|
||||
height: 340,
|
||||
}}
|
||||
learnMoreButton={{
|
||||
text: t("learn_more"),
|
||||
href: "https://cal.com/help/routing/routing-with-attributes",
|
||||
}}>
|
||||
<UpgradePlanDialog tracking="members" target="organization">
|
||||
<Button variant="outline">
|
||||
{t("try_for_free")}
|
||||
<Icon name="arrow-right" />
|
||||
</Button>
|
||||
</UpgradePlanDialog>
|
||||
</WideUpgradeBanner>
|
||||
);
|
||||
}
|
||||
@@ -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>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useSession } from "next-auth/react";
|
||||
import { createContext, useState } from "react";
|
||||
import { createContext, useEffect, useRef, useState } from "react";
|
||||
|
||||
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
|
||||
|
||||
@@ -26,6 +26,21 @@ export function InsightsOrgTeamsProvider({ children }: { children: React.ReactNo
|
||||
);
|
||||
const [selectedTeamId, setSelectedTeamId] = useState<number | undefined>();
|
||||
|
||||
// Track whether the session has been loaded and initial state synced.
|
||||
// useState's initial value is only used on the first render, so if the session
|
||||
// isn't available yet (e.g. during SSR/hydration in production), orgTeamsType
|
||||
// defaults to "yours". This effect corrects it once the session loads.
|
||||
const isInitializedRef = useRef(false);
|
||||
useEffect(() => {
|
||||
if (!isInitializedRef.current && session.status === "authenticated") {
|
||||
isInitializedRef.current = true;
|
||||
const shouldBeOrg = isAdminOrOwner && currentOrgId;
|
||||
if (shouldBeOrg) {
|
||||
setOrgTeamsType("org");
|
||||
}
|
||||
}
|
||||
}, [session.status, isAdminOrOwner, currentOrgId]);
|
||||
|
||||
return (
|
||||
<InsightsOrgTeamsContext.Provider
|
||||
value={{
|
||||
|
||||
@@ -10,6 +10,7 @@ type UseCreateTeamOptions = {
|
||||
redirectBasePath?: string;
|
||||
skipRedirectAfterInvite?: boolean;
|
||||
isOnboarding?: boolean;
|
||||
billingPeriod?: "MONTHLY" | "ANNUALLY";
|
||||
};
|
||||
|
||||
export function useCreateTeam(options: UseCreateTeamOptions = {}) {
|
||||
@@ -17,6 +18,7 @@ export function useCreateTeam(options: UseCreateTeamOptions = {}) {
|
||||
redirectBasePath = "/onboarding/teams",
|
||||
skipRedirectAfterInvite = false,
|
||||
isOnboarding = true,
|
||||
billingPeriod,
|
||||
} = options;
|
||||
const router = useRouter();
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
@@ -48,6 +50,7 @@ export function useCreateTeam(options: UseCreateTeamOptions = {}) {
|
||||
bio: teamDetails.bio,
|
||||
logo: teamBrand.logo,
|
||||
isOnboarding,
|
||||
...(billingPeriod && { billingPeriod }),
|
||||
});
|
||||
|
||||
// If there's a checkout URL, redirect to Stripe payment
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import { useSearchParams } from "next/navigation";
|
||||
|
||||
export const useOnboardingQueryParams = () => {
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
const bpParam = searchParams?.get("bp");
|
||||
const billingPeriod = bpParam === "a" ? ("ANNUALLY" as const) : ("MONTHLY" as const);
|
||||
|
||||
const getQueryString = () => {
|
||||
const migrateParam = searchParams?.get("migrate");
|
||||
const queryParams = new URLSearchParams();
|
||||
if (migrateParam) queryParams.set("migrate", migrateParam);
|
||||
if (bpParam) queryParams.set("bp", bpParam);
|
||||
return queryParams.toString() ? `?${queryParams.toString()}` : "";
|
||||
};
|
||||
|
||||
return { billingPeriod, getQueryString };
|
||||
};
|
||||
@@ -18,7 +18,8 @@ export const useSubmitOnboarding = () => {
|
||||
const submitOnboarding = async (
|
||||
store: OnboardingState,
|
||||
userEmail: string,
|
||||
invitesToSubmit: OnboardingState["invites"]
|
||||
invitesToSubmit: OnboardingState["invites"],
|
||||
options?: { billingPeriod?: "MONTHLY" | "ANNUALLY" }
|
||||
) => {
|
||||
setIsSubmitting(true);
|
||||
setError(null);
|
||||
@@ -96,6 +97,7 @@ export const useSubmitOnboarding = () => {
|
||||
creationSource: CreationSource.WEBAPP,
|
||||
teams: teamsData,
|
||||
invitedMembers: allInvitedMembers,
|
||||
...(options?.billingPeriod && { billingPeriod: options.billingPeriod }),
|
||||
});
|
||||
|
||||
// If there's a checkout URL, redirect to Stripe (billing enabled flow)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useRouter } from "next/navigation";
|
||||
import posthog from "posthog-js";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
@@ -13,6 +13,7 @@ import { OnboardingCard } from "../../components/OnboardingCard";
|
||||
import { OnboardingLayout } from "../../components/OnboardingLayout";
|
||||
import { OnboardingOrganizationBrowserView } from "../../components/onboarding-organization-browser-view";
|
||||
import { useMigrationFlow } from "../../hooks/useMigrationFlow";
|
||||
import { useOnboardingQueryParams } from "../../hooks/useOnboardingQueryParams";
|
||||
import { useOnboardingStore } from "../../store/onboarding-store";
|
||||
|
||||
type OrganizationBrandViewProps = {
|
||||
@@ -21,8 +22,8 @@ type OrganizationBrandViewProps = {
|
||||
|
||||
export const OrganizationBrandView = ({ userEmail }: OrganizationBrandViewProps) => {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const { t } = useLocale();
|
||||
const { getQueryString } = useOnboardingQueryParams();
|
||||
const { organizationDetails, organizationBrand, setOrganizationBrand } = useOnboardingStore();
|
||||
const { isMigrationFlow, hasTeams } = useMigrationFlow();
|
||||
|
||||
@@ -52,8 +53,7 @@ export const OrganizationBrandView = ({ userEmail }: OrganizationBrandViewProps)
|
||||
};
|
||||
|
||||
const getNextStep = () => {
|
||||
const migrateParam = searchParams?.get("migrate");
|
||||
const queryString = migrateParam ? `?migrate=${migrateParam}` : "";
|
||||
const queryString = getQueryString();
|
||||
|
||||
// If migration flow and has teams, go to migrate-teams, otherwise go to teams
|
||||
if (isMigrationFlow && hasTeams) {
|
||||
@@ -80,7 +80,7 @@ export const OrganizationBrandView = ({ userEmail }: OrganizationBrandViewProps)
|
||||
const handleSkip = () => {
|
||||
posthog.capture("onboarding_organization_brand_skip_clicked");
|
||||
// Skip brand customization and go to teams
|
||||
router.push("/onboarding/organization/teams");
|
||||
router.push(`/onboarding/organization/teams${getQueryString()}`);
|
||||
};
|
||||
|
||||
const totalSteps = isMigrationFlow && hasTeams ? 6 : 4;
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
"use client";
|
||||
|
||||
import { isCompanyEmail } from "@calcom/features/ee/organizations/lib/utils";
|
||||
import { emailSchema } from "@calcom/lib/emailSchema";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Alert } from "@calcom/ui/components/alert";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { Form, InputError, TextField } from "@calcom/ui/components/form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
||||
import posthog from "posthog-js";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
import { OnboardingCard } from "../../components/OnboardingCard";
|
||||
import { OnboardingLayout } from "../../components/OnboardingLayout";
|
||||
import { OnboardingOrganizationBrowserView } from "../../components/onboarding-organization-browser-view";
|
||||
|
||||
type FormValues = {
|
||||
email: string;
|
||||
};
|
||||
|
||||
export const CompanyEmailRequired = ({ userEmail }: { userEmail: string }) => {
|
||||
const { t } = useLocale();
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
const [submittedEmail, setSubmittedEmail] = useState<string | null>(null);
|
||||
const [errorMessage, setErrorMessage] = useState("");
|
||||
|
||||
const formMethods = useForm<FormValues>({
|
||||
resolver: zodResolver(
|
||||
z.object({
|
||||
email: emailSchema.refine((val) => isCompanyEmail(val), {
|
||||
message: t("use_company_email_to_create_an_organization"),
|
||||
}),
|
||||
})
|
||||
),
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const subscription = formMethods.watch(() => setErrorMessage(""));
|
||||
return () => subscription.unsubscribe();
|
||||
}, [formMethods.watch]);
|
||||
|
||||
const addSecondaryEmailMutation = trpc.viewer.loggedInViewerRouter.addSecondaryEmail.useMutation({
|
||||
onSuccess: (_res, variables) => {
|
||||
setSubmittedEmail(variables.email);
|
||||
},
|
||||
onError: (error) => {
|
||||
setErrorMessage(error?.message || "");
|
||||
},
|
||||
});
|
||||
|
||||
const handleSubmit = (values: FormValues) => {
|
||||
posthog.capture("onboarding_company_email_verify_clicked");
|
||||
setErrorMessage("");
|
||||
const qs = searchParams?.toString() ?? "";
|
||||
const redirectTo = qs ? `${pathname ?? ""}?${qs}` : pathname ?? undefined;
|
||||
addSecondaryEmailMutation.mutate({
|
||||
email: values.email,
|
||||
makePrimary: true,
|
||||
redirectTo,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<OnboardingLayout userEmail={userEmail}>
|
||||
<OnboardingCard
|
||||
title={t("set_up_your_organization")}
|
||||
subtitle={t("onboarding_org_details_subtitle")}
|
||||
footer={
|
||||
!submittedEmail ? (
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<Button
|
||||
color="minimal"
|
||||
className="rounded-[10px]"
|
||||
onClick={() => {
|
||||
posthog.capture("onboarding_company_email_back_clicked");
|
||||
router.back();
|
||||
}}>
|
||||
{t("go_back")}
|
||||
</Button>
|
||||
<Button
|
||||
color="primary"
|
||||
className="rounded-[10px]"
|
||||
type="submit"
|
||||
form="company-email-form"
|
||||
disabled={addSecondaryEmailMutation.isPending}>
|
||||
{t("verify_email")}
|
||||
</Button>
|
||||
</div>
|
||||
) : undefined
|
||||
}>
|
||||
{submittedEmail ? (
|
||||
<Alert
|
||||
severity="info"
|
||||
title={t("check_your_email")}
|
||||
message={t("org_company_email_verification_sent", { email: submittedEmail })}
|
||||
/>
|
||||
) : (
|
||||
<Form id="company-email-form" form={formMethods} handleSubmit={handleSubmit}>
|
||||
<Alert severity="warning" title={t("org_requires_company_email")} className="mb-4" />
|
||||
<TextField
|
||||
label={t("company_email")}
|
||||
placeholder={t("company_email_placeholder")}
|
||||
{...formMethods.register("email")}
|
||||
/>
|
||||
{errorMessage && <InputError message={errorMessage} />}
|
||||
</Form>
|
||||
)}
|
||||
</OnboardingCard>
|
||||
|
||||
<OnboardingOrganizationBrowserView avatar={null} name="" bio="" slug="" bannerUrl={null} />
|
||||
</OnboardingLayout>
|
||||
);
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useRouter } from "next/navigation";
|
||||
import posthog from "posthog-js";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
@@ -12,6 +12,7 @@ import { OnboardingCard } from "../../components/OnboardingCard";
|
||||
import { OnboardingLayout } from "../../components/OnboardingLayout";
|
||||
import { OnboardingOrganizationBrowserView } from "../../components/onboarding-organization-browser-view";
|
||||
import { useMigrationFlow } from "../../hooks/useMigrationFlow";
|
||||
import { useOnboardingQueryParams } from "../../hooks/useOnboardingQueryParams";
|
||||
import { useOnboardingStore } from "../../store/onboarding-store";
|
||||
import { ValidatedOrganizationSlug } from "./validated-organization-slug";
|
||||
|
||||
@@ -31,8 +32,8 @@ const slugify = (text: string): string => {
|
||||
|
||||
export const OrganizationDetailsView = ({ userEmail }: OrganizationDetailsViewProps) => {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const { t } = useLocale();
|
||||
const { getQueryString } = useOnboardingQueryParams();
|
||||
const { organizationDetails, setOrganizationDetails, selectedPlan, setSelectedPlan } = useOnboardingStore();
|
||||
const { isMigrationFlow, hasTeams } = useMigrationFlow();
|
||||
|
||||
@@ -88,9 +89,7 @@ export const OrganizationDetailsView = ({ userEmail }: OrganizationDetailsViewPr
|
||||
link: organizationLink,
|
||||
bio: organizationBio,
|
||||
});
|
||||
const migrateParam = searchParams?.get("migrate");
|
||||
const nextUrl = `/onboarding/organization/brand${migrateParam ? `?migrate=${migrateParam}` : ""}`;
|
||||
router.push(nextUrl);
|
||||
router.push(`/onboarding/organization/brand${getQueryString()}`);
|
||||
};
|
||||
|
||||
const totalSteps = isMigrationFlow && hasTeams ? 6 : 4;
|
||||
|
||||
+4
-2
@@ -17,6 +17,7 @@ import { OnboardingCard } from "../../../components/OnboardingCard";
|
||||
import { OnboardingLayout } from "../../../components/OnboardingLayout";
|
||||
import { RoleSelector } from "../../../components/RoleSelector";
|
||||
import { OnboardingInviteBrowserView } from "../../../components/onboarding-invite-browser-view";
|
||||
import { useOnboardingQueryParams } from "../../../hooks/useOnboardingQueryParams";
|
||||
import { useSubmitOnboarding } from "../../../hooks/useSubmitOnboarding";
|
||||
import { useOnboardingStore, type InviteRole } from "../../../store/onboarding-store";
|
||||
import { OrganizationCSVUploadModal } from "../csv-upload-modal";
|
||||
@@ -41,6 +42,7 @@ export const OrganizationInviteEmailView = ({ userEmail }: OrganizationInviteEma
|
||||
const { teams } = useOnboardingStore();
|
||||
const migratedTeams = teams.filter((team) => team.isBeingMigrated);
|
||||
const isMigrationFlow = searchParams?.get("migrate") === "true";
|
||||
const { billingPeriod } = useOnboardingQueryParams();
|
||||
|
||||
const store = useOnboardingStore();
|
||||
const usersEmailDomain = userEmail.split("@")[1];
|
||||
@@ -102,7 +104,7 @@ export const OrganizationInviteEmailView = ({ userEmail }: OrganizationInviteEma
|
||||
|
||||
const handleContinue = async (data: FormValues) => {
|
||||
setInvites(data.invites);
|
||||
await submitOnboarding(store, userEmail, data.invites);
|
||||
await submitOnboarding(store, userEmail, data.invites, { billingPeriod });
|
||||
};
|
||||
|
||||
const handleBack = () => {
|
||||
@@ -111,7 +113,7 @@ export const OrganizationInviteEmailView = ({ userEmail }: OrganizationInviteEma
|
||||
|
||||
const handleSkip = async () => {
|
||||
setInvites([]);
|
||||
await submitOnboarding(store, userEmail, []);
|
||||
await submitOnboarding(store, userEmail, [], { billingPeriod });
|
||||
};
|
||||
|
||||
const handleGoogleWorkspaceConnect = () => {
|
||||
|
||||
@@ -12,6 +12,7 @@ import { InviteOptions } from "../../components/InviteOptions";
|
||||
import { OnboardingCard } from "../../components/OnboardingCard";
|
||||
import { OnboardingLayout } from "../../components/OnboardingLayout";
|
||||
import { OnboardingOrganizationBrowserView } from "../../components/onboarding-organization-browser-view";
|
||||
import { useOnboardingQueryParams } from "../../hooks/useOnboardingQueryParams";
|
||||
import { useSubmitOnboarding } from "../../hooks/useSubmitOnboarding";
|
||||
import { useOnboardingStore } from "../../store/onboarding-store";
|
||||
import { OrganizationCSVUploadModal } from "./csv-upload-modal";
|
||||
@@ -24,6 +25,7 @@ export const OrganizationInviteView = ({ userEmail }: OrganizationInviteViewProp
|
||||
const router = useRouter();
|
||||
const { t } = useLocale();
|
||||
const flags = useFlags();
|
||||
const { billingPeriod, getQueryString } = useOnboardingQueryParams();
|
||||
|
||||
const store = useOnboardingStore();
|
||||
const { setInvites, organizationDetails, organizationBrand } = store;
|
||||
@@ -37,7 +39,7 @@ export const OrganizationInviteView = ({ userEmail }: OrganizationInviteViewProp
|
||||
};
|
||||
|
||||
const handleInviteViaEmail = () => {
|
||||
router.push("/onboarding/organization/invite/email");
|
||||
router.push(`/onboarding/organization/invite/email${getQueryString()}`);
|
||||
};
|
||||
|
||||
const handleUploadCSV = () => {
|
||||
@@ -51,11 +53,11 @@ export const OrganizationInviteView = ({ userEmail }: OrganizationInviteViewProp
|
||||
const handleSkip = async () => {
|
||||
posthog.capture("onboarding_organization_invite_skip_clicked");
|
||||
setInvites([]);
|
||||
await submitOnboarding(store, userEmail, []);
|
||||
await submitOnboarding(store, userEmail, [], { billingPeriod });
|
||||
};
|
||||
|
||||
const handleInvite = async () => {
|
||||
await submitOnboarding(store, userEmail, []);
|
||||
await submitOnboarding(store, userEmail, [], { billingPeriod });
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -71,7 +73,7 @@ export const OrganizationInviteView = ({ userEmail }: OrganizationInviteViewProp
|
||||
className="rounded-[10px]"
|
||||
onClick={() => {
|
||||
posthog.capture("onboarding_organization_invite_back_clicked");
|
||||
router.push("/onboarding/organization/teams");
|
||||
router.push(`/onboarding/organization/teams${getQueryString()}`);
|
||||
}}
|
||||
disabled={isSubmitting}>
|
||||
{t("back")}
|
||||
|
||||
+4
-5
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
@@ -15,6 +15,7 @@ import { OnboardingCard } from "../../components/OnboardingCard";
|
||||
import { OnboardingLayout } from "../../components/OnboardingLayout";
|
||||
import { OnboardingMigrateMembersBrowserView } from "../../components/onboarding-migrate-members-browser-view";
|
||||
import { useMigrationFlow } from "../../hooks/useMigrationFlow";
|
||||
import { useOnboardingQueryParams } from "../../hooks/useOnboardingQueryParams";
|
||||
import { useOnboardingStore } from "../../store/onboarding-store";
|
||||
|
||||
type TeamMember = RouterOutputs["viewer"]["teams"]["listMembers"]["members"][number];
|
||||
@@ -25,8 +26,8 @@ type OrganizationMigrateMembersViewProps = {
|
||||
|
||||
export const OrganizationMigrateMembersView = ({ userEmail }: OrganizationMigrateMembersViewProps) => {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const { t } = useLocale();
|
||||
const { getQueryString } = useOnboardingQueryParams();
|
||||
const { isLoading: isMigrationFlowLoading } = useMigrationFlow();
|
||||
const { teams, organizationBrand, organizationDetails, setMigratedMembers } = useOnboardingStore();
|
||||
|
||||
@@ -56,9 +57,7 @@ export const OrganizationMigrateMembersView = ({ userEmail }: OrganizationMigrat
|
||||
|
||||
setMigratedMembers(migratedMembersData);
|
||||
|
||||
const migrateParam = searchParams?.get("migrate");
|
||||
const nextUrl = `/onboarding/organization/invite/email${migrateParam ? `?migrate=${migrateParam}` : ""}`;
|
||||
router.push(nextUrl);
|
||||
router.push(`/onboarding/organization/invite/email${getQueryString()}`);
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
|
||||
+5
-8
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
@@ -16,6 +16,7 @@ import { OnboardingCard } from "../../components/OnboardingCard";
|
||||
import { OnboardingLayout } from "../../components/OnboardingLayout";
|
||||
import { OnboardingMigrateTeamsBrowserView } from "../../components/onboarding-migrate-teams-browser-view";
|
||||
import { useMigrationFlow } from "../../hooks/useMigrationFlow";
|
||||
import { useOnboardingQueryParams } from "../../hooks/useOnboardingQueryParams";
|
||||
import { useOnboardingStore } from "../../store/onboarding-store";
|
||||
import { getSuggestedSlug } from "./utils";
|
||||
|
||||
@@ -37,8 +38,8 @@ type FormValues = z.infer<typeof schema>;
|
||||
|
||||
export const OrganizationMigrateTeamsView = ({ userEmail }: OrganizationMigrateTeamsViewProps) => {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const { t } = useLocale();
|
||||
const { getQueryString } = useOnboardingQueryParams();
|
||||
const { isMigrationFlow, hasTeams, teams, isLoading } = useMigrationFlow();
|
||||
const { organizationDetails, organizationBrand, teams: teamsFromStore, setTeams } = useOnboardingStore();
|
||||
const orgSlug = organizationDetails.link;
|
||||
@@ -115,15 +116,11 @@ export const OrganizationMigrateTeamsView = ({ userEmail }: OrganizationMigrateT
|
||||
|
||||
setTeams([...teamsBeingMoved, ...existingNewTeams]);
|
||||
|
||||
const migrateParam = searchParams?.get("migrate");
|
||||
const nextUrl = `/onboarding/organization/teams${migrateParam ? `?migrate=${migrateParam}` : ""}`;
|
||||
router.push(nextUrl);
|
||||
router.push(`/onboarding/organization/teams${getQueryString()}`);
|
||||
};
|
||||
|
||||
const handleSkip = () => {
|
||||
const migrateParam = searchParams?.get("migrate");
|
||||
const nextUrl = `/onboarding/organization/teams${migrateParam ? `?migrate=${migrateParam}` : ""}`;
|
||||
router.push(nextUrl);
|
||||
router.push(`/onboarding/organization/teams${getQueryString()}`);
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useRouter } from "next/navigation";
|
||||
import posthog from "posthog-js";
|
||||
import { useForm, useFieldArray } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
@@ -17,6 +17,7 @@ import { OnboardingCard } from "../../components/OnboardingCard";
|
||||
import { OnboardingLayout } from "../../components/OnboardingLayout";
|
||||
import { OnboardingTeamsBrowserView } from "../../components/onboarding-teams-browser-view";
|
||||
import { useMigrationFlow } from "../../hooks/useMigrationFlow";
|
||||
import { useOnboardingQueryParams } from "../../hooks/useOnboardingQueryParams";
|
||||
import { useOnboardingStore } from "../../store/onboarding-store";
|
||||
|
||||
type OrganizationTeamsViewProps = {
|
||||
@@ -29,8 +30,8 @@ type FormValues = {
|
||||
|
||||
export const OrganizationTeamsView = ({ userEmail }: OrganizationTeamsViewProps) => {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const { t } = useLocale();
|
||||
const { getQueryString } = useOnboardingQueryParams();
|
||||
const { teams: storedTeams, setTeams, organizationBrand, organizationDetails } = useOnboardingStore();
|
||||
const { isMigrationFlow } = useMigrationFlow();
|
||||
|
||||
@@ -59,8 +60,7 @@ export const OrganizationTeamsView = ({ userEmail }: OrganizationTeamsViewProps)
|
||||
});
|
||||
|
||||
const getNextStep = () => {
|
||||
const migrateParam = searchParams?.get("migrate");
|
||||
const queryString = migrateParam ? `?migrate=${migrateParam}` : "";
|
||||
const queryString = getQueryString();
|
||||
|
||||
// If migration flow and teams were migrated, go to migrate-members
|
||||
if (isMigrationFlow && migratedTeams.length > 0) {
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { revalidateSettingsProfile } from "app/cache/path/settings/my-account";
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { get, pick } from "lodash";
|
||||
import { signOut, useSession } from "next-auth/react";
|
||||
import type { BaseSyntheticEvent } from "react";
|
||||
import React, { useRef, useState } from "react";
|
||||
import { Controller, useFieldArray, useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
import { ErrorCode } from "@calcom/features/auth/lib/ErrorCode";
|
||||
import { Dialog } from "@calcom/features/components/controlled-dialog";
|
||||
import { isCompanyEmail } from "@calcom/features/ee/organizations/lib/utils";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import SettingsHeader from "@calcom/features/settings/appDir/SettingsHeader";
|
||||
import SectionBottomActions from "@calcom/features/settings/SectionBottomActions";
|
||||
import { APP_NAME, FULL_NAME_LENGTH_MAX_LIMIT } from "@calcom/lib/constants";
|
||||
import { emailSchema } from "@calcom/lib/emailSchema";
|
||||
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
|
||||
@@ -28,25 +18,29 @@ import type { AppRouter } from "@calcom/trpc/types/server/routers/_app";
|
||||
import { Alert } from "@calcom/ui/components/alert";
|
||||
import { UserAvatar } from "@calcom/ui/components/avatar";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { DialogContent, DialogFooter, DialogTrigger, DialogClose } from "@calcom/ui/components/dialog";
|
||||
import { DialogClose, DialogContent, DialogFooter, DialogTrigger } from "@calcom/ui/components/dialog";
|
||||
import { Editor } from "@calcom/ui/components/editor";
|
||||
import { Form } from "@calcom/ui/components/form";
|
||||
import { PasswordField } from "@calcom/ui/components/form";
|
||||
import { Label } from "@calcom/ui/components/form";
|
||||
import { TextField } from "@calcom/ui/components/form";
|
||||
import { Form, Label, PasswordField, TextField } from "@calcom/ui/components/form";
|
||||
import { ImageUploader } from "@calcom/ui/components/image-uploader";
|
||||
import { InfoIcon } from "@coss/ui/icons";
|
||||
import { showToast } from "@calcom/ui/components/toast";
|
||||
import { DisplayInfo } from "@calcom/web/modules/users/components/UserTable/EditSheet/DisplayInfo";
|
||||
|
||||
import TwoFactor from "@components/auth/TwoFactor";
|
||||
import CustomEmailTextField from "@components/settings/CustomEmailTextField";
|
||||
import SecondaryEmailConfirmModal from "@components/settings/SecondaryEmailConfirmModal";
|
||||
import SecondaryEmailModal from "@components/settings/SecondaryEmailModal";
|
||||
import { UsernameAvailabilityField } from "@components/ui/UsernameAvailability";
|
||||
|
||||
import { InfoIcon } from "@coss/ui/icons";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import type { TRPCClientErrorLike } from "@trpc/client";
|
||||
|
||||
import { revalidateSettingsProfile } from "app/cache/path/settings/my-account";
|
||||
// eslint-disable-next-line no-restricted-imports
|
||||
import { get, pick } from "lodash";
|
||||
import { signOut, useSession } from "next-auth/react";
|
||||
import type React from "react";
|
||||
import type { BaseSyntheticEvent } from "react";
|
||||
import { useRef, useState } from "react";
|
||||
import { Controller, useFieldArray, useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
import { CompanyEmailOrganizationBanner } from "./components/CompanyEmailOrganizationBanner";
|
||||
|
||||
interface DeleteAccountValues {
|
||||
@@ -77,6 +71,7 @@ const ProfileView = ({ user }: Props) => {
|
||||
const utils = trpc.useUtils();
|
||||
const session = useSession();
|
||||
const { update } = session;
|
||||
const [showSecondaryEmailModalOpen, setShowSecondaryEmailModalOpen] = useState(false);
|
||||
const updateProfileMutation = trpc.viewer.me.updateProfile.useMutation({
|
||||
onSuccess: async (res) => {
|
||||
await update(res);
|
||||
@@ -135,7 +130,6 @@ const ProfileView = ({ user }: Props) => {
|
||||
const [confirmPasswordErrorMessage, setConfirmPasswordDeleteErrorMessage] = useState("");
|
||||
const [showCreateAccountPasswordDialog, setShowCreateAccountPasswordDialog] = useState(false);
|
||||
const [showAccountDisconnectWarning, setShowAccountDisconnectWarning] = useState(false);
|
||||
const [showSecondaryEmailModalOpen, setShowSecondaryEmailModalOpen] = useState(false);
|
||||
const [secondaryEmailAddErrorMessage, setSecondaryEmailAddErrorMessage] = useState("");
|
||||
const [newlyAddedSecondaryEmail, setNewlyAddedSecondaryEmail] = useState<undefined | string>(undefined);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import posthog from "posthog-js";
|
||||
import React, { useEffect, useRef, useState, type FormEvent } from "react";
|
||||
|
||||
@@ -25,12 +25,16 @@ type CreateNewTeamViewProps = {
|
||||
|
||||
export const CreateNewTeamView = ({ userEmail }: CreateNewTeamViewProps) => {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const { t } = useLocale();
|
||||
const store = useOnboardingStore();
|
||||
const { teamDetails, teamBrand, setTeamDetails, setTeamBrand, resetOnboardingPreservingPlan } = store;
|
||||
const bpParam = searchParams?.get("bp");
|
||||
const billingPeriod = bpParam === "a" ? ("ANNUALLY" as const) : bpParam === "m" ? ("MONTHLY" as const) : undefined;
|
||||
const { createTeam, isSubmitting } = useCreateTeam({
|
||||
redirectBasePath: "/settings/teams/new",
|
||||
isOnboarding: false,
|
||||
billingPeriod,
|
||||
});
|
||||
|
||||
const logoRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
@@ -206,10 +206,10 @@ function MainContainer({
|
||||
...props
|
||||
}: LayoutProps) {
|
||||
return (
|
||||
<main className="bg-default relative z-0 flex-1 pb-8 focus:outline-none">
|
||||
<main className="bg-default relative z-0 flex-1 focus:outline-none">
|
||||
{/* show top navigation for md and smaller (tablet and phones) */}
|
||||
{TopNavContainerProp}
|
||||
<div className="max-w-full p-2 sm:py-4 lg:px-6">
|
||||
<div className="max-w-full p-2 sm:p-4 lg:p-6">
|
||||
<ErrorBoundary>
|
||||
{!props.withoutMain ? <ShellMain {...props}>{props.children}</ShellMain> : props.children}
|
||||
</ErrorBoundary>
|
||||
|
||||
@@ -20,8 +20,7 @@ import { NavigationItem, MobileNavigationItem, MobileNavigationMoreItem } from "
|
||||
export const MORE_SEPARATOR_NAME = "more";
|
||||
|
||||
const getNavigationItems = (
|
||||
orgBranding: OrganizationBranding,
|
||||
hasAllInsightsAccess: boolean
|
||||
orgBranding: OrganizationBranding
|
||||
): NavigationItemType[] => [
|
||||
{
|
||||
name: "event_types_page_title",
|
||||
@@ -112,8 +111,7 @@ const getNavigationItems = (
|
||||
icon: "chart-bar",
|
||||
isCurrent: ({ pathname: path, item }) => path?.startsWith(item.href) ?? false,
|
||||
moreOnMobile: true,
|
||||
child: hasAllInsightsAccess
|
||||
? [
|
||||
child: [
|
||||
{
|
||||
name: "bookings",
|
||||
href: "/insights",
|
||||
@@ -141,14 +139,6 @@ const getNavigationItems = (
|
||||
isCurrent: ({ pathname: path }) => path?.startsWith("/insights/wrong-routing") ?? false,
|
||||
},
|
||||
]
|
||||
: [
|
||||
{
|
||||
name: "call_history",
|
||||
href: "/insights/call-history",
|
||||
// icon: "phone",
|
||||
isCurrent: ({ pathname: path }) => path?.startsWith("/insights/call-history") ?? false,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -206,9 +196,8 @@ const useNavigationItems = (isPlatformNavigation = false) => {
|
||||
const orgBranding = useOrgBranding();
|
||||
const { hasPaidPlan, isPending } = useHasPaidPlan();
|
||||
return useMemo(() => {
|
||||
const hasAllInsightsAccess = !isPending && !!hasPaidPlan;
|
||||
const items = !isPlatformNavigation
|
||||
? getNavigationItems(orgBranding, hasAllInsightsAccess)
|
||||
? getNavigationItems(orgBranding)
|
||||
: platformNavigationItems;
|
||||
|
||||
const desktopNavigationItems = items.filter((item) => item.name !== MORE_SEPARATOR_NAME);
|
||||
|
||||
Reference in new issue
Block a user