refactor: rename getEventLocationType to getLocationByType for better clarity (#28567)

* chore: rename getEventLocationType

* chore: update imports
This commit is contained in:
Anirban Singha authored and GitHub committed 2026-07-09 09:22:35 +00:00
1 parent 761b780aa2
commit f004349273
10 files changed
+45 -46

No files matched your search

+10 -11
View File
@@ -280,8 +280,7 @@ const locations = [...defaultLocations, ...locationsFromApps];
export const getLocationFromApp = (locationType: string) =>
locationsFromApps.find((l) => l.type === locationType);
// TODO: Rename this to getLocationByType()
export const getEventLocationType = (locationType: string | undefined | null) =>
export const getLocationByType = (locationType: string | undefined | null) =>
locations.find((l) => l.type === locationType);
const getStaticLinkLocationByValue = (value: string | undefined | null) => {
@@ -297,7 +296,7 @@ const getStaticLinkLocationByValue = (value: string | undefined | null) => {
};
export const guessEventLocationType = (locationTypeOrValue: string | undefined | null) =>
getEventLocationType(locationTypeOrValue) || getStaticLinkLocationByValue(locationTypeOrValue);
getLocationByType(locationTypeOrValue) || getStaticLinkLocationByValue(locationTypeOrValue);
export const LocationType = { ...DefaultEventLocationTypeEnum, ...AppStoreLocationType };
@@ -322,7 +321,7 @@ type PrivacyFilteredLocationObject = Optional<LocationObject, "address" | "link"
export const privacyFilteredLocations = (locations: LocationObject[]): PrivacyFilteredLocationObject[] => {
const locationsAfterPrivacyFilter = locations.map((location) => {
const eventLocationType = getEventLocationType(location.type);
const eventLocationType = getLocationByType(location.type);
if (!eventLocationType) {
logger.debug(`Couldn't find location type. App might be uninstalled: ${location.type} `);
}
@@ -372,7 +371,7 @@ export const getHumanReadableLocationValue = (
}
// Just in case linkValue is a `locationType.type`(for old bookings)
const eventLocationType = getEventLocationType(linkValue);
const eventLocationType = getLocationByType(linkValue);
const isDefault = eventLocationType?.default;
if (eventLocationType) {
// If we can find a video location based on linkValue then it means that the linkValue is something like integrations:google-meet and in that case we don't have the meeting URL to show.
@@ -384,7 +383,7 @@ export const getHumanReadableLocationValue = (
};
export const locationKeyToString = (location: LocationObject) => {
const eventLocationType = getEventLocationType(location.type);
const eventLocationType = getLocationByType(location.type);
if (!eventLocationType) {
return null;
}
@@ -418,7 +417,7 @@ export const getLocationValueForDB = (
eventLocations.forEach((location) => {
if (location.type === bookingLocationTypeOrValue) {
const eventLocationType = getEventLocationType(bookingLocationTypeOrValue);
const eventLocationType = getLocationByType(bookingLocationTypeOrValue);
conferenceCredentialId = location.credentialId;
if (!eventLocationType) {
return;
@@ -441,7 +440,7 @@ export const getLocationValueForDB = (
};
export const getEventLocationValue = (eventLocations: LocationObject[], bookingLocation: LocationObject) => {
const eventLocationType = getEventLocationType(bookingLocation?.type);
const eventLocationType = getLocationByType(bookingLocation?.type);
if (!eventLocationType) {
return "";
}
@@ -470,7 +469,7 @@ export function getSuccessPageLocationMessage(
t: TFunction,
bookingStatus?: BookingStatus
) {
const eventLocationType = getEventLocationType(location);
const eventLocationType = getLocationByType(location);
let locationToDisplay = location;
if (eventLocationType && !eventLocationType.default && eventLocationType.linkType === "dynamic") {
const isConfirmed = bookingStatus === BookingStatus.ACCEPTED;
@@ -490,7 +489,7 @@ export function getSuccessPageLocationMessage(
export const getTranslatedLocation = (
location: PrivacyFilteredLocationObject,
eventLocationType: ReturnType<typeof getEventLocationType>,
eventLocationType: ReturnType<typeof getLocationByType>,
t: TFunction
) => {
if (!eventLocationType) return null;
@@ -546,7 +545,7 @@ export const locationsResolver = (t: TFunction) => {
.superRefine((val, ctx) => {
if (val?.link) {
const link = val.link;
const eventLocationType = getEventLocationType(val.type);
const eventLocationType = getLocationByType(val.type);
if (
eventLocationType &&
!eventLocationType.default &&
@@ -4,7 +4,7 @@ import { useForm } from "react-hook-form";
import { z } from "zod";
import type { EventLocationType } from "@calcom/app-store/locations";
import { getEventLocationType } from "@calcom/app-store/locations";
import { getLocationByType } from "@calcom/app-store/locations";
import { Dialog } from "@calcom/features/components/controlled-dialog";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Button } from "@calcom/ui/components/button";
@@ -37,7 +37,7 @@ export function AppSetDefaultLinkDialog({
handleUpdateUserDefaultConferencingApp: (params: UpdateUsersDefaultConferencingAppParams) => void;
}) {
const { t } = useLocale();
const eventLocationTypeOptions = getEventLocationType(locationType.type);
const eventLocationTypeOptions = getLocationByType(locationType.type);
const form = useForm<LocationTypeSetLinkDialogFormProps>({
resolver: zodResolver(
@@ -1,6 +1,6 @@
import type { LocationObject } from "@calcom/app-store/locations";
import { locationKeyToString } from "@calcom/app-store/locations";
import { getEventLocationType } from "@calcom/app-store/locations";
import { getLocationByType } from "@calcom/app-store/locations";
import { getTranslatedLocation } from "@calcom/app-store/locations";
import type { useLocale } from "@calcom/lib/hooks/useLocale";
import notEmpty from "@calcom/lib/notEmpty";
@@ -11,7 +11,7 @@ export default function getLocationsOptionsForSelect(
) {
return locations
.map((location) => {
const eventLocation = getEventLocationType(location.type);
const eventLocation = getLocationByType(location.type);
const locationString = locationKeyToString(location);
if (typeof locationString !== "string" || !eventLocation) {
@@ -1,5 +1,5 @@
import { getUsersCredentialsIncludeServiceAccountKey } from "@calcom/app-store/delegationCredential";
import { getEventLocationType, OrganizerDefaultConferencingAppType } from "@calcom/app-store/locations";
import { getLocationByType, OrganizerDefaultConferencingAppType } from "@calcom/app-store/locations";
import { getAppFromSlug } from "@calcom/app-store/utils";
import { sendLocationChangeEmailsAndSMS } from "@calcom/emails/email-manager";
import EventManager from "@calcom/features/bookings/lib/EventManager";
@@ -243,7 +243,7 @@ export function getLocationForOrganizerDefaultConferencingAppInEvtFormat({
}
const location = defaultConferencingAppLocationType;
const locationType = getEventLocationType(location);
const locationType = getLocationByType(location);
if (!locationType) {
throw new SystemError(`Location type not found: ${location}`);
}