* use booking.uid instead of booking.id for url param * show timezone on calendar * fix type * restore horizontal tab and remove header and subtitle * clean up sidebar items * fix event propagation from attendees * fetch all statuses except for cancelled on calendar view * clean up styles of the badges on BookingListItem * fix useMediaQuery * add close button to the header * add assignment reason to the details sheet * use separator row * use ToggleGroup for the top bookings tab * move ViewToggleButton * resize the action button * remove wrong prop * fix type error * fix type error * hide view toggle button on mobile (and fix the breakpoint) * remove unused e2e tests * fix e2e tests * hide toggle button when feature flag is off * update skeleton * improve attendees on booking list item and slide over * improve attendee dropdown * fix type error * move query to containers * select attendee email * infinite fetching for calendar view * update styles * fix compatibility * fix: add backward compatibility for status field in getAllUserBookings * increase calendar height * fix type error * support Member filter only for admin / owners * add debug log (TEMP) * add event border color * show Reject / Accept buttons on BookingDetailsSheet * move description section to the top * update When section * update style of Who section * add CancelBookingDialog WIP * fix CancelBookingDialog * increase clickable area * add schedule info section WIP * fix flaky reject button * fixing reschedule info WIP * add fromReschedule index to Booking * improve rescheduled information * improve reassignment * fix type error * fix unit test * respect user's weekStart value on the booking calendar view * update debug log * improve payment section * clean up * fix log message * reposition filters on list view * fix bookings controller api2 e2e test * clean up file by extracting logic into custom hooks * rename files * merge BookingCalendar into its container * extract logic into separate hook files * remove redundant logic * rearrange items on calendar view * add WeekPicker * extract filter button * responsive header on list view * horizontal scroll for ToggleGroup WIP * fix type error * fix cancelling recurring event * address feedback * fix e2e tests * fix unit test * fix e2e tests * make hover style more visible for ToggleGroup * fix margin on CancelBookingDialog * update styles on the slide over (mostly font weight) * update style of CancelBookingDialog * update styles * update margin top for the header * refactor getBookingDetails handler * fix gap in who section * auto-filter the current user on the calendar view * calculate calendar height considering top banners * improve booking details sheet interaction without overlay * update calendar event styles * update reject dialog style * put uid first in the query params * fix class name * memoize functions in useMediaQuery * query attendee with id instead of email * update margins * replace TRPCError with ErrorWithCode * move calculation outside loop * remove dead code
259 lines
7.3 KiB
TypeScript
259 lines
7.3 KiB
TypeScript
import { useSession } from "next-auth/react";
|
|
import { useMemo } from "react";
|
|
|
|
import { useIsEmbed } from "@calcom/embed-core/embed-iframe";
|
|
import UnconfirmedBookingBadge from "@calcom/features/bookings/UnconfirmedBookingBadge";
|
|
import {
|
|
useOrgBranding,
|
|
type OrganizationBranding,
|
|
} from "@calcom/features/ee/organizations/context/provider";
|
|
import { KBarTrigger } from "@calcom/features/kbar/Kbar";
|
|
import classNames from "@calcom/ui/classNames";
|
|
|
|
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): 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: [
|
|
{
|
|
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,
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
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();
|
|
return useMemo(() => {
|
|
const items = !isPlatformNavigation ? getNavigationItems(orgBranding) : 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 };
|
|
}, [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>
|
|
);
|
|
};
|