* Revert "fix: revert bookings redesign (#25172)"
This reverts commit 1f102bf3b4.
* add bookings-v3 feature flag
* put things behind a feature flag
* remove no longer needed test
* revert e2e tests
* put back description
* revert AvatarGroup
* apply feedback
* remove "view" booking action
* remove Alert (When the bookings query errors, this branch now renders only the alert and skips the data-table filter/segment controls. Those controls moved into BookingsList, so in error states users can no longer clear or tweak filters to recover from the failure, effectively trapping them behind the alert.)
* address feedback
* revert useMediaQuery
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import type { TFunction } from "i18next";
|
|
import { useMemo } from "react";
|
|
|
|
import { useBookingLocation } from "@calcom/features/bookings/hooks";
|
|
import type { BookingStatus } from "@calcom/prisma/enums";
|
|
import { bookingMetadataSchema } from "@calcom/prisma/zod-utils";
|
|
|
|
interface UseJoinableLocationParams {
|
|
location: string | null;
|
|
metadata?: unknown;
|
|
bookingStatus: BookingStatus;
|
|
t: TFunction;
|
|
}
|
|
|
|
/**
|
|
* Custom hook to determine if a booking location is joinable (i.e., has a clickable URL).
|
|
* This hook is used to show/hide the join meeting button and related UI elements.
|
|
*
|
|
* @returns An object containing:
|
|
* - `isJoinable`: Whether the location is joinable (has a valid URL)
|
|
* - `locationToDisplay`: The location URL or text to display
|
|
* - `provider`: Provider information (label, iconUrl, etc.)
|
|
* - `isLocationURL`: Whether the location is a URL
|
|
*/
|
|
export function useJoinableLocation({ location, metadata, bookingStatus, t }: UseJoinableLocationParams) {
|
|
const bookingMetadata = useMemo(() => {
|
|
const parsedMetadata = bookingMetadataSchema.safeParse(metadata ?? null);
|
|
return parsedMetadata.success ? parsedMetadata.data : null;
|
|
}, [metadata]);
|
|
|
|
const { locationToDisplay, provider, isLocationURL } = useBookingLocation({
|
|
location,
|
|
videoCallUrl: bookingMetadata?.videoCallUrl,
|
|
t,
|
|
bookingStatus,
|
|
});
|
|
|
|
const isJoinable = isLocationURL && !!locationToDisplay;
|
|
|
|
return {
|
|
isJoinable,
|
|
locationToDisplay,
|
|
provider,
|
|
isLocationURL,
|
|
};
|
|
}
|