refactor: Move trpc-dependent components from features to web [1] (#25859)
* refactor: migrate UnconfirmedBookingBadge from features to apps/web Move UnconfirmedBookingBadge.tsx from packages/features/bookings/ to apps/web/modules/bookings/components/ as part of the architectural refactor to remove trpc client imports from the features layer. Also removes unused preserveBookingsQueryParams function from Navigation.tsx. Co-Authored-By: [email protected] <[email protected]> * refactor: move shell navigation and badges to apps/web Move shell navigation components and trpc-using badges from packages/features to apps/web/modules to fix circular dependency: - Move navigation folder to apps/web/modules/shell/navigation/ - Move TeamInviteBadge.tsx to apps/web/modules/shell/ - Create Shell wrapper in apps/web that provides MobileNavigationContainer - Update all Shell imports in apps/web to use the new wrapper - Remove MobileNavigationContainer default from features Shell.tsx - Fix pre-existing lint warnings in touched files This establishes the pattern for migrating React components that use trpc hooks from the features layer to the web app layer, ensuring proper dependency direction: apps/web imports from packages/features, never the reverse. Co-Authored-By: [email protected] <[email protected]> * fix: move SideBar.tsx to apps/web to fix build error SideBar.tsx was importing Navigation from the moved navigation folder, causing a build error. Moving SideBar.tsx to apps/web and updating the features Shell to not have a default SidebarContainer fixes this. The web Shell wrapper now provides both the default SidebarContainer and MobileNavigationContainer, maintaining the injection pattern. Co-Authored-By: [email protected] <[email protected]> * revert * revert * revert * wip * wip * wip * wip * wip * wip * not used anywhere * wip * wip * wip * wip * fix * fix * wip * wip * wip * wip * wip * fix * fix * fix * fix * migrate * migrate admin-adpi * wip * feat: migrate organization settings components from packages/features to apps/web/modules - Migrate profile.tsx, appearance.tsx, general.tsx, privacy.tsx, guest-notifications.tsx, delegationCredential.tsx, other-team-members-view.tsx, other-team-profile-view.tsx - Migrate attributes directory (AttributesForm.tsx, DeleteAttributeModal.tsx, ListSkeleton.tsx, attributes-create-view.tsx, attributes-edit-view.tsx, attributes-list-view.tsx) - Migrate admin directory (AdminOrgEditPage.tsx, AdminOrgPage.tsx, WorkspacePlatformPage.tsx) - Update all page imports to use new paths from ~/settings/organizations/ - Update relative imports in migrated files to use @calcom/features paths - Fix lint warnings in migrated files Co-Authored-By: [email protected] <[email protected]> * fix: update test import path after migration Co-Authored-By: [email protected] <[email protected]> * fix: remove unnecessary test-setup import (already in vitest config) Co-Authored-By: [email protected] <[email protected]> * wip * refactor: delete original files after migration to apps/web/modules Co-Authored-By: [email protected] <[email protected]> * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix * fix * fix * fix * wip * refactor more * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * mv * update import paths * wip * wip * fix * fix * fix * fix * fix * fix * fix * mv * mv * mv * fix * wip * wip * fix * fix * fix * fix: make test mocks resilient to vi.resetAllMocks() Co-Authored-By: [email protected] <[email protected]> * fix: fix AttributeForm test failures Co-Authored-By: [email protected] <[email protected]> * fix * fix * refactor: move ee files to apps/web/modules/ee/ folder - Move teams, workflows, and organizations folders to apps/web/modules/ee/ - Add LICENSE file to apps/web/modules/ee/ - Update all import paths from ~/teams/ to ~/ee/teams/ - Update all import paths from ~/settings/organizations/ to ~/ee/organizations/ - Remove duplicate MemberInvitationModal copy.tsx file Co-Authored-By: [email protected] <[email protected]> * fix: move useHasPaidPlan and dependent files to apps/web/modules - Move useHasPaidPlan.ts from packages/features/billing/hooks to apps/web/modules/billing/hooks - Move intercom files from packages/features/ee/support to apps/web/modules/ee/support - Move ContactMenuItem.tsx and dependencies (freshchat, helpscout, zendesk) to apps/web/modules/ee/support - Move ViewRecordingsDialog.tsx and RecordingListSkeleton to apps/web/modules/ee/video - Move CalVideoSettings.tsx to apps/web/modules/eventtypes/components/locations - Move CreateOrEditOutOfOfficeModal.tsx to apps/web/modules/settings/outOfOffice - Refactor UpgradeTeamsBadge to accept props and create wrapper in apps/web/modules/billing - Update all callers to use new file locations - Add eslint-disable comments for pre-existing lint warnings This fixes the tRPC server build failure caused by circular dependency where the server build was traversing into packages/features and pulling in React hooks that depend on @calcom/trpc/react types. Co-Authored-By: [email protected] <[email protected]> * fix: correct UpgradeTeamsBadge import path to use package export Co-Authored-By: [email protected] <[email protected]> * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * fix * fix * fix * fix * fix * fix * fix * fix: pass plan state through SelectProps to UpgradeTeamsBadge - Add upgradeTeamsBadgeProps field to ExtendedOption type in Select component - Update OptionComponent to spread upgradeTeamsBadgeProps to UpgradeTeamsBadge - Update getOptions.ts to accept PlanState object and include upgradeTeamsBadgeProps - Update WorkflowStepContainer.tsx to pass planState to getWorkflowTriggerOptions/getWorkflowTemplateOptions - Update WorkflowDetailsPage.tsx to pass upgradeTeamsBadgeProps in transformed action options - Update AddActionDialog.tsx interface and mapping to include upgradeTeamsBadgeProps - Add eslint-disable comments for pre-existing React Hook dependency warnings This fixes the UpgradeTeamsBadge refactoring issue where the badge was always showing 'upgrade' text instead of the correct text based on plan state (trial_mode, inactive_team_plan, etc.) Co-Authored-By: [email protected] <[email protected]> * fix: update import paths to use /ee/ folder for workflows and organizations Co-Authored-By: [email protected] <[email protected]> * fix: update workflow component imports to use /ee/ folder Co-Authored-By: [email protected] <[email protected]> * fix: add missing types.ts for LocationInput.tsx Co-Authored-By: [email protected] <[email protected]> * fix: extract BookingRedirectForm type to shared location Co-Authored-By: [email protected] <[email protected]> * fix * wip * wip * fix: update BookingRedirectForm import to use local types file Co-Authored-By: [email protected] <[email protected]> * wip * fix * fix --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
7847177e8b
commit
8afe87ff75
374 files changed
+1213
-1417
No files matched your search
@@ -0,0 +1,27 @@
|
||||
"use client";
|
||||
|
||||
import { WelcomeToOrganizationsModal } from "@calcom/features/ee/organizations/components/WelcomeToOrganizationsModal";
|
||||
|
||||
import { WelcomeToCalcomModal } from "./components/WelcomeToCalcomModal";
|
||||
import { GatedFeaturesModal } from "./components/GatedFeaturesModal";
|
||||
|
||||
/**
|
||||
* Container for all query-param driven modals that should appear globally across the app.
|
||||
* This keeps the Shell component clean and provides a centralized place for dynamic modals.
|
||||
*
|
||||
* We can probably also use this for thinks like the T&C and Privacy Policy modals. That @marketing are discussing
|
||||
*
|
||||
* To add a new modal:
|
||||
* 1. Create the modal component with its own useQueryState hook
|
||||
* 2. Import and add it here
|
||||
*/
|
||||
export function DynamicModals() {
|
||||
return (
|
||||
<>
|
||||
<WelcomeToOrganizationsModal />
|
||||
<WelcomeToCalcomModal />
|
||||
{/* Add more query-param driven modals here */}
|
||||
<GatedFeaturesModal />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
import type { Action } from "kbar";
|
||||
import {
|
||||
KBarAnimator,
|
||||
KBarPortal,
|
||||
KBarPositioner,
|
||||
KBarProvider,
|
||||
KBarResults,
|
||||
KBarSearch,
|
||||
useKBar,
|
||||
useMatches,
|
||||
useRegisterActions,
|
||||
} from "kbar";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useMemo, useState } from "react";
|
||||
|
||||
import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
|
||||
import { MintlifyChat } from "@calcom/features/mintlify-chat/MintlifyChat";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { isMac } from "@calcom/lib/isMac";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { Tooltip } from "@calcom/ui/components/tooltip";
|
||||
|
||||
type shortcutArrayType = {
|
||||
shortcuts?: string[];
|
||||
};
|
||||
|
||||
const getApps = Object.values(appStoreMetadata).map(({ name, slug }) => ({
|
||||
id: slug,
|
||||
name,
|
||||
section: "Installable Apps",
|
||||
keywords: `app ${name}`,
|
||||
}));
|
||||
|
||||
const useEventTypesAction = () => {
|
||||
const router = useRouter();
|
||||
const { data } = trpc.viewer.eventTypes.getEventTypesFromGroup.useInfiniteQuery(
|
||||
{
|
||||
limit: 10,
|
||||
group: { teamId: null, parentId: null },
|
||||
},
|
||||
{
|
||||
refetchOnWindowFocus: false,
|
||||
staleTime: 1 * 60 * 60 * 1000,
|
||||
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
||||
}
|
||||
);
|
||||
|
||||
const eventTypeActions: Action[] =
|
||||
data?.pages?.flatMap((page) => {
|
||||
return (
|
||||
page?.eventTypes?.map((item) => ({
|
||||
id: `event-type-${item.id}`,
|
||||
name: item.title,
|
||||
section: "event_types_page_title",
|
||||
keywords: "event types",
|
||||
perform: () => router.push(`/event-types/${item.id}`),
|
||||
})) ?? []
|
||||
);
|
||||
}) ?? [];
|
||||
|
||||
const actions = eventTypeActions?.length ? eventTypeActions : [];
|
||||
|
||||
return useRegisterActions(actions);
|
||||
};
|
||||
|
||||
export const KBarRoot = ({ children }: { children: React.ReactNode }) => {
|
||||
const router = useRouter();
|
||||
|
||||
// grab link to events
|
||||
// quick nested actions would be extremely useful
|
||||
|
||||
const actions = useMemo(() => {
|
||||
const appStoreActions = getApps.map((item) => ({
|
||||
...item,
|
||||
perform: () => router.push(`/apps/${item.id}`),
|
||||
}));
|
||||
return [
|
||||
{
|
||||
id: "workflows",
|
||||
name: "workflows",
|
||||
section: "workflows",
|
||||
shortcut: ["w", "f"],
|
||||
keywords: "workflows automation",
|
||||
perform: () => router.push("/workflows"),
|
||||
},
|
||||
{
|
||||
id: "event-types",
|
||||
name: "event_types_page_title",
|
||||
section: "event_types_page_title",
|
||||
shortcut: ["e", "t"],
|
||||
keywords: "event types",
|
||||
perform: () => router.push("/event-types"),
|
||||
},
|
||||
{
|
||||
id: "app-store",
|
||||
name: "app_store",
|
||||
section: "apps",
|
||||
shortcut: ["a", "s"],
|
||||
keywords: "app store",
|
||||
perform: () => router.push("/apps"),
|
||||
},
|
||||
{
|
||||
id: "upcoming-bookings",
|
||||
name: "upcoming",
|
||||
section: "bookings",
|
||||
shortcut: ["u", "b"],
|
||||
keywords: "upcoming bookings",
|
||||
perform: () => router.push("/bookings/upcoming"),
|
||||
},
|
||||
{
|
||||
id: "recurring-bookings",
|
||||
name: "recurring",
|
||||
section: "bookings",
|
||||
shortcut: ["r", "b"],
|
||||
keywords: "recurring bookings",
|
||||
perform: () => router.push("/bookings/recurring"),
|
||||
},
|
||||
{
|
||||
id: "past-bookings",
|
||||
name: "past",
|
||||
section: "bookings",
|
||||
shortcut: ["p", "b"],
|
||||
keywords: "past bookings",
|
||||
perform: () => router.push("/bookings/past"),
|
||||
},
|
||||
{
|
||||
id: "cancelled-bookings",
|
||||
name: "cancelled",
|
||||
section: "bookings",
|
||||
shortcut: ["c", "b"],
|
||||
keywords: "cancelled bookings",
|
||||
perform: () => router.push("/bookings/cancelled"),
|
||||
},
|
||||
{
|
||||
id: "schedule",
|
||||
name: "availability",
|
||||
section: "availability",
|
||||
shortcut: ["s", "a"],
|
||||
keywords: "schedule availability",
|
||||
perform: () => router.push("/availability"),
|
||||
},
|
||||
{
|
||||
id: "profile",
|
||||
name: "profile",
|
||||
section: "profile",
|
||||
shortcut: ["p", "s"],
|
||||
keywords: "setting profile",
|
||||
perform: () => router.push("/settings/my-account/profile"),
|
||||
},
|
||||
{
|
||||
id: "avatar",
|
||||
name: "change_avatar",
|
||||
section: "profile",
|
||||
shortcut: ["c", "a"],
|
||||
keywords: "remove change modify avatar",
|
||||
perform: () => router.push("/settings/my-account/profile"),
|
||||
},
|
||||
{
|
||||
id: "timezone",
|
||||
name: "timezone",
|
||||
section: "profile",
|
||||
shortcut: ["c", "t"],
|
||||
keywords: "change modify timezone",
|
||||
perform: () => router.push("/settings/my-account/general"),
|
||||
},
|
||||
{
|
||||
id: "brand-color",
|
||||
name: "brand_color",
|
||||
section: "profile",
|
||||
shortcut: ["b", "c"],
|
||||
keywords: "change modify brand color",
|
||||
perform: () => router.push("/settings/my-account/appearance"),
|
||||
},
|
||||
{
|
||||
id: "teams",
|
||||
name: "teams",
|
||||
shortcut: ["t", "s"],
|
||||
keywords: "add manage modify team",
|
||||
perform: () => router.push("/settings/teams"),
|
||||
},
|
||||
{
|
||||
id: "password",
|
||||
name: "change_password",
|
||||
section: "security",
|
||||
shortcut: ["c", "p"],
|
||||
keywords: "change modify password",
|
||||
perform: () => router.push("/settings/security/password"),
|
||||
},
|
||||
{
|
||||
id: "two-factor",
|
||||
name: "two_factor_auth",
|
||||
section: "security",
|
||||
shortcut: ["t", "f", "a"],
|
||||
keywords: "two factor authentication",
|
||||
perform: () => router.push("/settings/security/two-factor-auth"),
|
||||
},
|
||||
{
|
||||
id: "impersonation",
|
||||
name: "user_impersonation_heading",
|
||||
section: "security",
|
||||
shortcut: ["u", "i"],
|
||||
keywords: "user impersonation",
|
||||
perform: () => router.push("/settings/security/impersonation"),
|
||||
},
|
||||
{
|
||||
id: "license",
|
||||
name: "choose_a_license",
|
||||
section: "admin",
|
||||
shortcut: ["u", "l"],
|
||||
keywords: "license",
|
||||
perform: () => router.push("/auth/setup?step=1"),
|
||||
},
|
||||
{
|
||||
id: "webhooks",
|
||||
name: "Webhooks",
|
||||
section: "developer",
|
||||
shortcut: ["w", "h"],
|
||||
keywords: "webhook automation",
|
||||
perform: () => router.push("/settings/developer/webhooks"),
|
||||
},
|
||||
{
|
||||
id: "api-keys",
|
||||
name: "api_keys",
|
||||
section: "developer",
|
||||
shortcut: ["a", "p", "i"],
|
||||
keywords: "api keys",
|
||||
perform: () => router.push("/settings/developer/api-keys"),
|
||||
},
|
||||
{
|
||||
id: "billing",
|
||||
name: "manage_billing",
|
||||
section: "billing",
|
||||
shortcut: ["m", "b"],
|
||||
keywords: "billing view manage",
|
||||
perform: () => router.push("/settings/billing"),
|
||||
},
|
||||
...appStoreActions,
|
||||
];
|
||||
}, []);
|
||||
|
||||
return <KBarProvider actions={actions}>{children}</KBarProvider>;
|
||||
};
|
||||
|
||||
export const KBarContent = () => {
|
||||
const { t } = useLocale();
|
||||
useEventTypesAction();
|
||||
const [inputText, setInputText] = useState("");
|
||||
const [aiResponse, setAiResponse] = useState("");
|
||||
const showAiChat =
|
||||
process.env.NEXT_PUBLIC_ENABLE_MINTLIFY_CHAT === "true" && !!process.env.NEXT_PUBLIC_CHAT_API_URL;
|
||||
|
||||
return (
|
||||
<KBarPortal>
|
||||
<KBarPositioner className="overflow-scroll">
|
||||
<KBarAnimator className="bg-default max-w-(--breakpoint-sm) z-10 w-full overflow-hidden rounded-md shadow-lg">
|
||||
<div className="border-subtle flex items-center justify-center border-b">
|
||||
<Icon name="search" className="text-default mx-3 h-4 w-4" />
|
||||
<KBarSearch
|
||||
defaultPlaceholder={t("kbar_search_placeholder")}
|
||||
className="bg-default placeholder:text-subtle text-default w-full rounded-sm border-0 py-2.5 px-0 focus:ring-0 focus-visible:outline-none"
|
||||
value={inputText}
|
||||
onChange={(e) => {
|
||||
setInputText(e.currentTarget.value.trim());
|
||||
if (aiResponse) setAiResponse("");
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{showAiChat && inputText && (
|
||||
<MintlifyChat aiResponse={aiResponse} setAiResponse={setAiResponse} searchText={inputText} />
|
||||
)}
|
||||
<RenderResults />
|
||||
<div className="text-subtle border-subtle hidden items-center space-x-1 border-t px-2 py-1.5 text-xs sm:flex">
|
||||
<Icon name="arrow-up" className="h-4 w-4" />
|
||||
<Icon name="arrow-down" className="h-4 w-4" /> <span className="pr-2">{t("navigate")}</span>
|
||||
<Icon name="corner-down-left" className="h-4 w-4" />
|
||||
<span className="pr-2">{t("open")}</span>
|
||||
{isMac ? <Icon name="command" className="h-3 w-3" /> : "CTRL"}
|
||||
<span className="pr-1">+ K </span>
|
||||
<span className="pr-2">{t("close")}</span>
|
||||
</div>
|
||||
</KBarAnimator>
|
||||
<div className="z-1 fixed inset-0 bg-neutral-800/70" />
|
||||
</KBarPositioner>
|
||||
</KBarPortal>
|
||||
);
|
||||
};
|
||||
|
||||
export const KBarTrigger = () => {
|
||||
const { query } = useKBar();
|
||||
return query ? (
|
||||
<>
|
||||
<Tooltip side="right" content={isMac ? "⌘ + K" : "CTRL + K"}>
|
||||
<button
|
||||
color="minimal"
|
||||
onClick={query.toggle}
|
||||
className="text-default hover:bg-subtle todesktop:hover:!bg-transparent lg:hover:bg-emphasis lg:hover:text-emphasis group flex rounded-md px-3 py-2 text-sm font-medium transition lg:px-2">
|
||||
<Icon name="search" className="h-4 w-4 shrink-0 text-inherit" />
|
||||
</button>
|
||||
</Tooltip>
|
||||
</>
|
||||
) : null;
|
||||
};
|
||||
|
||||
const DisplayShortcuts = (item: shortcutArrayType) => {
|
||||
const shortcuts = item.shortcuts;
|
||||
|
||||
return (
|
||||
<span className="space-x-1">
|
||||
{shortcuts?.map((shortcut) => {
|
||||
return (
|
||||
<kbd
|
||||
key={shortcut}
|
||||
className="bg-default hover:bg-subtle text-emphasis rounded-sm border px-2 py-1 transition">
|
||||
{shortcut}
|
||||
</kbd>
|
||||
);
|
||||
})}
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
function RenderResults() {
|
||||
const { results } = useMatches();
|
||||
const { t } = useLocale();
|
||||
|
||||
return (
|
||||
<KBarResults
|
||||
items={results}
|
||||
onRender={({ item, active }) =>
|
||||
typeof item === "string" ? (
|
||||
<div className="bg-default text-emphasis p-4 text-xs font-bold uppercase">{t(item)}</div>
|
||||
) : (
|
||||
<div
|
||||
// For seeing keyboard up & down navigation in action, we need visual feedback based on "active" prop
|
||||
style={{
|
||||
background: active ? "var(--cal-bg-subtle)" : `var(--cal-bg-default)`,
|
||||
borderLeft: active ? "2px solid var(--cal-border)" : "2px solid transparent",
|
||||
color: "var(--cal-text)",
|
||||
}}
|
||||
className="flex items-center justify-between px-4 py-2.5 text-sm transition hover:cursor-pointer">
|
||||
<span>{t(item.name)}</span>
|
||||
<DisplayShortcuts shortcuts={item.shortcut} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
"use client";
|
||||
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import type { Dispatch, ReactElement, ReactNode, SetStateAction } from "react";
|
||||
import React, { cloneElement } from "react";
|
||||
import { Toaster } from "sonner";
|
||||
|
||||
import { useRedirectToLoginIfUnauthenticated } from "@calcom/features/auth/lib/hooks/useRedirectToLoginIfUnauthenticated";
|
||||
import { useRedirectToOnboardingIfNeeded } from "@calcom/features/auth/lib/hooks/useRedirectToOnboardingIfNeeded";
|
||||
import { useFormbricks } from "@calcom/features/formbricks/formbricks-client";
|
||||
import TimezoneChangeDialog from "@calcom/features/settings/TimezoneChangeDialog";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { ErrorBoundary } from "@calcom/ui/components/errorBoundary";
|
||||
import { SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
|
||||
import { DynamicModals } from "./DynamicModals";
|
||||
import { KBarContent, KBarRoot } from "./Kbar";
|
||||
import { SideBarContainer } from "./SideBar";
|
||||
import { TopNavContainer } from "./TopNav";
|
||||
import { BannerContainer } from "./banners/LayoutBanner";
|
||||
import { useBanners } from "./banners/useBanners";
|
||||
import { MobileNavigationContainer } from "./navigation/Navigation";
|
||||
import { useAppTheme } from "./useAppTheme";
|
||||
|
||||
const Layout = (props: LayoutProps) => {
|
||||
const { banners, bannersHeight } = useBanners();
|
||||
|
||||
useFormbricks();
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<Toaster position="bottom-right" />
|
||||
</div>
|
||||
|
||||
<TimezoneChangeDialog />
|
||||
<DynamicModals />
|
||||
|
||||
<div className="flex min-h-screen flex-col">
|
||||
{banners && !props.isPlatformUser && <BannerContainer banners={banners} />}
|
||||
|
||||
<div className="flex flex-1" data-testid="dashboard-shell">
|
||||
{props.SidebarContainer ? (
|
||||
cloneElement(props.SidebarContainer, { bannersHeight })
|
||||
) : (
|
||||
<SideBarContainer isPlatformUser={props.isPlatformUser} bannersHeight={bannersHeight} />
|
||||
)}
|
||||
<div className="flex w-0 flex-1 flex-col">
|
||||
<MainContainer {...props} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
type DrawerState = [isOpen: boolean, setDrawerOpen: Dispatch<SetStateAction<boolean>>];
|
||||
|
||||
export type LayoutProps = {
|
||||
centered?: boolean;
|
||||
title?: string;
|
||||
description?: string;
|
||||
heading?: ReactNode;
|
||||
subtitle?: ReactNode;
|
||||
headerClassName?: string;
|
||||
children: ReactNode;
|
||||
CTA?: ReactNode;
|
||||
large?: boolean;
|
||||
MobileNavigationContainer?: ReactNode;
|
||||
SidebarContainer?: ReactElement;
|
||||
TopNavContainer?: ReactNode;
|
||||
drawerState?: DrawerState;
|
||||
HeadingLeftIcon?: ReactNode;
|
||||
backPath?: string | boolean; // renders back button to specified path
|
||||
// use when content needs to expand with flex
|
||||
flexChildrenContainer?: boolean;
|
||||
isPublic?: boolean;
|
||||
withoutMain?: boolean;
|
||||
// Gives the ability to include actions to the right of the heading
|
||||
actions?: JSX.Element;
|
||||
beforeCTAactions?: JSX.Element;
|
||||
afterHeading?: ReactNode;
|
||||
smallHeading?: boolean;
|
||||
isPlatformUser?: boolean;
|
||||
};
|
||||
|
||||
const KBarWrapper = ({ children, withKBar = false }: { withKBar: boolean; children: React.ReactNode }) =>
|
||||
withKBar ? (
|
||||
<KBarRoot>
|
||||
{children}
|
||||
<KBarContent />
|
||||
</KBarRoot>
|
||||
) : (
|
||||
<>{children}</>
|
||||
);
|
||||
|
||||
const PublicShell = (props: LayoutProps) => {
|
||||
const { status } = useSession();
|
||||
return (
|
||||
<KBarWrapper withKBar={status === "authenticated"}>
|
||||
<Layout {...props} />
|
||||
</KBarWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export default function Shell(props: LayoutProps) {
|
||||
// if a page is unauthed and isPublic is true, the redirect does not happen.
|
||||
useRedirectToLoginIfUnauthenticated(props.isPublic);
|
||||
useRedirectToOnboardingIfNeeded();
|
||||
useAppTheme();
|
||||
|
||||
return !props.isPublic ? (
|
||||
<KBarWrapper withKBar>
|
||||
<Layout {...props} />
|
||||
</KBarWrapper>
|
||||
) : (
|
||||
<PublicShell {...props} />
|
||||
);
|
||||
}
|
||||
|
||||
export function ShellMain(props: LayoutProps) {
|
||||
const router = useRouter();
|
||||
const { isLocaleReady } = useLocale();
|
||||
|
||||
return (
|
||||
<>
|
||||
{(props.heading || !!props.backPath) && (
|
||||
<div
|
||||
className={classNames(
|
||||
"bg-default sticky top-0 z-10 mb-0 flex items-center md:mb-6 md:mt-0",
|
||||
props.smallHeading ? "lg:mb-7" : "lg:mb-8"
|
||||
)}>
|
||||
{!!props.backPath && (
|
||||
<Button
|
||||
variant="icon"
|
||||
size="sm"
|
||||
color="minimal"
|
||||
onClick={() =>
|
||||
typeof props.backPath === "string" ? router.push(props.backPath as string) : router.back()
|
||||
}
|
||||
StartIcon="arrow-left"
|
||||
aria-label="Go Back"
|
||||
className="rounded-md ltr:mr-2 rtl:ml-2"
|
||||
data-testid="go-back-button"
|
||||
/>
|
||||
)}
|
||||
{props.heading && (
|
||||
<header
|
||||
className={classNames(props.large && "py-8", "flex w-full max-w-full items-center truncate")}>
|
||||
{props.HeadingLeftIcon && <div className="ltr:mr-4">{props.HeadingLeftIcon}</div>}
|
||||
<div
|
||||
className={classNames("w-full truncate ltr:mr-4 rtl:ml-4 md:block", props.headerClassName)}>
|
||||
{props.heading && (
|
||||
<h3
|
||||
className={classNames(
|
||||
"font-cal text-emphasis max-w-28 sm:max-w-72 md:max-w-80 hidden truncate text-lg font-semibold tracking-wide sm:text-xl md:block xl:max-w-full",
|
||||
props.smallHeading ? "text-base" : "text-xl"
|
||||
)}>
|
||||
{!isLocaleReady ? <SkeletonText invisible /> : props.heading}
|
||||
</h3>
|
||||
)}
|
||||
{props.subtitle && (
|
||||
<p className="text-default hidden text-sm md:block" data-testid="subtitle">
|
||||
{!isLocaleReady ? <SkeletonText invisible /> : props.subtitle}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{props.beforeCTAactions}
|
||||
{props.CTA && (
|
||||
<div
|
||||
className={classNames(
|
||||
props.backPath
|
||||
? "relative"
|
||||
: "pwa:bottom-[max(7rem,_calc(5rem_+_env(safe-area-inset-bottom)))] fixed bottom-20 z-40 ltr:right-4 rtl:left-4 md:z-auto md:ltr:right-0 md:rtl:left-0",
|
||||
"shrink-0 [-webkit-app-region:no-drag] md:relative md:bottom-auto md:right-auto"
|
||||
)}>
|
||||
{isLocaleReady && props.CTA}
|
||||
</div>
|
||||
)}
|
||||
{props.actions && props.actions}
|
||||
</header>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{props.afterHeading && <>{props.afterHeading}</>}
|
||||
<div className={classNames(props.flexChildrenContainer && "flex flex-1 flex-col")}>
|
||||
{props.children}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function MainContainer({
|
||||
isPlatformUser,
|
||||
MobileNavigationContainer: MobileNavigationContainerProp = (
|
||||
<MobileNavigationContainer isPlatformNavigation={isPlatformUser} />
|
||||
),
|
||||
TopNavContainer: TopNavContainerProp = <TopNavContainer />,
|
||||
...props
|
||||
}: LayoutProps) {
|
||||
return (
|
||||
<main className="bg-default relative z-0 flex-1 pb-8 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">
|
||||
<ErrorBoundary>
|
||||
{!props.withoutMain ? <ShellMain {...props}>{props.children}</ShellMain> : props.children}
|
||||
</ErrorBoundary>
|
||||
{/* show bottom navigation for md and smaller (tablet and phones) on pages where back button doesn't exist */}
|
||||
{!props.backPath ? MobileNavigationContainerProp : null}
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
import type { User as UserAuth } from "next-auth";
|
||||
import { useSession } from "next-auth/react";
|
||||
import dynamic from "next/dynamic";
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
import { getBookerBaseUrlSync } from "@calcom/features/ee/organizations/lib/getBookerBaseUrlSync";
|
||||
import { IS_VISUAL_REGRESSION_TESTING, ENABLE_PROFILE_SWITCHER } from "@calcom/lib/constants";
|
||||
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { UserPermissionRole } from "@calcom/prisma/enums";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Avatar } from "@calcom/ui/components/avatar";
|
||||
import { Credits } from "@calcom/ui/components/credits";
|
||||
import { ButtonOrLink } from "@calcom/ui/components/dropdown";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { Logo } from "@calcom/ui/components/logo";
|
||||
import { SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
import { Tooltip } from "@calcom/ui/components/tooltip";
|
||||
|
||||
import { KBarTrigger } from "./Kbar";
|
||||
import { Navigation } from "./navigation/Navigation";
|
||||
import { useBottomNavItems } from "./useBottomNavItems";
|
||||
import { ProfileDropdown } from "./user-dropdown/ProfileDropdown";
|
||||
import { UserDropdown } from "./user-dropdown/UserDropdown";
|
||||
|
||||
// need to import without ssr to prevent hydration errors
|
||||
const Tips = dynamic(() => import("./Tips").then((mod) => mod.default), {
|
||||
ssr: false,
|
||||
});
|
||||
|
||||
export type SideBarContainerProps = {
|
||||
bannersHeight: number;
|
||||
isPlatformUser?: boolean;
|
||||
};
|
||||
|
||||
export type SideBarProps = {
|
||||
bannersHeight: number;
|
||||
user?: UserAuth | null;
|
||||
isPlatformUser?: boolean;
|
||||
};
|
||||
|
||||
export function SideBarContainer({ bannersHeight, isPlatformUser = false }: SideBarContainerProps) {
|
||||
const { status, data } = useSession();
|
||||
|
||||
// Make sure that Sidebar is rendered optimistically so that a refresh of pages when logged in have SideBar from the beginning.
|
||||
// This improves the experience of refresh on app store pages(when logged in) which are SSG.
|
||||
// Though when logged out, app store pages would temporarily show SideBar until session status is confirmed.
|
||||
if (status !== "loading" && status !== "authenticated") return null;
|
||||
return <SideBar isPlatformUser={isPlatformUser} bannersHeight={bannersHeight} user={data?.user} />;
|
||||
}
|
||||
|
||||
export function SideBar({ bannersHeight, user }: SideBarProps) {
|
||||
const session = useSession();
|
||||
const { t, isLocaleReady } = useLocale();
|
||||
const pathname = usePathname();
|
||||
const isPlatformPages = pathname?.startsWith("/settings/platform");
|
||||
const isAdmin = session.data?.user.role === UserPermissionRole.ADMIN;
|
||||
|
||||
const publicPageUrl = `${getBookerBaseUrlSync(user?.org?.slug ?? null)}/${user?.orgAwareUsername}`;
|
||||
|
||||
const bottomNavItems = useBottomNavItems({
|
||||
publicPageUrl,
|
||||
isAdmin,
|
||||
user,
|
||||
});
|
||||
|
||||
const sidebarStylingAttributes = {
|
||||
maxHeight: `calc(100vh - ${bannersHeight}px)`,
|
||||
top: `${bannersHeight}px`,
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="relative">
|
||||
<aside
|
||||
style={!isPlatformPages ? sidebarStylingAttributes : {}}
|
||||
className={classNames(
|
||||
"bg-cal-muted border-muted fixed left-0 hidden h-full w-14 flex-col overflow-y-auto overflow-x-hidden border-r md:sticky md:flex lg:w-56 lg:px-3",
|
||||
!isPlatformPages && "max-h-screen"
|
||||
)}>
|
||||
<div className="flex h-full flex-col justify-between py-3 lg:pt-4">
|
||||
<header className="todesktop:-mt-3 todesktop:flex-col-reverse todesktop:[-webkit-app-region:drag] items-center justify-between md:hidden lg:flex">
|
||||
{user?.org ? (
|
||||
!ENABLE_PROFILE_SWITCHER ? (
|
||||
<Link href="/settings/organizations/profile" className="w-full px-1.5">
|
||||
<div className="flex items-center gap-2 font-medium">
|
||||
<Avatar
|
||||
alt={`${user.org.name} logo`}
|
||||
imageSrc={getPlaceholderAvatar(user.org.logoUrl, user.org.name)}
|
||||
size="xsm"
|
||||
/>
|
||||
<p className="text line-clamp-1 text-sm">
|
||||
<span>{user.org.name}</span>
|
||||
</p>
|
||||
</div>
|
||||
</Link>
|
||||
) : (
|
||||
<ProfileDropdown />
|
||||
)
|
||||
) : (
|
||||
<div data-testid="user-dropdown-trigger" className="todesktop:mt-4 w-full">
|
||||
<span className="hidden lg:inline">
|
||||
<UserDropdown />
|
||||
</span>
|
||||
<span className="hidden md:inline lg:hidden">
|
||||
<UserDropdown small />
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
<div className="flex w-full justify-end rtl:space-x-reverse">
|
||||
<button
|
||||
color="minimal"
|
||||
onClick={() => window.history.back()}
|
||||
className="todesktop:block hover:text-emphasis text-subtle group hidden text-sm font-medium">
|
||||
<Icon name="arrow-left" className="group-hover:text-emphasis text-subtle h-4 w-4 shrink-0" />
|
||||
</button>
|
||||
<button
|
||||
color="minimal"
|
||||
onClick={() => window.history.forward()}
|
||||
className="todesktop:block hover:text-emphasis text-subtle group hidden text-sm font-medium">
|
||||
<Icon name="arrow-right" className="group-hover:text-emphasis text-subtle h-4 w-4 shrink-0" />
|
||||
</button>
|
||||
{!!user?.org && (
|
||||
<div data-testid="user-dropdown-trigger" className="flex items-center">
|
||||
<UserDropdown small />
|
||||
</div>
|
||||
)}
|
||||
<KBarTrigger />
|
||||
</div>
|
||||
</header>
|
||||
{/* logo icon for tablet */}
|
||||
<Link href="/event-types" className="text-center md:inline lg:hidden">
|
||||
<Logo small icon />
|
||||
</Link>
|
||||
<Navigation isPlatformNavigation={isPlatformPages} />
|
||||
</div>
|
||||
|
||||
{!isPlatformPages && (
|
||||
<div className="md:px-2 md:pb-4 lg:p-0">
|
||||
<div className="overflow-hidden">
|
||||
<Tips />
|
||||
</div>
|
||||
{bottomNavItems.map((item, index) => (
|
||||
<Tooltip side="right" content={t(item.name)} className="lg:hidden" key={item.name}>
|
||||
<ButtonOrLink
|
||||
id={item.name}
|
||||
href={item.href || undefined}
|
||||
aria-label={t(item.name)}
|
||||
target={item.target}
|
||||
className={classNames(
|
||||
"text-left",
|
||||
"[&[aria-current='page']]:bg-emphasis text-default justify-right group flex items-center rounded-md px-2 py-1.5 text-sm font-medium transition",
|
||||
"[&[aria-current='page']]:text-emphasis mt-0.5 w-full text-sm",
|
||||
isLocaleReady ? "hover:bg-subtle hover:text-emphasis" : "",
|
||||
index === 0 && "mt-3"
|
||||
)}
|
||||
onClick={item.onClick}>
|
||||
{!!item.icon && (
|
||||
<Icon
|
||||
name={item.isLoading ? "rotate-cw" : item.icon}
|
||||
className={classNames(
|
||||
"h-4 w-4 shrink-0 aria-[aria-current='page']:text-inherit",
|
||||
"ml-3 md:mx-auto lg:ltr:mr-2 lg:rtl:ml-2",
|
||||
item.isLoading && "animate-spin"
|
||||
)}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
)}
|
||||
{isLocaleReady ? (
|
||||
<span className="hidden w-full justify-between lg:flex">
|
||||
<div className="flex">{t(item.name)}</div>
|
||||
</span>
|
||||
) : (
|
||||
<SkeletonText className="h-[20px] w-full" />
|
||||
)}
|
||||
</ButtonOrLink>
|
||||
</Tooltip>
|
||||
))}
|
||||
{!IS_VISUAL_REGRESSION_TESTING && <Credits />}
|
||||
</div>
|
||||
)}
|
||||
</aside>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
import { useTeamInvites } from "@calcom/web/modules/billing/hooks/useHasPaidPlan";
|
||||
|
||||
export function TeamInviteBadge() {
|
||||
const { isPending, listInvites } = useTeamInvites();
|
||||
const { t } = useLocale();
|
||||
|
||||
if (isPending || !listInvites || listInvites.length === 0) return null;
|
||||
|
||||
return <Badge variant="default">{t("invite_team_notifcation_badge")}</Badge>;
|
||||
}
|
||||
@@ -0,0 +1,289 @@
|
||||
import shuffle from "lodash/shuffle";
|
||||
import posthog from "posthog-js";
|
||||
import { useState, memo } from "react";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { localStorage } from "@calcom/lib/webstorage";
|
||||
import { Card } from "@calcom/ui/components/card";
|
||||
|
||||
import { GatedFeatures } from "./stores/gatedFeaturesStore";
|
||||
import { useGatedFeaturesStore } from "./stores/gatedFeaturesStore";
|
||||
|
||||
type Tip = {
|
||||
id: number;
|
||||
thumbnailUrl: string;
|
||||
mediaLink?: string;
|
||||
title: string;
|
||||
description: string;
|
||||
href?: string;
|
||||
onClick?: () => void;
|
||||
coverPhoto?: string;
|
||||
variant?: "SidebarCard" | "NewLaunchSidebarCard";
|
||||
};
|
||||
|
||||
function Tips() {
|
||||
const { t } = useLocale();
|
||||
const openModal = useGatedFeaturesStore((state) => state.open);
|
||||
|
||||
const tips: Tip[] = [
|
||||
{
|
||||
id: 18,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/J8HsK-8W39U/0.jpg",
|
||||
mediaLink: "https://go.cal.com/rbac-video",
|
||||
title: "Roles & Permissions",
|
||||
description: "Manage team access with roles & permissions",
|
||||
onClick: () => openModal(GatedFeatures.RolesAndPermissions),
|
||||
},
|
||||
{
|
||||
id: 17,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/fMHW6jYPIb8/0.jpg",
|
||||
mediaLink: "https://go.cal.com/embed-video",
|
||||
title: "Embed",
|
||||
description: "Embed your booking page on your website",
|
||||
href: "https://go.cal.com/embed-video",
|
||||
},
|
||||
{
|
||||
id: 16,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/xopxmk2H4Ng/0.jpg",
|
||||
mediaLink: "https://go.cal.com/paid-booking",
|
||||
title: "Paid Bookings",
|
||||
description: "Charge for your time with Cal.com's paid bookings",
|
||||
href: "https://go.cal.com/paid-booking",
|
||||
},
|
||||
{
|
||||
id: 15,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/ZjSD1yPgLLQ/0.jpg",
|
||||
mediaLink: "https://go.cal.com/instant-meetings-video",
|
||||
title: "Instant Meetings",
|
||||
description: "Book meetings instantly with a link",
|
||||
href: "https://go.cal.com/instant-meetings-video",
|
||||
},
|
||||
{
|
||||
id: 14,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/IZ4-nUiIpvY/0.jpg",
|
||||
mediaLink: "https://go.cal.com/custom-attributes",
|
||||
title: "Custom Attributes",
|
||||
description: "Define roles and attributes for your teams",
|
||||
href: "https://go.cal.com/custom-attributes",
|
||||
},
|
||||
{
|
||||
id: 13,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/TTAASLLPKk0/0.jpg",
|
||||
mediaLink: "https://go.cal.com/ooo-video",
|
||||
title: "ooo.new",
|
||||
description: "Easily go out-of-office",
|
||||
href: "https://go.cal.com/ooo-video",
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
thumbnailUrl: "https://cal.com/og-image-cal-ai.jpg",
|
||||
mediaLink: "https://go.cal.com/cal-ai",
|
||||
title: "Cal.ai",
|
||||
description: "Your personal AI scheduling assistant",
|
||||
href: "https://go.cal.com/cal-ai",
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/KTg_qzA9NEc/0.jpg",
|
||||
mediaLink: "https://go.cal.com/insights",
|
||||
title: "Insights",
|
||||
description: "Get a better understanding of your business",
|
||||
href: "https://go.cal.com/insights",
|
||||
},
|
||||
{
|
||||
id: 10,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/jvaBafzVUQc/0.jpg",
|
||||
mediaLink: "https://go.cal.com/video",
|
||||
title: "Cal Video",
|
||||
description: "Free video conferencing with recording",
|
||||
href: "https://go.cal.com/video",
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/93iOmzHieCU/0.jpg",
|
||||
mediaLink: "https://go.cal.com/round-robin",
|
||||
title: "Round-Robin",
|
||||
description: "Create advanced group meetings with round-robin",
|
||||
href: "https://go.cal.com/round-robin",
|
||||
},
|
||||
{
|
||||
id: 8,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/piKlAiibAFo/0.jpg",
|
||||
mediaLink: "https://go.cal.com/workflows",
|
||||
title: "Automate Workflows",
|
||||
description: "Make time work for you and automate tasks",
|
||||
href: "https://go.cal.com/workflows",
|
||||
},
|
||||
{
|
||||
id: 7,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/UVXgo12cY4g/0.jpg",
|
||||
mediaLink: "https://go.cal.com/routing-forms",
|
||||
title: "Routing Forms",
|
||||
description: "Ask questions and route to the correct person",
|
||||
href: "https://go.cal.com/routing-forms",
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/yGiZo1Ry5-8/0.jpg",
|
||||
mediaLink: "https://go.cal.com/recurring-video",
|
||||
title: "Recurring Bookings",
|
||||
description: "Learn how to create a recurring schedule",
|
||||
href: "https://go.cal.com/recurring-video",
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/0v_nQtpxC_4/0.jpg",
|
||||
mediaLink: "https://go.cal.com/payments-video",
|
||||
title: "Accept Payments",
|
||||
description: "Charge for your time with Cal.com's Stripe App",
|
||||
href: "https://app.cal.com/apps/stripe",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/zGr_s-fG84k/0.jpg",
|
||||
mediaLink: "https://go.cal.com/confirmation-video",
|
||||
title: "Requires Confirmation",
|
||||
description: "Learn how to be in charge of your bookings",
|
||||
href: "https://cal.com/resources/feature/opt-in",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/-L8MCiT6uhQ/0.jpg",
|
||||
mediaLink: "https://youtu.be/-L8MCiT6uhQ?si=DRJzRNhN85hqAwBl",
|
||||
title: "Routing Forms, Workflows",
|
||||
description: "Ask screening questions of potential bookers to connect them with the right person",
|
||||
href: "https://youtu.be/-L8MCiT6uhQ?si=DRJzRNhN85hqAwBl",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/EAc46SPL6iA/0.jpg",
|
||||
mediaLink: "https://go.cal.com/teams-video",
|
||||
title: "How to set up Teams",
|
||||
description: "Learn how to use round-robin and collective events.",
|
||||
href: "https://cal.com/teams",
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
thumbnailUrl: "https://img.youtube.com/vi/VZ5PfQzzxBw/0.jpg",
|
||||
mediaLink: "https://youtu.be/VZ5PfQzzxBw?si=oB0LPSxG8dWIwg5a",
|
||||
title: "Dynamic booking links",
|
||||
description: "Booking link that allows people to quickly schedule meetings.",
|
||||
href: "https://youtu.be/VZ5PfQzzxBw?si=oB0LPSxG8dWIwg5a",
|
||||
},
|
||||
];
|
||||
|
||||
const reversedTips = [...shuffle(tips).slice(0).reverse()];
|
||||
|
||||
const [list, setList] = useState<Tip[]>(() => {
|
||||
if (typeof window === "undefined") {
|
||||
return reversedTips;
|
||||
}
|
||||
try {
|
||||
const removedTipsString = localStorage.getItem("removedTipsIds");
|
||||
if (removedTipsString !== null) {
|
||||
const removedTipsIds = removedTipsString.split(",").map((id) => parseInt(id, 10));
|
||||
const filteredTips = reversedTips.filter((tip) => removedTipsIds.indexOf(tip.id) === -1);
|
||||
return filteredTips;
|
||||
} else {
|
||||
return reversedTips;
|
||||
}
|
||||
} catch {
|
||||
return reversedTips;
|
||||
}
|
||||
});
|
||||
|
||||
const handleRemoveItem = (id: number) => {
|
||||
setList((currentItems) => {
|
||||
const items = localStorage.getItem("removedTipsIds") || "";
|
||||
const itemToRemoveIndex = currentItems.findIndex((item) => item.id === id);
|
||||
|
||||
if (itemToRemoveIndex === -1) return [...currentItems];
|
||||
|
||||
localStorage.setItem(
|
||||
"removedTipsIds",
|
||||
`${currentItems[itemToRemoveIndex].id.toString()}${items.length > 0 ? `,${items}` : ""}`
|
||||
);
|
||||
currentItems.splice(itemToRemoveIndex, 1);
|
||||
return [...currentItems];
|
||||
});
|
||||
};
|
||||
|
||||
const baseOriginalList = list.slice(0).reverse();
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className="hidden pb-4 pt-8 lg:grid"
|
||||
/* ref={animationRef} */
|
||||
style={{
|
||||
gridTemplateColumns: "1fr",
|
||||
}}>
|
||||
{list.map((tip) => {
|
||||
const isTopTip = baseOriginalList.indexOf(tip) === 0;
|
||||
return (
|
||||
<div
|
||||
className="relative"
|
||||
style={{
|
||||
gridRowStart: 1,
|
||||
gridColumnStart: 1,
|
||||
}}
|
||||
key={tip.id}>
|
||||
<div
|
||||
className="relative"
|
||||
style={{
|
||||
transform: `scale(${1 - baseOriginalList.indexOf(tip) / 20})`,
|
||||
top: -baseOriginalList.indexOf(tip) * 10,
|
||||
opacity: `${1 - baseOriginalList.indexOf(tip) / 7}`,
|
||||
}}>
|
||||
<Card
|
||||
variant={tip.variant ?? "SidebarCard"}
|
||||
thumbnailUrl={tip.thumbnailUrl}
|
||||
coverPhoto={tip.coverPhoto}
|
||||
mediaLink={isTopTip ? tip.mediaLink : undefined}
|
||||
mediaLinkOnClick={
|
||||
isTopTip
|
||||
? () => {
|
||||
posthog.capture("tip_video_clicked", tip);
|
||||
if (tip.onClick) tip.onClick();
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
title={t(tip.title)}
|
||||
description={t(tip.description)}
|
||||
learnMore={
|
||||
isTopTip
|
||||
? {
|
||||
href: tip.href,
|
||||
text: t("learn_more"),
|
||||
onClick: () => {
|
||||
posthog.capture("tip_learn_more_clicked", tip);
|
||||
if (tip.onClick) tip.onClick();
|
||||
},
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
actionButton={
|
||||
isTopTip
|
||||
? {
|
||||
onClick: () => {
|
||||
posthog.capture("tip_dismiss_clicked", tip);
|
||||
handleRemoveItem(tip.id);
|
||||
},
|
||||
child: t("dismiss"),
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
containerProps={{
|
||||
tabIndex: isTopTip ? undefined : -1,
|
||||
"aria-hidden": isTopTip ? undefined : "true",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default memo(Tips);
|
||||
@@ -0,0 +1,44 @@
|
||||
import { useSession } from "next-auth/react";
|
||||
import Link from "next/link";
|
||||
|
||||
import { useIsEmbed } from "@calcom/embed-core/embed-iframe";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { Logo } from "@calcom/ui/components/logo";
|
||||
|
||||
import { KBarTrigger } from "./Kbar";
|
||||
import { UserDropdown } from "./user-dropdown/UserDropdown";
|
||||
|
||||
export function TopNavContainer() {
|
||||
const { status } = useSession();
|
||||
if (status !== "authenticated") return null;
|
||||
return <TopNav />;
|
||||
}
|
||||
|
||||
function TopNav() {
|
||||
const isEmbed = useIsEmbed();
|
||||
const { t } = useLocale();
|
||||
return (
|
||||
<>
|
||||
<nav
|
||||
style={isEmbed ? { display: "none" } : {}}
|
||||
className="bg-cal-muted/50 border-subtle sticky top-0 z-40 flex w-full items-center justify-between border-b px-4 py-1.5 backdrop-blur-lg sm:p-4 md:hidden">
|
||||
<Link href="/event-types">
|
||||
<Logo />
|
||||
</Link>
|
||||
<div className="flex items-center gap-2 self-center">
|
||||
<span className="hover:bg-cal-muted hover:text-emphasis text-default group flex items-center rounded-full text-sm font-medium transition lg:hidden">
|
||||
<KBarTrigger />
|
||||
</span>
|
||||
<button className="hover:bg-cal-muted hover:text-subtle text-muted rounded-full p-1 transition focus:outline-none focus:ring-2 focus:ring-black focus:ring-offset-2">
|
||||
<span className="sr-only">{t("settings")}</span>
|
||||
<Link href="/settings/my-account/profile">
|
||||
<Icon name="settings" className="text-default h-4 w-4" aria-hidden="true" />
|
||||
</Link>
|
||||
</button>
|
||||
<UserDropdown small />
|
||||
</div>
|
||||
</nav>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
import { useGetTheme } from "@calcom/lib/hooks/useTheme";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { useHasTeamPlan } from "@calcom/web/modules/billing/hooks/useHasPaidPlan";
|
||||
|
||||
export function UpgradeTip({
|
||||
title,
|
||||
description,
|
||||
background,
|
||||
features,
|
||||
buttons,
|
||||
isParentLoading,
|
||||
children,
|
||||
plan,
|
||||
}: {
|
||||
title: string;
|
||||
description: string;
|
||||
/* overwrite EmptyScreen text */
|
||||
background: string;
|
||||
features: Array<{ icon: JSX.Element; title: string; description: string }>;
|
||||
buttons?: JSX.Element;
|
||||
/**Chldren renders when the user is in a team */
|
||||
children: ReactNode;
|
||||
isParentLoading?: ReactNode;
|
||||
plan: "team" | "enterprise";
|
||||
}) {
|
||||
const { resolvedTheme } = useGetTheme();
|
||||
const { isPending, hasTeamPlan } = useHasTeamPlan();
|
||||
const { data } = trpc.viewer.teams.getUpgradeable.useQuery();
|
||||
const imageSrc = `${background}${resolvedTheme === "dark" ? "-dark" : ""}.jpg`;
|
||||
|
||||
const hasEnterprisePlan = false;
|
||||
//const { isPending , hasEnterprisePlan } = useHasEnterprisePlan();
|
||||
|
||||
const hasUnpublishedTeam = !!data?.[0];
|
||||
|
||||
if (plan === "team" && (hasTeamPlan || hasUnpublishedTeam)) return <>{children}</>;
|
||||
|
||||
if (plan === "enterprise" && hasEnterprisePlan) return <>{children}</>;
|
||||
|
||||
if (isPending) return <>{isParentLoading}</>;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="relative flex min-h-[295px] w-full items-center justify-between overflow-hidden rounded-lg pb-10">
|
||||
<picture className="absolute min-h-[295px] w-full rounded-lg object-cover">
|
||||
<source srcSet={imageSrc} media="(prefers-color-scheme: dark)" />
|
||||
<img
|
||||
className="absolute min-h-[295px] w-full select-none rounded-lg object-cover object-left md:object-center"
|
||||
src={imageSrc}
|
||||
loading="lazy"
|
||||
alt={title}
|
||||
/>
|
||||
</picture>
|
||||
<div className="relative my-4 px-8 pb-4 sm:px-14">
|
||||
<h1 className={classNames("font-cal mt-4 text-3xl")}>{title}</h1>
|
||||
<p className={classNames("mb-8 mt-4 max-w-sm")}>{description}</p>
|
||||
{buttons}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-4 grid-cols-3 md:grid md:gap-4">
|
||||
{features.map((feature) => (
|
||||
<div key={feature.title} className="bg-cal-muted mb-4 min-h-[180px] w-full rounded-md p-8 md:mb-0">
|
||||
{feature.icon}
|
||||
<h2 className="font-cal text-emphasis mt-4 text-lg">{feature.title}</h2>
|
||||
<p className="text-default">{feature.description}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import ImpersonatingBanner, {
|
||||
type ImpersonatingBannerProps,
|
||||
} from "@calcom/features/ee/impersonation/components/ImpersonatingBanner";
|
||||
import {
|
||||
OrgUpgradeBanner,
|
||||
type OrgUpgradeBannerProps,
|
||||
} from "@calcom/features/ee/organizations/components/OrgUpgradeBanner";
|
||||
import {
|
||||
TeamsUpgradeBanner,
|
||||
type TeamsUpgradeBannerProps,
|
||||
} from "@calcom/web/modules/ee/teams/components/TeamsUpgradeBanner";
|
||||
import AdminPasswordBanner, {
|
||||
type AdminPasswordBannerProps,
|
||||
} from "@calcom/web/modules/users/components/AdminPasswordBanner";
|
||||
import CalendarCredentialBanner, {
|
||||
type CalendarCredentialBannerProps,
|
||||
} from "@calcom/web/modules/users/components/CalendarCredentialBanner";
|
||||
import {
|
||||
InvalidAppCredentialBanners,
|
||||
type InvalidAppCredentialBannersProps,
|
||||
} from "@calcom/web/modules/users/components/InvalidAppCredentialsBanner";
|
||||
import VerifyEmailBanner, {
|
||||
type VerifyEmailBannerProps,
|
||||
} from "@calcom/web/modules/users/components/VerifyEmailBanner";
|
||||
|
||||
type BannerTypeProps = {
|
||||
teamUpgradeBanner: TeamsUpgradeBannerProps;
|
||||
orgUpgradeBanner: OrgUpgradeBannerProps;
|
||||
verifyEmailBanner: VerifyEmailBannerProps;
|
||||
adminPasswordBanner: AdminPasswordBannerProps;
|
||||
impersonationBanner: ImpersonatingBannerProps;
|
||||
calendarCredentialBanner: CalendarCredentialBannerProps;
|
||||
invalidAppCredentialBanners: InvalidAppCredentialBannersProps;
|
||||
};
|
||||
|
||||
type BannerType = keyof BannerTypeProps;
|
||||
|
||||
type BannerComponent = {
|
||||
[Key in BannerType]: (props: BannerTypeProps[Key]) => JSX.Element;
|
||||
};
|
||||
|
||||
export type AllBannerProps = { [Key in BannerType]: BannerTypeProps[Key]["data"] };
|
||||
|
||||
export const BannerComponent: BannerComponent = {
|
||||
teamUpgradeBanner: (props: TeamsUpgradeBannerProps) => <TeamsUpgradeBanner {...props} />,
|
||||
orgUpgradeBanner: (props: OrgUpgradeBannerProps) => <OrgUpgradeBanner {...props} />,
|
||||
verifyEmailBanner: (props: VerifyEmailBannerProps) => <VerifyEmailBanner {...props} />,
|
||||
adminPasswordBanner: (props: AdminPasswordBannerProps) => <AdminPasswordBanner {...props} />,
|
||||
impersonationBanner: (props: ImpersonatingBannerProps) => <ImpersonatingBanner {...props} />,
|
||||
calendarCredentialBanner: (props: CalendarCredentialBannerProps) => <CalendarCredentialBanner {...props} />,
|
||||
invalidAppCredentialBanners: (props: InvalidAppCredentialBannersProps) => (
|
||||
<InvalidAppCredentialBanners {...props} />
|
||||
),
|
||||
};
|
||||
|
||||
interface BannerContainerProps {
|
||||
banners: AllBannerProps;
|
||||
}
|
||||
|
||||
export const BannerContainer: React.FC<BannerContainerProps> = ({ banners }) => {
|
||||
return (
|
||||
<div className="sticky top-0 z-10 w-full divide-y divide-black">
|
||||
{Object.keys(banners).map((key) => {
|
||||
if (key === "teamUpgradeBanner") {
|
||||
const Banner = BannerComponent[key];
|
||||
return <Banner data={banners[key]} key={key} />;
|
||||
} else if (key === "orgUpgradeBanner") {
|
||||
const Banner = BannerComponent[key];
|
||||
return <Banner data={banners[key]} key={key} />;
|
||||
} else if (key === "verifyEmailBanner") {
|
||||
const Banner = BannerComponent[key];
|
||||
return <Banner data={banners[key]} key={key} />;
|
||||
} else if (key === "adminPasswordBanner") {
|
||||
const Banner = BannerComponent[key];
|
||||
return <Banner data={banners[key]} key={key} />;
|
||||
} else if (key === "impersonationBanner") {
|
||||
const Banner = BannerComponent[key];
|
||||
return <Banner data={banners[key]} key={key} />;
|
||||
} else if (key === "calendarCredentialBanner") {
|
||||
const Banner = BannerComponent[key];
|
||||
return <Banner data={banners[key]} key={key} />;
|
||||
} else if (key === "invalidAppCredentialBanners") {
|
||||
const Banner = BannerComponent[key];
|
||||
return <Banner data={banners[key]} key={key} />;
|
||||
}
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
"use client";
|
||||
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { TOP_BANNER_HEIGHT } from "@calcom/lib/constants";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
|
||||
import { type AllBannerProps } from "./LayoutBanner";
|
||||
|
||||
const useBannersInternal = () => {
|
||||
const { data: getUserTopBanners, isPending } = trpc.viewer.me.getUserTopBanners.useQuery();
|
||||
const { data: userSession } = useSession();
|
||||
|
||||
if (isPending || !userSession) return null;
|
||||
|
||||
const isUserInactiveAdmin = userSession?.user.role === "INACTIVE_ADMIN";
|
||||
const userImpersonatedByUID = userSession?.user.impersonatedBy?.id;
|
||||
|
||||
const userSessionBanners = {
|
||||
adminPasswordBanner: isUserInactiveAdmin ? userSession : null,
|
||||
impersonationBanner: userImpersonatedByUID ? userSession : null,
|
||||
};
|
||||
|
||||
const allBanners: AllBannerProps = Object.assign({}, getUserTopBanners, userSessionBanners);
|
||||
|
||||
return allBanners;
|
||||
};
|
||||
|
||||
const useBannersHeight = (banners: AllBannerProps | null) => {
|
||||
const bannersHeight = useMemo(() => {
|
||||
const activeBanners =
|
||||
banners &&
|
||||
Object.entries(banners).filter(([_, value]) => {
|
||||
return value && (!Array.isArray(value) || value.length > 0);
|
||||
});
|
||||
return (activeBanners?.length ?? 0) * TOP_BANNER_HEIGHT;
|
||||
}, [banners]);
|
||||
|
||||
return bannersHeight;
|
||||
};
|
||||
|
||||
const useBanners = () => {
|
||||
const banners = useBannersInternal();
|
||||
const bannersHeight = useBannersHeight(banners);
|
||||
return { banners, bannersHeight };
|
||||
};
|
||||
|
||||
export { useBanners, useBannersHeight };
|
||||
@@ -0,0 +1,77 @@
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Dialog, DialogContent } from "@calcom/ui/components/dialog";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
|
||||
import { useGatedFeaturesStore, GatedFeatures } from "../stores/gatedFeaturesStore";
|
||||
|
||||
type FeatureContent = {
|
||||
badgeText: string;
|
||||
title: string;
|
||||
image: string;
|
||||
description: string;
|
||||
features: string[];
|
||||
learnMoreUrl: string;
|
||||
ctaUrl: string;
|
||||
};
|
||||
|
||||
const content: Record<GatedFeatures, FeatureContent> = {
|
||||
roles_and_permissions: {
|
||||
badgeText: "roles_and_permissions",
|
||||
title: "only_available_on_orgs_plan",
|
||||
image: "/gated-features/roles_and_permissions.svg",
|
||||
description: "upgrade_team_to_orgs_with_price",
|
||||
features: [
|
||||
"1_parent_team_unlimited_subteams",
|
||||
"attribute_based_routing",
|
||||
"compliance_check",
|
||||
"and_more_features",
|
||||
],
|
||||
learnMoreUrl: "https://cal.com/enterprise",
|
||||
ctaUrl: "/settings/organizations/new",
|
||||
},
|
||||
};
|
||||
|
||||
export function GatedFeaturesModal() {
|
||||
const { t } = useLocale();
|
||||
const isOpen = useGatedFeaturesStore((state) => state.isOpen);
|
||||
const activeFeature = useGatedFeaturesStore((state) => state.activeFeature);
|
||||
const close = useGatedFeaturesStore((state) => state.close);
|
||||
|
||||
const data = activeFeature ? content[activeFeature] : null;
|
||||
|
||||
if (!data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { badgeText, description, image, title, features, learnMoreUrl, ctaUrl } = data;
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={(open) => !open && close()}>
|
||||
<DialogContent className="p-0!" style={{ maxWidth: "400px" }}>
|
||||
<div className="p-6">
|
||||
<img src={image} alt={t(title)} className="w-full h-36 mb-5" />
|
||||
<div className="p-1 text-xs bg-emphasis rounded-md w-fit mb-3 leading-3">{t(badgeText)}</div>
|
||||
|
||||
<div className="mb-5 flex flex-col gap-2">
|
||||
<div className="text-xl font-semibold text-emphasis leading-6">{t(title)}</div>
|
||||
<div className="text-sm leading-5 font-normal text-default">{t(description)}</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1 ml-6">
|
||||
<ul className="list-disc">
|
||||
{features.map((feature) => (
|
||||
<li className="text-sm text-default font-medium" key={feature}>{t(feature)}</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-full bg-muted border-subtle flex items-center justify-between rounded-b-2xl border-t px-6 py-5">
|
||||
<Button color="minimal" onClick={close}>{t("dismiss")}</Button>
|
||||
<div className="flex gap-2">
|
||||
<Button color="secondary" target="_blank" rel="noopener noreferrer" href={learnMoreUrl}>{t("learn_more")}</Button>
|
||||
<Button color="primary" href={ctaUrl}>{t("upgrade")}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
"use client";
|
||||
|
||||
import { APP_NAME } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Button } from "@calcom/ui/components/button";
|
||||
import { Dialog, DialogContent } from "@calcom/ui/components/dialog";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import { Logo } from "@calcom/ui/components/logo";
|
||||
|
||||
import { useWelcomeToCalcomModal } from "../hooks/useWelcomeToCalcomModal";
|
||||
|
||||
const features = [
|
||||
"unlimited_calendars",
|
||||
"unlimited_event_types",
|
||||
"workflows_feature",
|
||||
"integrate_with_favorite_apps",
|
||||
"accept_payments_via_stripe",
|
||||
"html_react_embed",
|
||||
"cal_ai_phone_agent",
|
||||
"cal_video",
|
||||
];
|
||||
|
||||
export function WelcomeToCalcomModal() {
|
||||
const { t } = useLocale();
|
||||
const { isOpen, closeModal } = useWelcomeToCalcomModal();
|
||||
|
||||
const LARGE = { outer: 48, icon: 24 };
|
||||
const RINGS = [60, 95, 130]; // Ring radii in px
|
||||
const RING_STROKE = 1;
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={(open) => !open && closeModal()}>
|
||||
<DialogContent size="default" className="!p-0">
|
||||
<div className="flex flex-col gap-4 p-6">
|
||||
<div className="flex flex-col items-center gap-1">
|
||||
<Logo className="h-10 w-auto" />
|
||||
</div>
|
||||
|
||||
{/* User illustration with rings */}
|
||||
<div
|
||||
className="relative mx-auto"
|
||||
style={{
|
||||
width: 320,
|
||||
height: 220,
|
||||
maskImage: "radial-gradient(ellipse 100% 60% at center, black 30%, transparent 85%)",
|
||||
WebkitMaskImage: "radial-gradient(ellipse 100% 60% at center, black 30%, transparent 85%)",
|
||||
}}>
|
||||
{/* Center origin */}
|
||||
<div className="absolute left-1/2 top-1/2" style={{ transform: "translate(-50%, -50%)" }}>
|
||||
{/* Rings */}
|
||||
{RINGS.map((r, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className="pointer-events-none absolute rounded-full border"
|
||||
style={{
|
||||
width: 2 * r,
|
||||
height: 2 * r,
|
||||
left: `calc(50% - ${r}px)`,
|
||||
top: `calc(50% - ${r}px)`,
|
||||
borderWidth: RING_STROKE,
|
||||
borderColor: "var(--cal-border-subtle)",
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
|
||||
{/* Central user icon */}
|
||||
<div
|
||||
className="from-default to-muted border-subtle absolute flex items-center justify-center rounded-full border bg-gradient-to-b shadow-sm"
|
||||
style={{
|
||||
width: LARGE.outer,
|
||||
height: LARGE.outer,
|
||||
left: "50%",
|
||||
top: "50%",
|
||||
transform: "translate(-50%, -50%)",
|
||||
}}>
|
||||
<Icon
|
||||
name="user"
|
||||
className="text-emphasis opacity-70"
|
||||
style={{ width: LARGE.icon, height: LARGE.icon }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mb-2 flex flex-col gap-2 text-center">
|
||||
<h2 className="font-cal text-emphasis text-2xl leading-none">
|
||||
{t("welcome_to_calcom", { appName: APP_NAME })}
|
||||
</h2>
|
||||
<p className="text-default text-sm leading-normal">{t("personal_welcome_description")}</p>
|
||||
</div>
|
||||
|
||||
<div className="mb-2 flex flex-col gap-3">
|
||||
{features.map((feature) => (
|
||||
<div key={feature} className="flex items-start gap-2">
|
||||
<Icon name="check" className="text-muted mt-0.5 h-4 w-4 shrink-0" />
|
||||
<span className="text-default text-sm font-medium leading-tight">{t(feature)}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-muted border-subtle mt-6 flex items-center justify-between rounded-b-2xl border-t px-8 py-6">
|
||||
<Button
|
||||
color="minimal"
|
||||
href="https://cal.com/docs"
|
||||
target="_blank"
|
||||
EndIcon="external-link"
|
||||
className="pointer-events-none opacity-0">
|
||||
{t("learn_more")}
|
||||
</Button>
|
||||
<Button color="primary" onClick={closeModal}>
|
||||
{t("continue")}
|
||||
</Button>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import { parseAsBoolean, useQueryState } from "nuqs";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { sessionStorage } from "@calcom/lib/webstorage";
|
||||
|
||||
const STORAGE_KEY = "showWelcomeToCalcomModal";
|
||||
const ORG_MODAL_STORAGE_KEY = "showNewOrgModal";
|
||||
|
||||
export function useWelcomeToCalcomModal() {
|
||||
const [welcomeToCalcomModal, setWelcomeToCalcomModal] = useQueryState(
|
||||
"welcomeToCalcomModal",
|
||||
parseAsBoolean.withDefault(false)
|
||||
);
|
||||
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
// Don't show personal modal if org modal flag is set (org modal takes precedence)
|
||||
const hasOrgModalFlag = sessionStorage.getItem(ORG_MODAL_STORAGE_KEY) === "true";
|
||||
if (hasOrgModalFlag) {
|
||||
setIsOpen(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (welcomeToCalcomModal) {
|
||||
setIsOpen(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sessionStorage.getItem(STORAGE_KEY) === "true") {
|
||||
setIsOpen(true);
|
||||
}
|
||||
}, [welcomeToCalcomModal]);
|
||||
|
||||
const closeModal = () => {
|
||||
setIsOpen(false);
|
||||
// Remove the query param from URL
|
||||
setWelcomeToCalcomModal(null);
|
||||
// Also clear sessionStorage
|
||||
sessionStorage.removeItem(STORAGE_KEY);
|
||||
};
|
||||
|
||||
return {
|
||||
isOpen,
|
||||
closeModal,
|
||||
};
|
||||
}
|
||||
|
||||
export function setShowWelcomeToCalcomModalFlag() {
|
||||
sessionStorage.setItem(STORAGE_KEY, "true");
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { useIsEmbed } from "@calcom/embed-core/embed-iframe";
|
||||
import {
|
||||
useOrgBranding,
|
||||
type OrganizationBranding,
|
||||
} from "@calcom/features/ee/organizations/context/provider";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { useHasPaidPlan } from "@calcom/web/modules/billing/hooks/useHasPaidPlan";
|
||||
|
||||
import UnconfirmedBookingBadge from "../../bookings/components/UnconfirmedBookingBadge";
|
||||
import { KBarTrigger } from "../Kbar";
|
||||
import { TeamInviteBadge } from "../TeamInviteBadge";
|
||||
import type { NavigationItemType } from "./NavigationItem";
|
||||
import { NavigationItem, MobileNavigationItem, MobileNavigationMoreItem } from "./NavigationItem";
|
||||
|
||||
export const MORE_SEPARATOR_NAME = "more";
|
||||
|
||||
const getNavigationItems = (
|
||||
orgBranding: OrganizationBranding,
|
||||
hasInsightsAccess: boolean
|
||||
): NavigationItemType[] => [
|
||||
{
|
||||
name: "event_types_page_title",
|
||||
href: "/event-types",
|
||||
icon: "link",
|
||||
},
|
||||
{
|
||||
name: "bookings",
|
||||
href: "/bookings/upcoming",
|
||||
icon: "calendar",
|
||||
badge: <UnconfirmedBookingBadge />,
|
||||
isCurrent: ({ pathname }) => pathname?.startsWith("/bookings") ?? false,
|
||||
},
|
||||
{
|
||||
name: "availability",
|
||||
href: "/availability",
|
||||
icon: "clock",
|
||||
},
|
||||
...(orgBranding
|
||||
? [
|
||||
{
|
||||
name: "members",
|
||||
href: `/settings/organizations/${orgBranding.slug}/members`,
|
||||
icon: "building",
|
||||
moreOnMobile: true,
|
||||
} satisfies NavigationItemType,
|
||||
]
|
||||
: []),
|
||||
{
|
||||
name: "teams",
|
||||
href: "/teams",
|
||||
icon: "users",
|
||||
badge: <TeamInviteBadge />,
|
||||
moreOnMobile: true,
|
||||
},
|
||||
{
|
||||
name: "apps",
|
||||
href: "/apps",
|
||||
icon: "grid-3x3",
|
||||
moreOnMobile: true,
|
||||
isCurrent: ({ pathname: path, item }) => {
|
||||
// During Server rendering path is /v2/apps but on client it becomes /apps(weird..)
|
||||
return (path?.startsWith(item.href) ?? false) && !(path?.includes("routing-forms/") ?? false);
|
||||
},
|
||||
child: [
|
||||
{
|
||||
name: "app_store",
|
||||
href: "/apps",
|
||||
isCurrent: ({ pathname: path, item }) => {
|
||||
// During Server rendering path is /v2/apps but on client it becomes /apps(weird..)
|
||||
return (
|
||||
(path?.startsWith(item.href) ?? false) &&
|
||||
!(path?.includes("routing-forms/") ?? false) &&
|
||||
!(path?.includes("/installed") ?? false)
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "installed_apps",
|
||||
href: "/apps/installed/calendar",
|
||||
isCurrent: ({ pathname: path }) =>
|
||||
(path?.startsWith("/apps/installed/") ?? false) ||
|
||||
(path?.startsWith("/v2/apps/installed/") ?? false),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: MORE_SEPARATOR_NAME,
|
||||
href: "/more",
|
||||
icon: "ellipsis",
|
||||
},
|
||||
{
|
||||
name: "routing",
|
||||
href: "/routing",
|
||||
icon: "split",
|
||||
isCurrent: ({ pathname }) => pathname?.startsWith("/routing") ?? false,
|
||||
moreOnMobile: true,
|
||||
},
|
||||
{
|
||||
name: "workflows",
|
||||
href: "/workflows",
|
||||
icon: "zap",
|
||||
moreOnMobile: true,
|
||||
},
|
||||
{
|
||||
name: "insights",
|
||||
href: "/insights",
|
||||
icon: "chart-bar",
|
||||
isCurrent: ({ pathname: path, item }) => path?.startsWith(item.href) ?? false,
|
||||
moreOnMobile: true,
|
||||
child: hasInsightsAccess
|
||||
? [
|
||||
{
|
||||
name: "bookings",
|
||||
href: "/insights",
|
||||
isCurrent: ({ pathname: path }) => path === "/insights",
|
||||
},
|
||||
{
|
||||
name: "routing",
|
||||
href: "/insights/routing",
|
||||
isCurrent: ({ pathname: path }) => path?.startsWith("/insights/routing") ?? false,
|
||||
},
|
||||
{
|
||||
name: "router_position",
|
||||
href: "/insights/router-position",
|
||||
isCurrent: ({ pathname: path }) => path?.startsWith("/insights/router-position") ?? false,
|
||||
},
|
||||
{
|
||||
name: "call_history",
|
||||
href: "/insights/call-history",
|
||||
// icon: "phone",
|
||||
isCurrent: ({ pathname: path }) => path?.startsWith("/insights/call-history") ?? false,
|
||||
},
|
||||
]
|
||||
: undefined,
|
||||
},
|
||||
];
|
||||
|
||||
const platformNavigationItems: NavigationItemType[] = [
|
||||
{
|
||||
name: "Dashboard",
|
||||
href: "/settings/platform/",
|
||||
icon: "layout-dashboard",
|
||||
},
|
||||
{
|
||||
name: "Documentation",
|
||||
href: "https://docs.cal.com/docs/platform",
|
||||
icon: "chart-bar",
|
||||
target: "_blank",
|
||||
},
|
||||
{
|
||||
name: "API reference",
|
||||
href: "https://api.cal.com/v2/docs#/",
|
||||
icon: "terminal",
|
||||
target: "_blank",
|
||||
},
|
||||
{
|
||||
name: "Atoms",
|
||||
href: "https://docs.cal.com/docs/platform#atoms",
|
||||
icon: "atom",
|
||||
target: "_blank",
|
||||
},
|
||||
{
|
||||
name: MORE_SEPARATOR_NAME,
|
||||
href: "https://docs.cal.com/docs/platform/faq",
|
||||
icon: "ellipsis",
|
||||
target: "_blank",
|
||||
},
|
||||
{
|
||||
name: "Billing",
|
||||
href: "/settings/platform/billing",
|
||||
icon: "credit-card",
|
||||
moreOnMobile: true,
|
||||
},
|
||||
{
|
||||
name: "Members",
|
||||
href: "/settings/platform/members",
|
||||
icon: "users",
|
||||
moreOnMobile: true,
|
||||
},
|
||||
{
|
||||
name: "Managed Users",
|
||||
href: "/settings/platform/managed-users",
|
||||
icon: "users",
|
||||
moreOnMobile: true,
|
||||
},
|
||||
];
|
||||
|
||||
const useNavigationItems = (isPlatformNavigation = false) => {
|
||||
const orgBranding = useOrgBranding();
|
||||
const { hasPaidPlan, isPending } = useHasPaidPlan();
|
||||
return useMemo(() => {
|
||||
const hasInsightsAccess = !isPending && !!hasPaidPlan;
|
||||
const items = !isPlatformNavigation
|
||||
? getNavigationItems(orgBranding, hasInsightsAccess)
|
||||
: platformNavigationItems;
|
||||
|
||||
const desktopNavigationItems = items.filter((item) => item.name !== MORE_SEPARATOR_NAME);
|
||||
const mobileNavigationBottomItems = items.filter(
|
||||
(item) => (!item.moreOnMobile && !item.onlyDesktop) || item.name === MORE_SEPARATOR_NAME
|
||||
);
|
||||
const mobileNavigationMoreItems = items.filter(
|
||||
(item) => item.moreOnMobile && !item.onlyDesktop && item.name !== MORE_SEPARATOR_NAME
|
||||
);
|
||||
|
||||
return { desktopNavigationItems, mobileNavigationBottomItems, mobileNavigationMoreItems };
|
||||
}, [hasPaidPlan, isPending, isPlatformNavigation, orgBranding]);
|
||||
};
|
||||
|
||||
export const Navigation = ({ isPlatformNavigation = false }: { isPlatformNavigation?: boolean }) => {
|
||||
const { desktopNavigationItems } = useNavigationItems(isPlatformNavigation);
|
||||
|
||||
return (
|
||||
<nav className="mt-2 flex-1 md:px-2 lg:mt-4 lg:px-0">
|
||||
{desktopNavigationItems.map((item) => (
|
||||
<NavigationItem key={item.name} item={item} />
|
||||
))}
|
||||
<div className="text-subtle mt-0.5 lg:hidden">
|
||||
<KBarTrigger />
|
||||
</div>
|
||||
</nav>
|
||||
);
|
||||
};
|
||||
|
||||
export function MobileNavigationContainer({
|
||||
isPlatformNavigation = false,
|
||||
}: {
|
||||
isPlatformNavigation?: boolean;
|
||||
}) {
|
||||
const { status } = useSession();
|
||||
if (status !== "authenticated") return null;
|
||||
return <MobileNavigation isPlatformNavigation={isPlatformNavigation} />;
|
||||
}
|
||||
|
||||
const MobileNavigation = ({ isPlatformNavigation = false }: { isPlatformNavigation?: boolean }) => {
|
||||
const isEmbed = useIsEmbed();
|
||||
const { mobileNavigationBottomItems } = useNavigationItems(isPlatformNavigation);
|
||||
|
||||
return (
|
||||
<>
|
||||
<nav
|
||||
className={classNames(
|
||||
"pwa:pb-[max(0.25rem,env(safe-area-inset-bottom))] pwa:-mx-2 bg-cal-muted/40 border-subtle fixed bottom-0 left-0 z-30 flex w-full border-t px-1 shadow backdrop-blur-md md:hidden",
|
||||
isEmbed && "hidden"
|
||||
)}>
|
||||
{mobileNavigationBottomItems.map((item) => (
|
||||
<MobileNavigationItem key={item.name} item={item} />
|
||||
))}
|
||||
</nav>
|
||||
{/* add padding to content for mobile navigation*/}
|
||||
<div className="block pt-12 md:hidden" />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export const MobileNavigationMoreItems = () => {
|
||||
const { mobileNavigationMoreItems } = useNavigationItems();
|
||||
|
||||
return (
|
||||
<ul className="border-subtle mt-2 rounded-md border">
|
||||
{mobileNavigationMoreItems.map((item) => (
|
||||
<MobileNavigationMoreItem key={item.name} item={item} />
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,333 @@
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import posthog from "posthog-js";
|
||||
import React, { Fragment, useState, useEffect } from "react";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import useMediaQuery from "@calcom/lib/hooks/useMediaQuery";
|
||||
import { sessionStorage } from "@calcom/lib/webstorage";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Badge } from "@calcom/ui/components/badge";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
import type { IconName } from "@calcom/ui/components/icon";
|
||||
import { SkeletonText } from "@calcom/ui/components/skeleton";
|
||||
import { Tooltip } from "@calcom/ui/components/tooltip";
|
||||
|
||||
import { useShouldDisplayNavigationItem } from "./useShouldDisplayNavigationItem";
|
||||
|
||||
const usePersistedExpansionState = (itemName: string) => {
|
||||
const [isExpanded, setIsExpanded] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const stored = sessionStorage.getItem(`nav-expansion-${itemName}`);
|
||||
if (stored !== null) {
|
||||
setIsExpanded(JSON.parse(stored));
|
||||
}
|
||||
}, [itemName]);
|
||||
|
||||
const setPersistedExpansion = (expanded: boolean) => {
|
||||
setIsExpanded(expanded);
|
||||
sessionStorage.setItem(`nav-expansion-${itemName}`, JSON.stringify(expanded));
|
||||
};
|
||||
|
||||
return [isExpanded, setPersistedExpansion] as const;
|
||||
};
|
||||
|
||||
const trackNavigationClick = (itemName: string, parentItemName?: string) => {
|
||||
posthog.capture("navigation_item_clicked", {
|
||||
item_name: itemName,
|
||||
parent_name: parentItemName,
|
||||
});
|
||||
};
|
||||
|
||||
export type NavigationItemType = {
|
||||
name: string;
|
||||
href: string;
|
||||
isLoading?: boolean;
|
||||
onClick?: React.MouseEventHandler<HTMLAnchorElement | HTMLButtonElement>;
|
||||
target?: HTMLAnchorElement["target"];
|
||||
badge?: React.ReactNode;
|
||||
icon?: IconName;
|
||||
child?: NavigationItemType[];
|
||||
pro?: true;
|
||||
onlyMobile?: boolean;
|
||||
onlyDesktop?: boolean;
|
||||
moreOnMobile?: boolean;
|
||||
isCurrent?: ({
|
||||
item,
|
||||
isChild,
|
||||
pathname,
|
||||
}: {
|
||||
item: Pick<NavigationItemType, "href">;
|
||||
isChild?: boolean;
|
||||
pathname: string | null;
|
||||
}) => boolean;
|
||||
};
|
||||
|
||||
const defaultIsCurrent: NavigationItemType["isCurrent"] = ({ isChild, item, pathname }) => {
|
||||
return isChild ? item.href === pathname : item.href ? pathname?.startsWith(item.href) ?? false : false;
|
||||
};
|
||||
|
||||
export const NavigationItem: React.FC<{
|
||||
index?: number;
|
||||
item: NavigationItemType;
|
||||
isChild?: boolean;
|
||||
}> = (props) => {
|
||||
const { item, isChild } = props;
|
||||
const { t, isLocaleReady } = useLocale();
|
||||
const pathname = usePathname();
|
||||
const isCurrent: NavigationItemType["isCurrent"] = item.isCurrent || defaultIsCurrent;
|
||||
const current = isCurrent({ isChild: !!isChild, item, pathname });
|
||||
const shouldDisplayNavigationItem = useShouldDisplayNavigationItem(props.item);
|
||||
const [isExpanded, setIsExpanded] = usePersistedExpansionState(item.name);
|
||||
|
||||
const isTablet = useMediaQuery("(max-width: 1024px)");
|
||||
const [isTooltipOpen, setIsTooltipOpen] = useState(false);
|
||||
|
||||
if (!shouldDisplayNavigationItem) return null;
|
||||
|
||||
const hasChildren = item.child && item.child.length > 0;
|
||||
const hasActiveChild =
|
||||
hasChildren && item.child?.some((child) => isCurrent({ isChild: true, item: child, pathname }));
|
||||
const shouldShowChildren = isExpanded || hasActiveChild || isCurrent({ pathname, isChild, item });
|
||||
const shouldShowChevron = hasChildren && !hasActiveChild;
|
||||
const isParentNavigationItem = hasChildren && !isChild;
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
{isParentNavigationItem ? (
|
||||
<Tooltip
|
||||
side="right"
|
||||
open={isTooltipOpen}
|
||||
content={
|
||||
hasChildren ? (
|
||||
<div className="stack-y-1 pointer-events-auto flex flex-col p-1">
|
||||
<span className="text-subtle px-2 text-xs font-semibold uppercase tracking-wide">
|
||||
{t(item.name)}
|
||||
</span>
|
||||
<div className="flex flex-col gap-1">
|
||||
{item.child?.map((childItem) => {
|
||||
const childIsCurrent =
|
||||
typeof childItem.isCurrent === "function"
|
||||
? childItem.isCurrent({ isChild: true, item: childItem, pathname })
|
||||
: defaultIsCurrent({ isChild: true, item: childItem, pathname });
|
||||
return (
|
||||
<Link
|
||||
key={childItem.name}
|
||||
href={childItem.href}
|
||||
aria-current={childIsCurrent ? "page" : undefined}
|
||||
onClick={() => {
|
||||
setIsTooltipOpen(false);
|
||||
trackNavigationClick(childItem.name, item.name);
|
||||
}}
|
||||
className={classNames(
|
||||
"group relative block rounded-md px-3 py-1 text-sm font-medium",
|
||||
childIsCurrent
|
||||
? "bg-emphasis text-white"
|
||||
: "hover:bg-emphasis text-mute hover:text-emphasis"
|
||||
)}>
|
||||
{t(childItem.name)}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
t(item.name)
|
||||
)
|
||||
}
|
||||
className="lg:hidden">
|
||||
<button
|
||||
data-test-id={item.name}
|
||||
aria-label={t(item.name)}
|
||||
aria-expanded={isExpanded}
|
||||
aria-current={current ? "page" : undefined}
|
||||
onClick={() => {
|
||||
setIsExpanded(!isExpanded);
|
||||
if (isTablet && hasChildren) {
|
||||
setIsTooltipOpen(!isTooltipOpen);
|
||||
}
|
||||
}}
|
||||
className={classNames(
|
||||
"todesktop:py-[7px] text-default group flex w-full items-center rounded-md px-2 py-1.5 text-sm font-medium transition",
|
||||
"aria-[aria-current='page']:bg-transparent!",
|
||||
"[&[aria-current='page']]:text-emphasis mt-0.5 text-sm",
|
||||
isLocaleReady
|
||||
? "hover:bg-subtle todesktop:[&[aria-current='page']]:bg-emphasis todesktop:hover:bg-transparent hover:text-emphasis"
|
||||
: ""
|
||||
)}>
|
||||
{item.icon && (
|
||||
<Icon
|
||||
name={item.isLoading ? "rotate-cw" : item.icon}
|
||||
className={classNames(
|
||||
"todesktop:!text-blue-500 mr-2 h-4 w-4 shrink-0 rtl:ml-2 md:ltr:mx-auto lg:ltr:mr-2",
|
||||
item.isLoading && "animate-spin"
|
||||
)}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
)}
|
||||
{isLocaleReady ? (
|
||||
<span
|
||||
className="hidden w-full justify-between truncate text-ellipsis lg:flex"
|
||||
data-testid={`${item.name}-test`}>
|
||||
{t(item.name)}
|
||||
{item.badge && item.badge}
|
||||
</span>
|
||||
) : (
|
||||
<SkeletonText className="h-[20px] w-full" />
|
||||
)}
|
||||
{shouldShowChevron && (
|
||||
<Icon name={isExpanded ? "chevron-up" : "chevron-down"} className="ml-auto h-4 w-4" />
|
||||
)}
|
||||
</button>
|
||||
</Tooltip>
|
||||
) : (
|
||||
<Tooltip side="right" content={t(item.name)} className="lg:hidden">
|
||||
<Link
|
||||
data-test-id={item.name}
|
||||
onClick={() => trackNavigationClick(item.name)}
|
||||
href={item.href}
|
||||
aria-label={t(item.name)}
|
||||
target={item.target}
|
||||
className={classNames(
|
||||
"todesktop:py-[7px] text-default group flex items-center rounded-md px-2 py-1.5 text-sm font-medium transition",
|
||||
item.child
|
||||
? `aria-[aria-current='page']:bg-transparent!`
|
||||
: `[&[aria-current='page']]:bg-emphasis`,
|
||||
isChild
|
||||
? `[&[aria-current='page']]:text-emphasis [&[aria-current='page']]:bg-emphasis hidden h-8 pl-16 lg:flex lg:pl-11 ${
|
||||
props.index === 0 ? "mt-0" : "mt-1 hover:mt-1 [&[aria-current='page']]:mt-1"
|
||||
}`
|
||||
: "[&[aria-current='page']]:text-emphasis mt-0.5 text-sm",
|
||||
isLocaleReady
|
||||
? "hover:bg-subtle todesktop:[&[aria-current='page']]:bg-emphasis todesktop:hover:bg-transparent hover:text-emphasis"
|
||||
: ""
|
||||
)}
|
||||
aria-current={current ? "page" : undefined}>
|
||||
{item.icon && (
|
||||
<Icon
|
||||
name={item.isLoading ? "rotate-cw" : item.icon}
|
||||
className={classNames(
|
||||
"todesktop:!text-blue-500 mr-2 h-4 w-4 shrink-0 aria-[aria-current='page']:text-inherit rtl:ml-2 md:ltr:mx-auto lg:ltr:mr-2",
|
||||
item.isLoading && "animate-spin"
|
||||
)}
|
||||
aria-hidden="true"
|
||||
aria-current={current ? "page" : undefined}
|
||||
/>
|
||||
)}
|
||||
{isLocaleReady ? (
|
||||
<span
|
||||
className="hidden w-full justify-between truncate text-ellipsis lg:flex"
|
||||
data-testid={`${item.name}-test`}>
|
||||
{t(item.name)}
|
||||
{item.badge && item.badge}
|
||||
</span>
|
||||
) : (
|
||||
<SkeletonText className="h-[20px] w-full" />
|
||||
)}
|
||||
{item.name === "workflows" && (
|
||||
<Badge startIcon="sparkles" variant="purple">
|
||||
Cal.ai
|
||||
</Badge>
|
||||
)}
|
||||
</Link>
|
||||
</Tooltip>
|
||||
)}
|
||||
{item.child &&
|
||||
shouldShowChildren &&
|
||||
item.child.map((item, index) => <NavigationItem index={index} key={item.name} item={item} isChild />)}
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
export const MobileNavigationItem: React.FC<{
|
||||
item: NavigationItemType;
|
||||
isChild?: boolean;
|
||||
}> = (props) => {
|
||||
const { item, isChild } = props;
|
||||
const pathname = usePathname();
|
||||
const { t, isLocaleReady } = useLocale();
|
||||
const isCurrent: NavigationItemType["isCurrent"] = item.isCurrent || defaultIsCurrent;
|
||||
const current = isCurrent({ isChild: !!isChild, item, pathname });
|
||||
const shouldDisplayNavigationItem = useShouldDisplayNavigationItem(props.item);
|
||||
|
||||
if (!shouldDisplayNavigationItem) return null;
|
||||
return (
|
||||
<Link
|
||||
key={item.name}
|
||||
href={item.href}
|
||||
target={item.target}
|
||||
className="[&[aria-current='page']]:text-emphasis hover:text-default text-muted bg-transparent! relative my-2 min-w-0 flex-1 overflow-hidden rounded-md p-1 text-center text-xs font-medium focus:z-10 sm:text-sm"
|
||||
aria-current={current ? "page" : undefined}>
|
||||
{item.badge && <div className="absolute right-1 top-1">{item.badge}</div>}
|
||||
{item.icon && (
|
||||
<Icon
|
||||
name={item.icon}
|
||||
className="[&[aria-current='page']]:text-emphasis mx-auto mb-1 block h-5 w-5 shrink-0 text-center text-inherit"
|
||||
aria-hidden="true"
|
||||
aria-current={current ? "page" : undefined}
|
||||
/>
|
||||
)}
|
||||
{isLocaleReady ? <span className="block truncate">{t(item.name)}</span> : <SkeletonText />}
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
|
||||
export const MobileNavigationMoreItem: React.FC<{
|
||||
item: NavigationItemType;
|
||||
isChild?: boolean;
|
||||
}> = (props) => {
|
||||
const { item } = props;
|
||||
const { t, isLocaleReady } = useLocale();
|
||||
const shouldDisplayNavigationItem = useShouldDisplayNavigationItem(props.item);
|
||||
const [isExpanded, setIsExpanded] = usePersistedExpansionState(item.name);
|
||||
|
||||
if (!shouldDisplayNavigationItem) return null;
|
||||
|
||||
const hasChildren = item.child && item.child.length > 0;
|
||||
|
||||
return (
|
||||
<li className="border-subtle border-b last:border-b-0" key={item.name}>
|
||||
{hasChildren ? (
|
||||
<>
|
||||
<button
|
||||
onClick={() => setIsExpanded(!isExpanded)}
|
||||
className="hover:bg-subtle flex w-full items-center justify-between p-5 text-left transition">
|
||||
<span className="text-default flex items-center font-semibold">
|
||||
{item.icon && (
|
||||
<Icon name={item.icon} className="h-5 w-5 shrink-0 ltr:mr-3 rtl:ml-3" aria-hidden="true" />
|
||||
)}
|
||||
{isLocaleReady ? t(item.name) : <SkeletonText />}
|
||||
</span>
|
||||
<Icon name={isExpanded ? "chevron-up" : "chevron-down"} className="text-subtle h-5 w-5" />
|
||||
</button>
|
||||
{isExpanded && item.child && (
|
||||
<ul className="bg-subtle">
|
||||
{item.child.map((childItem) => (
|
||||
<li key={childItem.name} className="border-subtle border-t">
|
||||
<Link
|
||||
href={childItem.href}
|
||||
className="hover:bg-cal-muted flex items-center p-4 pl-12 transition">
|
||||
<span className="text-default font-medium">
|
||||
{isLocaleReady ? t(childItem.name) : <SkeletonText />}
|
||||
</span>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<Link href={item.href} className="hover:bg-subtle flex items-center justify-between p-5 transition">
|
||||
<span className="text-default flex items-center font-semibold ">
|
||||
{item.icon && (
|
||||
<Icon name={item.icon} className="h-5 w-5 shrink-0 ltr:mr-3 rtl:ml-3" aria-hidden="true" />
|
||||
)}
|
||||
{isLocaleReady ? t(item.name) : <SkeletonText />}
|
||||
</span>
|
||||
<Icon name="arrow-right" className="text-subtle h-5 w-5" />
|
||||
</Link>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
import { useFlagMap } from "@calcom/features/flags/context/provider";
|
||||
import { isKeyInObject } from "@calcom/lib/isKeyInObject";
|
||||
|
||||
import type { NavigationItemType } from "./NavigationItem";
|
||||
|
||||
export function useShouldDisplayNavigationItem(item: NavigationItemType) {
|
||||
const flags = useFlagMap();
|
||||
if (isKeyInObject(item.name, flags)) return flags[item.name];
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
export enum GatedFeatures {
|
||||
RolesAndPermissions = "roles_and_permissions",
|
||||
}
|
||||
|
||||
type GatedFeaturesStore = {
|
||||
isOpen: boolean;
|
||||
activeFeature: GatedFeatures | null;
|
||||
open: (feature: GatedFeatures) => void;
|
||||
close: () => void;
|
||||
};
|
||||
|
||||
export const useGatedFeaturesStore = create<GatedFeaturesStore>((set) => ({
|
||||
isOpen: false,
|
||||
activeFeature: null,
|
||||
open: (feature) => set({ isOpen: true, activeFeature: feature }),
|
||||
close: () => set({ isOpen: false, activeFeature: null }),
|
||||
}));
|
||||
@@ -0,0 +1,16 @@
|
||||
"use client";
|
||||
|
||||
import getBrandColours from "@calcom/lib/getBrandColours";
|
||||
import useTheme from "@calcom/lib/hooks/useTheme";
|
||||
import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
|
||||
import { useCalcomTheme } from "@calcom/ui/styles";
|
||||
|
||||
export const useAppTheme = () => {
|
||||
const { data: user } = useMeQuery();
|
||||
const brandTheme = getBrandColours({
|
||||
lightVal: user?.brandColor,
|
||||
darkVal: user?.darkBrandColor,
|
||||
});
|
||||
useCalcomTheme(brandTheme);
|
||||
useTheme(user?.appTheme);
|
||||
};
|
||||
@@ -0,0 +1,91 @@
|
||||
import type { User as UserAuth } from "next-auth";
|
||||
import posthog from "posthog-js";
|
||||
|
||||
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 { useHasActiveTeamPlanAsOwner } from "@calcom/web/modules/billing/hooks/useHasPaidPlan";
|
||||
|
||||
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[];
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useState } from "react";
|
||||
|
||||
import { ENABLE_PROFILE_SWITCHER } from "@calcom/lib/constants";
|
||||
import { useRefreshData } from "@calcom/lib/hooks/useRefreshData";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { Avatar } from "@calcom/ui/components/avatar";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import {
|
||||
Dropdown,
|
||||
DropdownItem,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuPortal,
|
||||
DropdownMenuTrigger,
|
||||
} from "@calcom/ui/components/dropdown";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
|
||||
export function ProfileDropdown() {
|
||||
const { update, data: sessionData } = useSession();
|
||||
const { data } = trpc.viewer.me.get.useQuery();
|
||||
const [menuOpen, setMenuOpen] = useState(false);
|
||||
const refreshData = useRefreshData();
|
||||
|
||||
if (!data || !ENABLE_PROFILE_SWITCHER || !sessionData) {
|
||||
return null;
|
||||
}
|
||||
const options = data.profiles.map((profile) => {
|
||||
let label;
|
||||
if (profile.organization) {
|
||||
label = profile.organization.name;
|
||||
} else {
|
||||
label = sessionData.user.name;
|
||||
}
|
||||
|
||||
return {
|
||||
label,
|
||||
value: profile.upId,
|
||||
};
|
||||
});
|
||||
|
||||
const currentOption = options.find((option) => option.value === sessionData.upId) || options[0];
|
||||
|
||||
return (
|
||||
<Dropdown open={menuOpen}>
|
||||
<DropdownMenuTrigger asChild onClick={() => setMenuOpen((menuOpen) => !menuOpen)}>
|
||||
<button
|
||||
data-testid="user-dropdown-trigger-button"
|
||||
className={classNames(
|
||||
"hover:bg-emphasis todesktop:!bg-transparent group mx-0 flex w-full cursor-pointer appearance-none items-center rounded-full px-2 py-1.5 text-left outline-none transition focus:outline-none focus:ring-0 md:rounded-none lg:rounded"
|
||||
)}>
|
||||
<span className="flex w-full grow items-center justify-around gap-2 text-sm font-medium leading-none">
|
||||
<Avatar alt={currentOption.label || ""} size="xsm" />
|
||||
<span className="block w-20 overflow-hidden text-ellipsis whitespace-nowrap">
|
||||
{currentOption.label}
|
||||
</span>
|
||||
<Icon
|
||||
name="chevron-down"
|
||||
className="group-hover:text-subtle text-muted h-4 w-4 shrink-0 transition rtl:mr-4"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</span>
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuPortal>
|
||||
<DropdownMenuContent
|
||||
align="start"
|
||||
onInteractOutside={() => {
|
||||
setMenuOpen(false);
|
||||
}}
|
||||
className="min-w-56 hariom group overflow-hidden rounded-md">
|
||||
<DropdownMenuItem className="p-3 uppercase">
|
||||
<span>Switch to</span>
|
||||
</DropdownMenuItem>
|
||||
{options.map((option) => {
|
||||
const isSelected = currentOption.value === option.value;
|
||||
return (
|
||||
<DropdownMenuItem
|
||||
key={option.value}
|
||||
onClick={() => {
|
||||
setMenuOpen(false);
|
||||
if (isSelected) return;
|
||||
update({
|
||||
upId: option.value,
|
||||
}).then(() => {
|
||||
refreshData();
|
||||
});
|
||||
}}
|
||||
className={classNames("flex w-full", isSelected ? "bg-subtle text-emphasis" : "")}>
|
||||
<DropdownItem
|
||||
type="button"
|
||||
childrenClassName={classNames("flex w-full justify-between items-center")}>
|
||||
<span>
|
||||
<Avatar alt={option.label || ""} size="xsm" />
|
||||
<span className="ml-2">{option.label}</span>
|
||||
</span>
|
||||
{isSelected ? (
|
||||
<Icon name="check" className="ml-2 inline h-4 w-4" aria-hidden="true" />
|
||||
) : null}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* <DropdownMenuSeparator /> */}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenuPortal>
|
||||
</Dropdown>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
import { signOut } from "next-auth/react";
|
||||
import { usePathname } from "next/navigation";
|
||||
import type { MouseEvent } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { ROADMAP, DESKTOP_APP_LINK } from "@calcom/lib/constants";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
|
||||
import classNames from "@calcom/ui/classNames";
|
||||
import { Avatar } from "@calcom/ui/components/avatar";
|
||||
import {
|
||||
Dropdown,
|
||||
DropdownItem,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuPortal,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from "@calcom/ui/components/dropdown";
|
||||
import { Icon } from "@calcom/ui/components/icon";
|
||||
// TODO (Platform): we shouldnt be importing from web here
|
||||
import { useGetUserAttributes } from "@calcom/web/components/settings/platform/hooks/useGetUserAttributes";
|
||||
import FreshChatProvider from "@calcom/web/modules/ee/support/lib/freshchat/FreshChatProvider";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
Support?: {
|
||||
open: () => void;
|
||||
shouldShowTriggerButton: (showTrigger: boolean) => void;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
interface UserDropdownProps {
|
||||
small?: boolean;
|
||||
}
|
||||
|
||||
export function UserDropdown({ small }: UserDropdownProps) {
|
||||
const { isPlatformUser } = useGetUserAttributes();
|
||||
const { t } = useLocale();
|
||||
const { data: user, isPending } = useMeQuery();
|
||||
const pathname = usePathname();
|
||||
const isPlatformPages = pathname?.startsWith("/settings/platform");
|
||||
|
||||
useEffect(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
//@ts-ignore
|
||||
const Beacon = window.Beacon;
|
||||
// window.Beacon is defined when user actually opens up HelpScout and username is available here. On every re-render update session info, so that it is always latest.
|
||||
Beacon &&
|
||||
Beacon("session-data", {
|
||||
username: user?.username || "Unknown",
|
||||
screenResolution: `${screen.width}x${screen.height}`,
|
||||
});
|
||||
});
|
||||
|
||||
const [menuOpen, setMenuOpen] = useState(false);
|
||||
const [openSupportAfterClose, setOpenSupportAfterClose] = useState(false);
|
||||
|
||||
const handleHelpClick = (e?: MouseEvent) => {
|
||||
e?.preventDefault();
|
||||
e?.stopPropagation();
|
||||
|
||||
setOpenSupportAfterClose(true);
|
||||
setMenuOpen(false);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!menuOpen && openSupportAfterClose) {
|
||||
setTimeout(() => {
|
||||
window.Support?.open();
|
||||
}, 0);
|
||||
setOpenSupportAfterClose(false);
|
||||
}
|
||||
}, [menuOpen, openSupportAfterClose]);
|
||||
|
||||
// Prevent rendering dropdown if user isn't available.
|
||||
// We don't want to show nameless user.
|
||||
if (!user && !isPending) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Dropdown open={menuOpen}>
|
||||
<DropdownMenuTrigger asChild onClick={() => setMenuOpen((menuOpen) => !menuOpen)} disabled={isPending}>
|
||||
<button
|
||||
data-testid="user-dropdown-trigger-button"
|
||||
className={classNames(
|
||||
"hover:bg-emphasis todesktop:!bg-transparent group mx-0 flex w-full cursor-pointer appearance-none items-center rounded-full text-left outline-none transition focus:outline-none focus:ring-0 md:rounded-none lg:rounded",
|
||||
small ? "p-2" : "px-2 py-1.5"
|
||||
)}>
|
||||
<span
|
||||
className={classNames(
|
||||
small ? "h-4 w-4" : "h-5 w-5 ltr:mr-2 rtl:ml-2",
|
||||
"relative shrink-0 rounded-full"
|
||||
)}>
|
||||
<Avatar
|
||||
size={small ? "xs" : "xsm"}
|
||||
imageSrc={user?.avatarUrl ?? user?.avatar}
|
||||
alt={user?.username ? `${user.username} Avatar` : "Nameless User Avatar"}
|
||||
className="overflow-hidden"
|
||||
/>
|
||||
<span
|
||||
className={classNames(
|
||||
"border-muted absolute -bottom-1 -right-1 rounded-full border bg-green-500",
|
||||
small ? "-bottom-0.5 -right-0.5 h-2.5 w-2.5" : "-bottom-0.5 right-0 h-2 w-2"
|
||||
)}
|
||||
/>
|
||||
</span>
|
||||
{!small && (
|
||||
<span className="flex grow items-center gap-2">
|
||||
<span className="w-24 shrink-0 text-sm leading-none">
|
||||
<span className="text-emphasis block truncate py-0.5 font-medium leading-normal">
|
||||
{isPending ? "Loading..." : user?.name ?? "Nameless User"}
|
||||
</span>
|
||||
</span>
|
||||
<Icon
|
||||
name="chevron-down"
|
||||
className="group-hover:text-subtle text-muted h-4 w-4 shrink-0 transition rtl:mr-4"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
|
||||
<DropdownMenuPortal>
|
||||
<FreshChatProvider>
|
||||
<DropdownMenuContent
|
||||
align="start"
|
||||
onInteractOutside={() => {
|
||||
setMenuOpen(false);
|
||||
}}
|
||||
className="group overflow-hidden rounded-md">
|
||||
<>
|
||||
{!isPlatformPages && (
|
||||
<>
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem
|
||||
type="button"
|
||||
CustomStartIcon={
|
||||
<Icon name="user" className="text-default h-4 w-4" aria-hidden="true" />
|
||||
}
|
||||
href="/settings/my-account/profile">
|
||||
{t("my_profile")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem
|
||||
type="button"
|
||||
CustomStartIcon={
|
||||
<Icon name="settings" className="text-default h-4 w-4" aria-hidden="true" />
|
||||
}
|
||||
href="/settings/my-account/general">
|
||||
{t("my_settings")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem
|
||||
type="button"
|
||||
CustomStartIcon={
|
||||
<Icon name="moon" className="text-default h-4 w-4" aria-hidden="true" />
|
||||
}
|
||||
href="/settings/my-account/out-of-office">
|
||||
{t("out_of_office")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
</>
|
||||
)}
|
||||
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem StartIcon="map" target="_blank" href={ROADMAP}>
|
||||
{t("visit_roadmap")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem
|
||||
type="button"
|
||||
StartIcon="circle-help"
|
||||
aria-hidden="true"
|
||||
onClick={handleHelpClick}>
|
||||
{t("help")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
{!isPlatformPages && (
|
||||
<DropdownMenuItem className="todesktop:hidden hidden lg:flex">
|
||||
<DropdownItem StartIcon="download" target="_blank" rel="noreferrer" href={DESKTOP_APP_LINK}>
|
||||
{t("download_desktop_app")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
|
||||
{!isPlatformPages && isPlatformUser && (
|
||||
<DropdownMenuItem className="todesktop:hidden hidden lg:flex">
|
||||
<DropdownItem StartIcon="blocks" target="_blank" rel="noreferrer" href="/settings/platform">
|
||||
Platform
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem>
|
||||
<DropdownItem
|
||||
type="button"
|
||||
StartIcon="log-out"
|
||||
aria-hidden="true"
|
||||
onClick={() => {
|
||||
signOut({ callbackUrl: "/auth/logout" });
|
||||
}}>
|
||||
{t("sign_out")}
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
</>
|
||||
</DropdownMenuContent>
|
||||
</FreshChatProvider>
|
||||
</DropdownMenuPortal>
|
||||
</Dropdown>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user