Files
calendar/packages/features/bookings/lib/getLocationOptionsForSelect.ts
T
2d90d11e9e feat: Add custom label for organizer default app and link meeting (#23114)
* Create `CalVideoSettings` type

* Create `LocationOptionContainer`

* Extract cal video settings to `CalVideoSettings`

* Refactor `<Locations />` component to use `<CalVideoSettings />`

* Unify naming

* Move location folder back under components

* Type fixes

* Extract types

* Add custom label prop to default app types

* Extract `LocationInput` component

* Create `DefaultLocationSettings` component

* Move `locations` folder

* Add custom label field for link and organizer default locations

* Type fixes

* Save the custom label in db

* Include location custom label when querying db

* Display custom label on booking page

* Add translations

* Type fixes

* Change `customLabel` to `supportsCustomLabel`

* Remove unused code

* Show the customLabel on booking page

* Fix hover tooltip text as well

* Fix displaying exact value on booking page

* Add missing translation

* Remove default label of "Value"

* Replace nullish collescing with OR

* Replace nullish collescing with OR

---------

Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
2025-08-22 16:34:14 +00:00

33 lines
1.3 KiB
TypeScript

import type { LocationObject } from "@calcom/app-store/locations";
import { locationKeyToString } from "@calcom/app-store/locations";
import { getEventLocationType } 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";
export default function getLocationsOptionsForSelect(
locations: LocationObject[],
t: ReturnType<typeof useLocale>["t"]
) {
return locations
.map((location) => {
const eventLocation = getEventLocationType(location.type);
const locationString = locationKeyToString(location);
if (typeof locationString !== "string" || !eventLocation) {
// It's possible that location app got uninstalled
return null;
}
const type = eventLocation.type;
const translatedLocation = location.customLabel || getTranslatedLocation(location, eventLocation, t);
return {
// XYZ: is considered a namespace in i18next https://www.i18next.com/principles/namespaces and thus it gets cleaned up.
label: translatedLocation || locationString,
value: type,
inputPlaceholder: t(eventLocation?.attendeeInputPlaceholder || ""),
};
})
.filter(notEmpty);
}