Files
calendar/packages/features/shell/useBottomNavItems.ts
T
Amit SharmaGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
9048d053ac feat: posthog version upgrade and added trackings (#24401)
* posthog version upgrade and calai banner tracking

* disable posthog for EU

* bunch more posthog tracking

* Revert yarn.lock changes

* add posthog package yarn changes

* fix: add missing posthog import and fix lint warning in MemberInvitationModal

Co-Authored-By: amit@cal.com <samit91848@gmail.com>

* fix: type check

* cubic fixes

* refactor

* remove ui playground

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2025-11-28 12:43:37 +00:00

92 lines
2.5 KiB
TypeScript

import type { User as UserAuth } from "next-auth";
import posthog from "posthog-js";
import { useHasActiveTeamPlanAsOwner } from "@calcom/features/billing/hooks/useHasPaidPlan";
import { IS_DUB_REFERRALS_ENABLED } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { showToast } from "@calcom/ui/components/toast";
import { type NavigationItemType } from "./navigation/NavigationItem";
type BottomNavItemsProps = {
publicPageUrl: string;
isAdmin: boolean;
user: UserAuth | null | undefined;
};
export function useBottomNavItems({
publicPageUrl,
isAdmin,
user,
}: BottomNavItemsProps): NavigationItemType[] {
const { t } = useLocale();
const { isTrial } = useHasActiveTeamPlanAsOwner();
const utils = trpc.useUtils();
const skipTeamTrialsMutation = trpc.viewer.teams.skipTeamTrials.useMutation({
onSuccess: () => {
utils.viewer.teams.hasActiveTeamPlan.invalidate();
showToast(t("team_trials_skipped_successfully"), "success");
},
onError: () => {
showToast(t("something_went_wrong"), "error");
},
});
return [
// Render above to prevent layout shift as much as possible
isTrial
? {
name: "skip_trial",
href: "",
isLoading: skipTeamTrialsMutation.isPending,
icon: "clock",
onClick: (e: { preventDefault: () => void }) => {
e.preventDefault();
skipTeamTrialsMutation.mutate({});
},
}
: null,
{
name: "view_public_page",
href: publicPageUrl,
icon: "external-link",
target: "__blank",
},
{
name: "copy_public_page_link",
href: "",
onClick: (e: { preventDefault: () => void }) => {
e.preventDefault();
navigator.clipboard.writeText(publicPageUrl);
showToast(t("link_copied"), "success");
},
icon: "copy",
},
IS_DUB_REFERRALS_ENABLED
? {
name: "referral_text",
href: "/refer",
icon: "gift",
onClick: () => {
posthog.capture("refer_and_earn_clicked")
}
}
: null,
isAdmin
? {
name: "impersonation",
href: "/settings/admin/impersonation",
icon: "lock",
}
: null,
{
name: "settings",
href: user?.org ? `/settings/organizations/profile` : "/settings/my-account/profile",
icon: "settings",
},
].filter(Boolean) as NavigationItemType[];
}