Files
calendar/apps/web/modules/bookings/components/useJoinableLocation.tsx
T
Benny JooGitHubbenny@cal.com <sldisek783@gmail.com>benny@cal.com <sldisek783@gmail.com>benny@cal.com <sldisek783@gmail.com>benny@cal.com <sldisek783@gmail.com>Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
b3430c8efc refactor: remove 10 trpc imports from features package by moving 16 tRPC-driven components to apps/web/modules (#27336)
* refactor: move Segment, BookerLayoutSelector, CreateLicenseKeyForm from packages/features to apps/web/modules

Co-Authored-By: benny@cal.com <sldisek783@gmail.com>

* fix: update relative imports to absolute paths in moved files

Co-Authored-By: benny@cal.com <sldisek783@gmail.com>

* refactor: move useBookingLocation and blocklist components from packages/features to apps/web/modules

Co-Authored-By: benny@cal.com <sldisek783@gmail.com>

* refactor: move EmbedTabs and embed hooks from packages/features to apps/web/modules

Co-Authored-By: benny@cal.com <sldisek783@gmail.com>

* fix

* migrate useBookerUrl

* migrate embed tabs

* fix

* fix

* fix

* mv ThemeLabel

* mv settings headers to webn

* update imports

* clean up

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-01-30 04:55:50 -03:00

47 lines
1.5 KiB
TypeScript

import type { TFunction } from "i18next";
import { useMemo } from "react";
import { useBookingLocation } from "@calcom/web/modules/bookings/hooks/useBookingLocation";
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,
};
}