* 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
158 lines
5.9 KiB
TypeScript
158 lines
5.9 KiB
TypeScript
import { TooltipProvider } from "@radix-ui/react-tooltip";
|
|
import type { Session } from "next-auth";
|
|
import { useSession } from "next-auth/react";
|
|
import { ThemeProvider } from "next-themes";
|
|
import type { AppProps as NextAppProps } from "next/app";
|
|
import type { ReadonlyURLSearchParams } from "next/navigation";
|
|
import { usePathname, useSearchParams } from "next/navigation";
|
|
import { NuqsAdapter } from "nuqs/adapters/next/app";
|
|
|
|
import DynamicPostHogProvider from "@calcom/features/ee/event-tracking/lib/posthog/providerDynamic";
|
|
import DynamicPostHogPageView from "@calcom/features/ee/event-tracking/lib/posthog/web/pageViewDynamic";
|
|
import { OrgBrandingProvider } from "@calcom/features/ee/organizations/context/provider";
|
|
import DynamicHelpscoutProvider from "@calcom/features/ee/support/lib/helpscout/providerDynamic";
|
|
import DynamicIntercomProvider from "@calcom/features/ee/support/lib/intercom/providerDynamic";
|
|
import { FeatureProvider } from "@calcom/features/flags/context/provider";
|
|
import { useFlags } from "@calcom/features/flags/hooks";
|
|
|
|
import useIsBookingPage from "@lib/hooks/useIsBookingPage";
|
|
import useIsThemeSupported from "@lib/hooks/useIsThemeSupported";
|
|
import { useNuqsParams } from "@lib/hooks/useNuqsParams";
|
|
import type { WithLocaleProps } from "@lib/withLocale";
|
|
|
|
import type { PageWrapperProps } from "@components/PageWrapperAppDir";
|
|
|
|
import { getThemeProviderProps } from "./getThemeProviderProps";
|
|
|
|
// Workaround for https://github.com/vercel/next.js/issues/8592
|
|
export type AppProps = Omit<
|
|
NextAppProps<
|
|
WithLocaleProps<{
|
|
nonce: string | undefined;
|
|
themeBasis?: string;
|
|
session: Session;
|
|
}>
|
|
>,
|
|
"Component"
|
|
> & {
|
|
Component: NextAppProps["Component"] & {
|
|
requiresLicense?: boolean;
|
|
isBookingPage?: boolean | ((arg: { router: NextAppProps["router"] }) => boolean);
|
|
PageWrapper?: (props: AppProps) => JSX.Element;
|
|
};
|
|
|
|
/** Will be defined only is there was an error */
|
|
err?: Error;
|
|
};
|
|
|
|
const getEmbedNamespace = (searchParams: ReadonlyURLSearchParams) => {
|
|
// Mostly embed query param should be available on server. Use that there.
|
|
// Use the most reliable detection on client
|
|
return typeof window !== "undefined" ? window.getEmbedNamespace() : searchParams.get("embed") ?? null;
|
|
};
|
|
|
|
type CalcomThemeProps = Readonly<{
|
|
isBookingPage: boolean;
|
|
nonce: string | undefined;
|
|
children: React.ReactNode;
|
|
isThemeSupported: boolean;
|
|
}>;
|
|
|
|
const CalcomThemeProvider = (props: CalcomThemeProps) => {
|
|
// Use namespace of embed to ensure same namespaced embed are displayed with same theme. This allows different embeds on the same website to be themed differently
|
|
// One such example is our Embeds Demo and Testing page at http://localhost:3100
|
|
// Having `getEmbedNamespace` defined on window before react initializes the app, ensures that embedNamespace is available on the first mount and can be used as part of storageKey
|
|
const searchParams = useSearchParams();
|
|
const embedNamespace = searchParams ? getEmbedNamespace(searchParams) : null;
|
|
const isEmbedMode = typeof embedNamespace === "string";
|
|
const pathname = usePathname();
|
|
const { key, ...themeProviderProps } = getThemeProviderProps({
|
|
props,
|
|
isEmbedMode,
|
|
embedNamespace,
|
|
pathname,
|
|
searchParams,
|
|
});
|
|
|
|
return (
|
|
<ThemeProvider key={key} {...themeProviderProps}>
|
|
{/* Embed Mode can be detected reliably only on client side here as there can be static generated pages as well which can't determine if it's embed mode at backend */}
|
|
{/* color-scheme makes background:transparent not work in iframe which is required by embed. */}
|
|
{typeof window !== "undefined" && !isEmbedMode && (
|
|
//eslint-disable-next-line react/no-unknown-property
|
|
<style jsx global>
|
|
{`
|
|
.dark {
|
|
color-scheme: dark;
|
|
}
|
|
`}
|
|
</style>
|
|
)}
|
|
{props.children}
|
|
</ThemeProvider>
|
|
);
|
|
};
|
|
|
|
function FeatureFlagsProvider({ children }: { children: React.ReactNode }) {
|
|
const flags = useFlags();
|
|
return <FeatureProvider value={flags}>{children}</FeatureProvider>;
|
|
}
|
|
|
|
function useOrgBrandingValues() {
|
|
const session = useSession();
|
|
return session?.data?.user.org;
|
|
}
|
|
|
|
function OrgBrandProvider({ children }: { children: React.ReactNode }) {
|
|
const orgBrand = useOrgBrandingValues();
|
|
return <OrgBrandingProvider value={{ orgBrand }}>{children}</OrgBrandingProvider>;
|
|
}
|
|
|
|
const AppProviders = (props: PageWrapperProps) => {
|
|
// No need to have intercom on public pages - Good for Page Performance
|
|
const isBookingPage = useIsBookingPage();
|
|
const isThemeSupported = useIsThemeSupported();
|
|
const nuqsParams = useNuqsParams();
|
|
|
|
const RemainingProviders = (
|
|
<>
|
|
<TooltipProvider>
|
|
{/* color-scheme makes background:transparent not work which is required by embed. We need to ensure next-theme adds color-scheme to `body` instead of `html`(https://github.com/pacocoursey/next-themes/blob/main/src/index.tsx#L74). Once that's done we can enable color-scheme support */}
|
|
<CalcomThemeProvider
|
|
nonce={props.nonce}
|
|
isThemeSupported={isThemeSupported}
|
|
isBookingPage={props.isBookingPage || isBookingPage}>
|
|
<NuqsAdapter {...nuqsParams}>
|
|
<FeatureFlagsProvider>
|
|
{props.isBookingPage || isBookingPage ? (
|
|
<OrgBrandProvider>{props.children}</OrgBrandProvider>
|
|
) : (
|
|
<DynamicIntercomProvider>
|
|
<OrgBrandProvider>{props.children}</OrgBrandProvider>
|
|
</DynamicIntercomProvider>
|
|
)}
|
|
</FeatureFlagsProvider>
|
|
</NuqsAdapter>
|
|
</CalcomThemeProvider>
|
|
</TooltipProvider>
|
|
</>
|
|
);
|
|
|
|
if (props.isBookingPage || isBookingPage) {
|
|
return RemainingProviders;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<DynamicHelpscoutProvider>
|
|
<DynamicPostHogProvider>
|
|
<DynamicPostHogPageView />
|
|
{RemainingProviders}
|
|
</DynamicPostHogProvider>
|
|
</DynamicHelpscoutProvider>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default AppProviders;
|