2021-08-02 17:40:13 +00:00
|
|
|
import { SelectorIcon } from "@heroicons/react/outline";
|
2021-07-30 23:05:38 +00:00
|
|
|
import {
|
|
|
|
CalendarIcon,
|
2021-12-09 23:51:30 +00:00
|
|
|
ArrowLeftIcon,
|
2021-07-30 23:05:38 +00:00
|
|
|
ClockIcon,
|
2021-08-02 14:10:24 +00:00
|
|
|
CogIcon,
|
2021-07-30 23:05:38 +00:00
|
|
|
ExternalLinkIcon,
|
|
|
|
LinkIcon,
|
2021-08-02 20:51:57 +00:00
|
|
|
LogoutIcon,
|
|
|
|
PuzzleIcon,
|
2021-07-30 23:05:38 +00:00
|
|
|
} from "@heroicons/react/solid";
|
2021-09-22 19:52:38 +00:00
|
|
|
import { signOut, useSession } from "next-auth/client";
|
|
|
|
import Link from "next/link";
|
|
|
|
import { useRouter } from "next/router";
|
2021-11-08 14:10:02 +00:00
|
|
|
import React, { ReactNode, useEffect, useState } from "react";
|
2021-09-22 19:52:38 +00:00
|
|
|
import { Toaster } from "react-hot-toast";
|
|
|
|
|
2021-09-30 23:42:08 +00:00
|
|
|
import LicenseBanner from "@ee/components/LicenseBanner";
|
2021-09-24 20:02:03 +00:00
|
|
|
import HelpMenuItemDynamic from "@ee/lib/intercom/HelpMenuItemDynamic";
|
|
|
|
|
2021-09-22 19:52:38 +00:00
|
|
|
import classNames from "@lib/classNames";
|
2021-10-12 09:35:44 +00:00
|
|
|
import { shouldShowOnboarding } from "@lib/getting-started";
|
2021-10-14 13:58:17 +00:00
|
|
|
import { useLocale } from "@lib/hooks/useLocale";
|
2021-09-22 19:52:38 +00:00
|
|
|
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry";
|
2021-09-27 14:47:55 +00:00
|
|
|
import { trpc } from "@lib/trpc";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2021-11-16 08:51:46 +00:00
|
|
|
import CustomBranding from "@components/CustomBranding";
|
2021-10-14 19:10:44 +00:00
|
|
|
import Loader from "@components/Loader";
|
2021-08-27 12:35:20 +00:00
|
|
|
import { HeadSeo } from "@components/seo/head-seo";
|
2021-09-22 19:52:38 +00:00
|
|
|
import Avatar from "@components/ui/Avatar";
|
2021-10-13 14:00:40 +00:00
|
|
|
import Dropdown, {
|
|
|
|
DropdownMenuContent,
|
|
|
|
DropdownMenuItem,
|
|
|
|
DropdownMenuSeparator,
|
|
|
|
DropdownMenuTrigger,
|
|
|
|
} from "@components/ui/Dropdown";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2021-10-14 19:10:44 +00:00
|
|
|
import { useViewerI18n } from "./I18nLanguageHandler";
|
2021-09-22 19:52:38 +00:00
|
|
|
import Logo from "./Logo";
|
2021-12-09 23:51:30 +00:00
|
|
|
import Button from "./ui/Button";
|
2021-03-24 15:03:04 +00:00
|
|
|
|
2021-09-27 14:47:55 +00:00
|
|
|
function useMeQuery() {
|
2021-11-08 14:10:02 +00:00
|
|
|
const meQuery = trpc.useQuery(["viewer.me"], {
|
|
|
|
retry(failureCount) {
|
|
|
|
return failureCount > 3;
|
|
|
|
},
|
|
|
|
});
|
2021-09-27 14:47:55 +00:00
|
|
|
|
|
|
|
return meQuery;
|
|
|
|
}
|
|
|
|
|
|
|
|
function useRedirectToLoginIfUnauthenticated() {
|
|
|
|
const [session, loading] = useSession();
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (!loading && !session) {
|
|
|
|
router.replace({
|
|
|
|
pathname: "/auth/login",
|
|
|
|
query: {
|
|
|
|
callbackUrl: `${location.pathname}${location.search}`,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2021-11-08 14:10:02 +00:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [loading, session]);
|
2021-10-14 10:57:49 +00:00
|
|
|
|
2021-11-08 14:10:02 +00:00
|
|
|
return {
|
|
|
|
loading: loading && !session,
|
|
|
|
};
|
2021-10-14 10:57:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function useRedirectToOnboardingIfNeeded() {
|
|
|
|
const router = useRouter();
|
|
|
|
const query = useMeQuery();
|
|
|
|
const user = query.data;
|
|
|
|
|
2021-11-08 14:10:02 +00:00
|
|
|
const [isRedirectingToOnboarding, setRedirecting] = useState(false);
|
2021-10-14 10:57:49 +00:00
|
|
|
useEffect(() => {
|
2021-11-08 14:10:02 +00:00
|
|
|
if (user && shouldShowOnboarding(user)) {
|
|
|
|
setRedirecting(true);
|
|
|
|
}
|
|
|
|
}, [router, user]);
|
|
|
|
useEffect(() => {
|
|
|
|
if (isRedirectingToOnboarding) {
|
|
|
|
router.replace({
|
|
|
|
pathname: "/getting-started",
|
|
|
|
});
|
2021-10-14 10:57:49 +00:00
|
|
|
}
|
2021-11-08 14:10:02 +00:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [isRedirectingToOnboarding]);
|
|
|
|
return {
|
|
|
|
isRedirectingToOnboarding,
|
|
|
|
};
|
2021-09-27 14:47:55 +00:00
|
|
|
}
|
|
|
|
|
2021-10-12 09:35:44 +00:00
|
|
|
export function ShellSubHeading(props: {
|
|
|
|
title: ReactNode;
|
|
|
|
subtitle?: ReactNode;
|
|
|
|
actions?: ReactNode;
|
|
|
|
className?: string;
|
|
|
|
}) {
|
|
|
|
return (
|
|
|
|
<div className={classNames("block sm:flex justify-between mb-3", props.className)}>
|
|
|
|
<div>
|
2021-11-16 01:08:04 +00:00
|
|
|
<h2 className="flex items-center content-center space-x-2 text-base font-bold leading-6 text-gray-900">
|
2021-10-12 09:35:44 +00:00
|
|
|
{props.title}
|
|
|
|
</h2>
|
2021-10-13 14:00:40 +00:00
|
|
|
{props.subtitle && <p className="mr-4 text-sm text-neutral-500">{props.subtitle}</p>}
|
2021-10-12 09:35:44 +00:00
|
|
|
</div>
|
2021-12-09 19:37:29 +00:00
|
|
|
{props.actions && <div className="flex-shrink-0">{props.actions}</div>}
|
2021-10-12 09:35:44 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-27 14:47:55 +00:00
|
|
|
export default function Shell(props: {
|
2021-10-11 09:34:43 +00:00
|
|
|
centered?: boolean;
|
2021-09-27 14:47:55 +00:00
|
|
|
title?: string;
|
|
|
|
heading: ReactNode;
|
2021-10-11 09:34:43 +00:00
|
|
|
subtitle?: ReactNode;
|
2021-09-27 14:47:55 +00:00
|
|
|
children: ReactNode;
|
|
|
|
CTA?: ReactNode;
|
2021-12-09 23:51:30 +00:00
|
|
|
HeadingLeftIcon?: ReactNode;
|
|
|
|
showBackButton?: boolean;
|
|
|
|
// use when content needs to expand with flex
|
|
|
|
flexChildrenContainer?: boolean;
|
2021-09-27 14:47:55 +00:00
|
|
|
}) {
|
2021-10-14 13:58:17 +00:00
|
|
|
const { t } = useLocale();
|
2021-06-23 15:49:10 +00:00
|
|
|
const router = useRouter();
|
2021-11-08 14:10:02 +00:00
|
|
|
const { loading } = useRedirectToLoginIfUnauthenticated();
|
|
|
|
const { isRedirectingToOnboarding } = useRedirectToOnboardingIfNeeded();
|
2021-09-27 14:47:55 +00:00
|
|
|
|
2021-06-23 15:49:10 +00:00
|
|
|
const telemetry = useTelemetry();
|
2021-10-12 09:35:44 +00:00
|
|
|
|
2021-07-30 23:05:38 +00:00
|
|
|
const navigation = [
|
|
|
|
{
|
2021-10-14 13:58:17 +00:00
|
|
|
name: t("event_types_page_title"),
|
2021-07-30 23:05:38 +00:00
|
|
|
href: "/event-types",
|
|
|
|
icon: LinkIcon,
|
2021-09-29 21:33:18 +00:00
|
|
|
current: router.asPath.startsWith("/event-types"),
|
2021-07-30 23:05:38 +00:00
|
|
|
},
|
|
|
|
{
|
2021-10-14 13:58:17 +00:00
|
|
|
name: t("bookings"),
|
2021-09-29 21:33:18 +00:00
|
|
|
href: "/bookings/upcoming",
|
2021-12-08 19:28:36 +00:00
|
|
|
icon: CalendarIcon,
|
2021-09-29 21:33:18 +00:00
|
|
|
current: router.asPath.startsWith("/bookings"),
|
2021-07-30 23:05:38 +00:00
|
|
|
},
|
|
|
|
{
|
2021-10-14 13:58:17 +00:00
|
|
|
name: t("availability"),
|
2021-07-30 23:05:38 +00:00
|
|
|
href: "/availability",
|
2021-12-08 19:28:36 +00:00
|
|
|
icon: ClockIcon,
|
2021-09-29 21:33:18 +00:00
|
|
|
current: router.asPath.startsWith("/availability"),
|
2021-07-30 23:05:38 +00:00
|
|
|
},
|
|
|
|
{
|
2021-10-14 13:58:17 +00:00
|
|
|
name: t("integrations"),
|
2021-07-30 23:05:38 +00:00
|
|
|
href: "/integrations",
|
|
|
|
icon: PuzzleIcon,
|
2021-09-29 21:33:18 +00:00
|
|
|
current: router.asPath.startsWith("/integrations"),
|
2021-07-30 23:05:38 +00:00
|
|
|
},
|
2021-08-02 14:10:24 +00:00
|
|
|
{
|
2021-10-14 13:58:17 +00:00
|
|
|
name: t("settings"),
|
2021-08-02 14:10:24 +00:00
|
|
|
href: "/settings/profile",
|
|
|
|
icon: CogIcon,
|
2021-09-29 21:33:18 +00:00
|
|
|
current: router.asPath.startsWith("/settings"),
|
2021-08-02 14:10:24 +00:00
|
|
|
},
|
2021-07-30 23:05:38 +00:00
|
|
|
];
|
|
|
|
|
2021-06-23 15:49:10 +00:00
|
|
|
useEffect(() => {
|
|
|
|
telemetry.withJitsu((jitsu) => {
|
2021-09-29 21:33:18 +00:00
|
|
|
return jitsu.track(telemetryEventTypes.pageView, collectPageParameters(router.asPath));
|
2021-06-23 15:49:10 +00:00
|
|
|
});
|
2021-10-14 10:57:49 +00:00
|
|
|
}, [telemetry, router.asPath]);
|
2021-05-07 16:01:29 +00:00
|
|
|
|
2021-08-27 12:35:20 +00:00
|
|
|
const pageTitle = typeof props.heading === "string" ? props.heading : props.title;
|
|
|
|
|
2021-11-16 08:51:46 +00:00
|
|
|
const query = useMeQuery();
|
|
|
|
const user = query.data;
|
|
|
|
|
2021-10-14 19:10:44 +00:00
|
|
|
const i18n = useViewerI18n();
|
|
|
|
|
2021-11-08 14:10:02 +00:00
|
|
|
if (i18n.status === "loading" || isRedirectingToOnboarding || loading) {
|
2021-10-14 19:10:44 +00:00
|
|
|
// show spinner whilst i18n is loading to avoid language flicker
|
|
|
|
return (
|
2021-11-16 01:08:04 +00:00
|
|
|
<div className="absolute z-50 flex items-center w-full h-screen bg-gray-50">
|
2021-10-14 19:10:44 +00:00
|
|
|
<Loader />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2021-09-27 14:47:55 +00:00
|
|
|
return (
|
2021-08-03 11:13:48 +00:00
|
|
|
<>
|
2021-11-16 08:51:46 +00:00
|
|
|
<CustomBranding val={user?.brandColor} />
|
2021-08-27 12:35:20 +00:00
|
|
|
<HeadSeo
|
2021-09-27 14:47:55 +00:00
|
|
|
title={pageTitle ?? "Cal.com"}
|
2021-10-11 09:34:43 +00:00
|
|
|
description={props.subtitle ? props.subtitle?.toString() : ""}
|
2021-08-27 12:35:20 +00:00
|
|
|
nextSeoProps={{
|
|
|
|
nofollow: true,
|
|
|
|
noindex: true,
|
|
|
|
}}
|
|
|
|
/>
|
2021-08-18 08:18:18 +00:00
|
|
|
<div>
|
|
|
|
<Toaster position="bottom-right" />
|
|
|
|
</div>
|
|
|
|
|
2021-10-13 14:00:40 +00:00
|
|
|
<div className="flex h-screen overflow-hidden bg-gray-100">
|
2021-12-02 20:52:38 +00:00
|
|
|
<div className="hidden md:flex lg:flex-shrink-0">
|
2021-12-01 14:56:25 +00:00
|
|
|
<div className="flex flex-col w-14 lg:w-56">
|
2021-10-13 14:00:40 +00:00
|
|
|
<div className="flex flex-col flex-1 h-0 bg-white border-r border-gray-200">
|
2021-12-09 19:37:29 +00:00
|
|
|
<div className="flex flex-col flex-1 pt-3 pb-4 overflow-y-auto lg:pt-5">
|
2021-08-03 11:13:48 +00:00
|
|
|
<Link href="/event-types">
|
2021-12-02 20:52:38 +00:00
|
|
|
<a className="px-4 md:hidden lg:inline">
|
2021-08-03 11:13:48 +00:00
|
|
|
<Logo small />
|
|
|
|
</a>
|
|
|
|
</Link>
|
2021-12-02 20:52:38 +00:00
|
|
|
{/* logo icon for tablet */}
|
2021-12-01 14:56:25 +00:00
|
|
|
<Link href="/event-types">
|
2021-12-02 20:52:38 +00:00
|
|
|
<a className="md:inline lg:hidden">
|
|
|
|
<Logo small icon />
|
2021-12-01 14:56:25 +00:00
|
|
|
</a>
|
|
|
|
</Link>
|
2021-12-09 19:37:29 +00:00
|
|
|
<nav className="flex-1 px-2 mt-2 space-y-1 bg-white lg:mt-5">
|
2021-12-01 14:56:25 +00:00
|
|
|
{navigation.map((item) => (
|
|
|
|
<Link key={item.name} href={item.href}>
|
|
|
|
<a
|
|
|
|
className={classNames(
|
|
|
|
item.current
|
|
|
|
? "bg-neutral-100 text-neutral-900"
|
|
|
|
: "text-neutral-500 hover:bg-gray-50 hover:text-neutral-900",
|
|
|
|
"group flex items-center px-2 py-2 text-sm font-medium rounded-sm"
|
|
|
|
)}>
|
|
|
|
<item.icon
|
|
|
|
className={classNames(
|
|
|
|
item.current
|
|
|
|
? "text-neutral-500"
|
|
|
|
: "text-neutral-400 group-hover:text-neutral-500",
|
|
|
|
"mr-3 flex-shrink-0 h-5 w-5"
|
|
|
|
)}
|
|
|
|
aria-hidden="true"
|
|
|
|
/>
|
2021-12-02 20:52:38 +00:00
|
|
|
<span className="hidden lg:inline">{item.name}</span>
|
2021-12-01 14:56:25 +00:00
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
))}
|
|
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
<div className="p-2 pt-2 pr-2 m-2 rounded-sm hover:bg-gray-100">
|
2021-12-02 20:52:38 +00:00
|
|
|
<span className="hidden lg:inline">
|
|
|
|
<UserDropdown />
|
|
|
|
</span>
|
|
|
|
<span className="hidden md:inline lg:hidden">
|
|
|
|
<UserDropdown small />
|
|
|
|
</span>
|
2021-12-01 14:56:25 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-30 23:05:38 +00:00
|
|
|
</div>
|
2021-08-03 11:13:48 +00:00
|
|
|
|
2021-10-13 14:00:40 +00:00
|
|
|
<div className="flex flex-col flex-1 w-0 overflow-hidden">
|
2021-12-09 23:51:30 +00:00
|
|
|
<main
|
|
|
|
className={classNames(
|
|
|
|
"flex-1 relative z-0 overflow-y-auto focus:outline-none max-w-[1700px]",
|
|
|
|
props.flexChildrenContainer && "flex flex-col"
|
|
|
|
)}>
|
2021-08-03 11:13:48 +00:00
|
|
|
{/* show top navigation for md and smaller (tablet and phones) */}
|
2021-10-19 12:38:05 +00:00
|
|
|
<nav className="flex items-center justify-between p-4 bg-white border-b border-gray-200 md:hidden">
|
2021-08-03 11:13:48 +00:00
|
|
|
<Link href="/event-types">
|
2021-08-02 14:10:24 +00:00
|
|
|
<a>
|
2021-08-03 11:13:48 +00:00
|
|
|
<Logo />
|
2021-08-02 14:10:24 +00:00
|
|
|
</a>
|
|
|
|
</Link>
|
2021-10-13 14:00:40 +00:00
|
|
|
<div className="flex items-center self-center gap-3">
|
|
|
|
<button className="p-2 text-gray-400 bg-white rounded-full hover:text-gray-500 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-black">
|
2021-10-15 10:53:42 +00:00
|
|
|
<span className="sr-only">{t("view_notifications")}</span>
|
2021-08-03 11:13:48 +00:00
|
|
|
<Link href="/settings/profile">
|
|
|
|
<a>
|
2021-10-13 14:00:40 +00:00
|
|
|
<CogIcon className="w-6 h-6" aria-hidden="true" />
|
2021-08-03 11:13:48 +00:00
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
</button>
|
2021-10-13 14:00:40 +00:00
|
|
|
<UserDropdown small />
|
2021-06-23 15:49:10 +00:00
|
|
|
</div>
|
2021-08-03 11:13:48 +00:00
|
|
|
</nav>
|
2021-12-09 23:51:30 +00:00
|
|
|
<div
|
|
|
|
className={classNames(
|
|
|
|
props.centered && "md:max-w-5xl mx-auto",
|
|
|
|
props.flexChildrenContainer && "flex flex-col flex-1",
|
|
|
|
"py-8"
|
|
|
|
)}>
|
|
|
|
{props.showBackButton && (
|
|
|
|
<div className="mx-3 mb-8 sm:mx-8">
|
|
|
|
<Button onClick={() => router.back()} StartIcon={ArrowLeftIcon} color="secondary">
|
|
|
|
Back
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
)}
|
2021-09-30 19:59:34 +00:00
|
|
|
<div className="block sm:flex justify-between px-4 sm:px-6 md:px-8 min-h-[80px]">
|
2021-12-09 23:51:30 +00:00
|
|
|
{props.HeadingLeftIcon && <div className="mr-4">{props.HeadingLeftIcon}</div>}
|
2021-11-10 23:18:39 +00:00
|
|
|
<div className="w-full mb-8">
|
2021-10-13 14:00:40 +00:00
|
|
|
<h1 className="mb-1 text-xl font-bold tracking-wide text-gray-900 font-cal">
|
2021-10-10 09:46:20 +00:00
|
|
|
{props.heading}
|
|
|
|
</h1>
|
2021-10-13 14:00:40 +00:00
|
|
|
<p className="mr-4 text-sm text-neutral-500">{props.subtitle}</p>
|
2021-08-03 11:13:48 +00:00
|
|
|
</div>
|
2021-10-13 14:00:40 +00:00
|
|
|
<div className="flex-shrink-0 mb-4">{props.CTA}</div>
|
2021-08-03 11:13:48 +00:00
|
|
|
</div>
|
2021-12-09 23:51:30 +00:00
|
|
|
<div
|
|
|
|
className={classNames(
|
|
|
|
"px-4 sm:px-6 md:px-8",
|
|
|
|
props.flexChildrenContainer && "flex flex-col flex-1"
|
|
|
|
)}>
|
|
|
|
{props.children}
|
|
|
|
</div>
|
2021-08-03 11:13:48 +00:00
|
|
|
{/* show bottom navigation for md and smaller (tablet and phones) */}
|
2021-10-13 14:00:40 +00:00
|
|
|
<nav className="fixed bottom-0 flex w-full bg-white shadow bottom-nav md:hidden">
|
2021-08-03 11:13:48 +00:00
|
|
|
{/* note(PeerRich): using flatMap instead of map to remove settings from bottom nav */}
|
|
|
|
{navigation.flatMap((item, itemIdx) =>
|
2021-10-17 11:36:25 +00:00
|
|
|
item.href === "/settings/profile" ? (
|
2021-08-03 11:13:48 +00:00
|
|
|
[]
|
|
|
|
) : (
|
|
|
|
<Link key={item.name} href={item.href}>
|
|
|
|
<a
|
2021-08-02 17:50:52 +00:00
|
|
|
className={classNames(
|
2021-08-03 11:13:48 +00:00
|
|
|
item.current ? "text-gray-900" : "text-neutral-400 hover:text-gray-700",
|
|
|
|
itemIdx === 0 ? "rounded-l-lg" : "",
|
|
|
|
itemIdx === navigation.length - 1 ? "rounded-r-lg" : "",
|
|
|
|
"group relative min-w-0 flex-1 overflow-hidden bg-white py-2 px-2 text-xs sm:text-sm font-medium text-center hover:bg-gray-50 focus:z-10"
|
2021-08-02 17:50:52 +00:00
|
|
|
)}
|
2021-08-03 11:13:48 +00:00
|
|
|
aria-current={item.current ? "page" : undefined}>
|
|
|
|
<item.icon
|
|
|
|
className={classNames(
|
|
|
|
item.current ? "text-gray-900" : "text-gray-400 group-hover:text-gray-500",
|
|
|
|
"block mx-auto flex-shrink-0 h-5 w-5 mb-1 text-center"
|
|
|
|
)}
|
|
|
|
aria-hidden="true"
|
|
|
|
/>
|
2021-10-17 11:36:25 +00:00
|
|
|
<span className="truncate">{item.name}</span>
|
2021-08-03 11:13:48 +00:00
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
)
|
|
|
|
)}
|
|
|
|
</nav>
|
|
|
|
{/* add padding to content for mobile navigation*/}
|
2021-10-13 14:00:40 +00:00
|
|
|
<div className="block pt-12 md:hidden" />
|
2021-08-03 11:13:48 +00:00
|
|
|
</div>
|
2021-09-30 23:42:08 +00:00
|
|
|
<LicenseBanner />
|
2021-08-03 11:13:48 +00:00
|
|
|
</main>
|
|
|
|
</div>
|
2021-06-23 15:49:10 +00:00
|
|
|
</div>
|
2021-08-03 11:13:48 +00:00
|
|
|
</>
|
2021-09-27 14:47:55 +00:00
|
|
|
);
|
2021-06-23 15:49:10 +00:00
|
|
|
}
|
2021-08-02 14:10:24 +00:00
|
|
|
|
2021-10-13 14:00:40 +00:00
|
|
|
function UserDropdown({ small }: { small?: boolean }) {
|
2021-10-15 10:53:42 +00:00
|
|
|
const { t } = useLocale();
|
2021-09-27 14:47:55 +00:00
|
|
|
const query = useMeQuery();
|
|
|
|
const user = query.data;
|
2021-08-22 13:16:42 +00:00
|
|
|
|
2021-11-16 01:08:04 +00:00
|
|
|
return (
|
2021-10-17 12:13:24 +00:00
|
|
|
<Dropdown>
|
|
|
|
<DropdownMenuTrigger asChild>
|
2021-12-09 19:37:29 +00:00
|
|
|
<div className="flex items-center w-full space-x-2 cursor-pointer group">
|
2021-12-09 11:53:34 +00:00
|
|
|
<span
|
|
|
|
className={classNames(small ? "w-8 h-8" : "w-10 h-10", "bg-gray-300 rounded-full flex-shrink-0")}>
|
|
|
|
<Avatar imageSrc={user?.avatar || ""} alt={user?.username || "Nameless User"} />
|
|
|
|
</span>
|
2021-10-17 12:13:24 +00:00
|
|
|
{!small && (
|
2021-12-09 19:37:29 +00:00
|
|
|
<span className="flex items-center flex-grow truncate">
|
2021-12-09 11:53:34 +00:00
|
|
|
<span className="flex-grow text-sm truncate">
|
2021-11-16 01:08:04 +00:00
|
|
|
<span className="block font-medium text-gray-900 truncate">
|
|
|
|
{user?.username || "Nameless User"}
|
|
|
|
</span>
|
|
|
|
<span className="block font-normal truncate text-neutral-500">
|
|
|
|
{user?.username ? `cal.com/${user.username}` : "No public page"}
|
|
|
|
</span>
|
2021-10-17 12:13:24 +00:00
|
|
|
</span>
|
|
|
|
<SelectorIcon
|
|
|
|
className="flex-shrink-0 w-5 h-5 text-gray-400 group-hover:text-gray-500"
|
|
|
|
aria-hidden="true"
|
|
|
|
/>
|
2021-12-09 11:53:34 +00:00
|
|
|
</span>
|
2021-10-17 12:13:24 +00:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</DropdownMenuTrigger>
|
|
|
|
<DropdownMenuContent>
|
2021-11-16 01:08:04 +00:00
|
|
|
{user?.username && (
|
|
|
|
<DropdownMenuItem>
|
|
|
|
<a
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
href={`${process.env.NEXT_PUBLIC_APP_URL}/${user.username}`}
|
|
|
|
className="flex items-center px-4 py-2 text-sm text-gray-700">
|
|
|
|
<ExternalLinkIcon className="w-5 h-5 mr-3 text-gray-500" /> {t("view_public_page")}
|
|
|
|
</a>
|
|
|
|
</DropdownMenuItem>
|
|
|
|
)}
|
2021-10-17 12:13:24 +00:00
|
|
|
<DropdownMenuSeparator className="h-px bg-gray-200" />
|
|
|
|
<DropdownMenuItem>
|
|
|
|
<a
|
|
|
|
href="https://cal.com/slack"
|
|
|
|
target="_blank"
|
|
|
|
rel="noreferrer"
|
2021-10-19 12:38:05 +00:00
|
|
|
className="flex px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900">
|
2021-10-17 12:13:24 +00:00
|
|
|
<svg
|
|
|
|
viewBox="0 0 2447.6 2452.5"
|
|
|
|
className={classNames(
|
2021-10-19 12:38:05 +00:00
|
|
|
"text-gray-500 group-hover:text-gray-700",
|
2021-10-17 12:13:24 +00:00
|
|
|
"mt-0.5 mr-3 flex-shrink-0 h-4 w-4"
|
|
|
|
)}
|
|
|
|
xmlns="http://www.w3.org/2000/svg">
|
|
|
|
<g clipRule="evenodd" fillRule="evenodd">
|
|
|
|
<path
|
|
|
|
d="m897.4 0c-135.3.1-244.8 109.9-244.7 245.2-.1 135.3 109.5 245.1 244.8 245.2h244.8v-245.1c.1-135.3-109.5-245.1-244.9-245.3.1 0 .1 0 0 0m0 654h-652.6c-135.3.1-244.9 109.9-244.8 245.2-.2 135.3 109.4 245.1 244.7 245.3h652.7c135.3-.1 244.9-109.9 244.8-245.2.1-135.4-109.5-245.2-244.8-245.3z"
|
|
|
|
fill="#9BA6B6"></path>
|
|
|
|
<path
|
|
|
|
d="m2447.6 899.2c.1-135.3-109.5-245.1-244.8-245.2-135.3.1-244.9 109.9-244.8 245.2v245.3h244.8c135.3-.1 244.9-109.9 244.8-245.3zm-652.7 0v-654c.1-135.2-109.4-245-244.7-245.2-135.3.1-244.9 109.9-244.8 245.2v654c-.2 135.3 109.4 245.1 244.7 245.3 135.3-.1 244.9-109.9 244.8-245.3z"
|
|
|
|
fill="#9BA6B6"></path>
|
|
|
|
<path
|
|
|
|
d="m1550.1 2452.5c135.3-.1 244.9-109.9 244.8-245.2.1-135.3-109.5-245.1-244.8-245.2h-244.8v245.2c-.1 135.2 109.5 245 244.8 245.2zm0-654.1h652.7c135.3-.1 244.9-109.9 244.8-245.2.2-135.3-109.4-245.1-244.7-245.3h-652.7c-135.3.1-244.9 109.9-244.8 245.2-.1 135.4 109.4 245.2 244.7 245.3z"
|
|
|
|
fill="#9BA6B6"></path>
|
|
|
|
<path
|
|
|
|
d="m0 1553.2c-.1 135.3 109.5 245.1 244.8 245.2 135.3-.1 244.9-109.9 244.8-245.2v-245.2h-244.8c-135.3.1-244.9 109.9-244.8 245.2zm652.7 0v654c-.2 135.3 109.4 245.1 244.7 245.3 135.3-.1 244.9-109.9 244.8-245.2v-653.9c.2-135.3-109.4-245.1-244.7-245.3-135.4 0-244.9 109.8-244.8 245.1 0 0 0 .1 0 0"
|
|
|
|
fill="#9BA6B6"></path>
|
|
|
|
</g>
|
|
|
|
</svg>
|
|
|
|
{t("join_our_slack")}
|
|
|
|
</a>
|
|
|
|
</DropdownMenuItem>
|
|
|
|
<HelpMenuItemDynamic />
|
|
|
|
<DropdownMenuSeparator className="h-px bg-gray-200" />
|
|
|
|
<DropdownMenuItem>
|
|
|
|
<a
|
|
|
|
onClick={() => signOut({ callbackUrl: "/auth/logout" })}
|
2021-10-19 12:38:05 +00:00
|
|
|
className="flex px-4 py-2 text-sm cursor-pointer hover:bg-gray-100 hover:text-gray-900">
|
2021-10-17 12:13:24 +00:00
|
|
|
<LogoutIcon
|
2021-10-19 12:38:05 +00:00
|
|
|
className={classNames("text-gray-500 group-hover:text-gray-700", "mr-2 flex-shrink-0 h-5 w-5")}
|
2021-10-17 12:13:24 +00:00
|
|
|
aria-hidden="true"
|
2021-10-13 14:00:40 +00:00
|
|
|
/>
|
2021-10-17 12:13:24 +00:00
|
|
|
{t("sign_out")}
|
|
|
|
</a>
|
|
|
|
</DropdownMenuItem>
|
|
|
|
</DropdownMenuContent>
|
|
|
|
</Dropdown>
|
2021-11-16 01:08:04 +00:00
|
|
|
);
|
2021-08-02 17:40:13 +00:00
|
|
|
}
|