60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import type { User as UserAuth } from "next-auth";
|
|
|
|
import { IS_DUB_REFERRALS_ENABLED } from "@calcom/lib/constants";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
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();
|
|
|
|
return [
|
|
{
|
|
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",
|
|
}
|
|
: 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[];
|
|
}
|