refactor: rename getEventLocationType to getLocationByType for better clarity (#28567)
* chore: rename getEventLocationType * chore: update imports
This commit is contained in:
1 parent
761b780aa2
commit
f004349273
10 files changed
+45
-46
No files matched your search
@@ -7,7 +7,7 @@ import { z } from "zod";
|
||||
|
||||
import type { EventLocationType, LocationObject } from "@calcom/app-store/locations";
|
||||
import {
|
||||
getEventLocationType,
|
||||
getLocationByType,
|
||||
getHumanReadableLocationValue,
|
||||
getMessageForOrganizer,
|
||||
isAttendeeInputRequired,
|
||||
@@ -168,7 +168,7 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
|
||||
name: "locationAddress",
|
||||
});
|
||||
|
||||
const eventLocationType = getEventLocationType(selectedLocation);
|
||||
const eventLocationType = getLocationByType(selectedLocation);
|
||||
|
||||
const defaultLocation = defaultValues?.find(
|
||||
(location: { type: EventLocationType["type"]; address?: string }) => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import type {
|
||||
EventLocationTypeFromApp,
|
||||
LocationObject,
|
||||
} from "@calcom/app-store/locations";
|
||||
import { getEventLocationType, getTranslatedLocation } from "@calcom/app-store/locations";
|
||||
import { getLocationByType, getTranslatedLocation } from "@calcom/app-store/locations";
|
||||
import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import invertLogoOnDark from "@calcom/lib/invertLogoOnDark";
|
||||
@@ -43,7 +43,7 @@ function RenderLocationTooltip({ locations }: { locations: LocationObject[] }) {
|
||||
Omit<LocationObject, "link" | "address">,
|
||||
index: number
|
||||
) => {
|
||||
const eventLocationType = getEventLocationType(location.type);
|
||||
const eventLocationType = getLocationByType(location.type);
|
||||
if (!eventLocationType) {
|
||||
return null;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ export function AvailableEventLocations({ locations }: { locations: LocationObje
|
||||
location: Pick<Partial<LocationObject>, "link" | "address"> & Omit<LocationObject, "link" | "address">,
|
||||
index: number
|
||||
) => {
|
||||
const eventLocationType = getEventLocationType(location.type);
|
||||
const eventLocationType = getLocationByType(location.type);
|
||||
if (!eventLocationType) {
|
||||
// It's possible that the location app got uninstalled
|
||||
return null;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getEventLocationType, getTranslatedLocation } from "@calcom/app-store/locations";
|
||||
import { getLocationByType, getTranslatedLocation } from "@calcom/app-store/locations";
|
||||
import type { BookerEvent } from "@calcom/features/bookings/types";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { Tooltip } from "@calcom/ui/components/tooltip";
|
||||
@@ -13,12 +13,12 @@ export const EventLocations = ({ event }: { event: BookerEvent }) => {
|
||||
if (!locations?.length) return null;
|
||||
|
||||
const getLocationToDisplay = (location: BookerEvent["locations"][number]) => {
|
||||
const eventLocationType = getEventLocationType(location.type);
|
||||
const eventLocationType = getLocationByType(location.type);
|
||||
const translatedLocation = getTranslatedLocation(location, eventLocationType, t);
|
||||
|
||||
return translatedLocation;
|
||||
};
|
||||
const eventLocationType = getEventLocationType(locations[0].type);
|
||||
const eventLocationType = getLocationByType(locations[0].type);
|
||||
const iconUrl = locations.length > 1 || !eventLocationType?.iconUrl ? undefined : eventLocationType.iconUrl;
|
||||
const icon = locations.length > 1 || !eventLocationType?.iconUrl ? "map-pin" : undefined;
|
||||
|
||||
@@ -44,14 +44,14 @@ export const EventLocations = ({ event }: { event: BookerEvent }) => {
|
||||
<li key={`${location.type}-${index}`} className="mt-1">
|
||||
<div className="flex flex-row items-center">
|
||||
<img
|
||||
src={getEventLocationType(location.type)?.iconUrl}
|
||||
src={getLocationByType(location.type)?.iconUrl}
|
||||
className={classNames(
|
||||
"h-3 w-3 opacity-70 ltr:mr-[10px] rtl:ml-[10px] dark:opacity-100 ",
|
||||
!getEventLocationType(location.type)?.iconUrl?.startsWith("/app-store")
|
||||
!getLocationByType(location.type)?.iconUrl?.startsWith("/app-store")
|
||||
? "dark:invert-[.65]"
|
||||
: ""
|
||||
)}
|
||||
alt={`${getEventLocationType(location.type)?.label} icon`}
|
||||
alt={`${getLocationByType(location.type)?.label} icon`}
|
||||
/>
|
||||
<span>{getLocationToDisplay(location)}</span>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ErrorMessage } from "@hookform/error-message";
|
||||
import { useFieldArray, useFormContext } from "react-hook-form";
|
||||
|
||||
import { getEventLocationType } from "@calcom/app-store/locations";
|
||||
import { getLocationByType } from "@calcom/app-store/locations";
|
||||
import type { LocationCustomClassNames } from "@calcom/features/eventtypes/components/locations/types";
|
||||
import type { LocationFormValues, FormValues } from "@calcom/features/eventtypes/lib/types";
|
||||
import CheckboxField from "@calcom/features/form/components/CheckboxField";
|
||||
@@ -30,7 +30,7 @@ const DefaultLocationSettings = ({
|
||||
name: "locations",
|
||||
});
|
||||
const defaultLocation = field;
|
||||
const eventLocationType = getEventLocationType(field.type);
|
||||
const eventLocationType = getLocationByType(field.type);
|
||||
|
||||
if (!eventLocationType) return null;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { appStoreMetadata } from "@calcom/app-store/appStoreMetaData";
|
||||
import {
|
||||
defaultLocations,
|
||||
getAppSlugFromLocationType,
|
||||
getEventLocationType,
|
||||
getLocationByType,
|
||||
isCalVideoLocation,
|
||||
isStaticLocationType,
|
||||
} from "@calcom/app-store/locations";
|
||||
@@ -84,7 +84,7 @@ const filterOutBookerInputLocations = (options: TLocationOptions): TLocationOpti
|
||||
.map((group) => ({
|
||||
...group,
|
||||
options: group.options.filter((opt) => {
|
||||
const locationType = getEventLocationType(opt.value);
|
||||
const locationType = getLocationByType(opt.value);
|
||||
return !locationType?.attendeeInputType;
|
||||
}),
|
||||
}))
|
||||
@@ -111,7 +111,7 @@ const LocationInputDialog = ({
|
||||
initialValue = "",
|
||||
}: LocationInputDialogProps) => {
|
||||
const { t } = useLocale();
|
||||
const eventLocationType = locationOption ? getEventLocationType(locationOption.value) : null;
|
||||
const eventLocationType = locationOption ? getLocationByType(locationOption.value) : null;
|
||||
const [inputValue, setInputValue] = useState(initialValue);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -211,7 +211,7 @@ const buildHostLocation = (
|
||||
hostData: HostWithLocationOptions | undefined,
|
||||
inputValue?: string
|
||||
): HostLocation => {
|
||||
const eventLocationType = getEventLocationType(locationOption.value);
|
||||
const eventLocationType = getLocationByType(locationOption.value);
|
||||
const credential = findHostCredential(hostData, locationOption.value);
|
||||
|
||||
const location: HostLocation = {
|
||||
@@ -287,7 +287,7 @@ const HostLocationRow = ({
|
||||
[currentLocation, hostData, locationOptions]
|
||||
);
|
||||
|
||||
const currentLocationEventType = currentLocation ? getEventLocationType(currentLocation.type) : null;
|
||||
const currentLocationEventType = currentLocation ? getLocationByType(currentLocation.type) : null;
|
||||
const hasOrganizerInput = !!currentLocationEventType?.organizerInputType;
|
||||
|
||||
const currentLocationValue = useMemo(() => {
|
||||
@@ -303,7 +303,7 @@ const HostLocationRow = ({
|
||||
onLocationChange(host.userId, null);
|
||||
return;
|
||||
}
|
||||
if (getEventLocationType(option.value)?.organizerInputType) {
|
||||
if (getLocationByType(option.value)?.organizerInputType) {
|
||||
setPendingLocationOption(option);
|
||||
setIsDialogOpen(true);
|
||||
return;
|
||||
@@ -454,13 +454,13 @@ const MassApplyLocationDialog = ({ isOpen, onClose, onApply, isApplying }: MassA
|
||||
const { selectedType, setSelectedType, inputValue, setInputValue, reset } = useMassApplyDialogState(isOpen);
|
||||
const allLocationOptions = useMemo(() => {
|
||||
return getAllLocationOptions().filter((opt) => {
|
||||
const locationType = getEventLocationType(opt.value);
|
||||
const locationType = getLocationByType(opt.value);
|
||||
return !locationType?.attendeeInputType;
|
||||
});
|
||||
}, []);
|
||||
|
||||
const selectedOption = allLocationOptions.find((o) => o.value === selectedType);
|
||||
const eventLocationType = selectedType ? getEventLocationType(selectedType) : null;
|
||||
const eventLocationType = selectedType ? getLocationByType(selectedType) : null;
|
||||
const needsInput = eventLocationType?.organizerInputType;
|
||||
|
||||
const handleClose = () => {
|
||||
@@ -551,7 +551,7 @@ const MassApplyLocationDialog = ({ isOpen, onClose, onApply, isApplying }: MassA
|
||||
};
|
||||
|
||||
type LocationInputFieldProps = {
|
||||
eventLocationType: ReturnType<typeof getEventLocationType>;
|
||||
eventLocationType: ReturnType<typeof getLocationByType>;
|
||||
inputValue: string;
|
||||
setInputValue: (value: string) => void;
|
||||
};
|
||||
@@ -620,7 +620,7 @@ const buildFullLocationOptions = (
|
||||
const locationData = app.appData?.location;
|
||||
if (!locationData || existingValues.has(locationData.type)) continue;
|
||||
|
||||
const locationType = getEventLocationType(locationData.type);
|
||||
const locationType = getLocationByType(locationData.type);
|
||||
if (locationType?.attendeeInputType) continue;
|
||||
|
||||
existingValues.add(locationData.type);
|
||||
@@ -789,7 +789,7 @@ const useMassApplyMutation = (
|
||||
});
|
||||
|
||||
const handleMassApply = (locationType: string, inputValue?: string) => {
|
||||
const evtLocType = getEventLocationType(locationType);
|
||||
const evtLocType = getLocationByType(locationType);
|
||||
const link = evtLocType?.defaultValueVariable === "link" ? inputValue : undefined;
|
||||
const address = evtLocType?.defaultValueVariable === "address" ? inputValue : undefined;
|
||||
const phoneNumber = evtLocType?.organizerInputType === "phone" ? inputValue : undefined;
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useFieldArray } from "react-hook-form";
|
||||
import type { UseFormGetValues, UseFormSetValue, Control, FormState } from "react-hook-form";
|
||||
|
||||
import type { EventLocationType } from "@calcom/app-store/locations";
|
||||
import { getEventLocationType, MeetLocationType } from "@calcom/app-store/locations";
|
||||
import { getLocationByType, MeetLocationType } from "@calcom/app-store/locations";
|
||||
import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";
|
||||
import type { LocationCustomClassNames } from "@calcom/features/eventtypes/components/locations/types";
|
||||
import type { LocationFormValues, EventTypeSetupProps } from "@calcom/features/eventtypes/lib/types";
|
||||
@@ -124,7 +124,7 @@ const Locations: React.FC<LocationsProps> = ({
|
||||
|
||||
const validLocations =
|
||||
getValues("locations")?.filter((location) => {
|
||||
const eventLocation = getEventLocationType(location.type);
|
||||
const eventLocation = getLocationByType(location.type);
|
||||
if (!eventLocation) {
|
||||
// It's possible that the location app in use got uninstalled.
|
||||
return false;
|
||||
@@ -169,7 +169,7 @@ const Locations: React.FC<LocationsProps> = ({
|
||||
<div className={classNames("w-full", customClassNames?.container)}>
|
||||
<ul ref={animationRef} className={classNames("stack-y-2")}>
|
||||
{locationFields.map((field, index) => {
|
||||
const eventLocationType = getEventLocationType(field.type);
|
||||
const eventLocationType = getLocationByType(field.type);
|
||||
const defaultLocation = field;
|
||||
|
||||
const isCalVideo = field.type === "integrations:daily";
|
||||
@@ -195,7 +195,7 @@ const Locations: React.FC<LocationsProps> = ({
|
||||
setShowEmptyLocationSelect(false);
|
||||
if (e?.value) {
|
||||
const newLocationType = e.value;
|
||||
const eventLocationType = getEventLocationType(newLocationType);
|
||||
const eventLocationType = getLocationByType(newLocationType);
|
||||
if (!eventLocationType) {
|
||||
return;
|
||||
}
|
||||
@@ -340,7 +340,7 @@ const Locations: React.FC<LocationsProps> = ({
|
||||
setShowEmptyLocationSelect(false);
|
||||
if (e?.value) {
|
||||
const newLocationType = e.value;
|
||||
const eventLocationType = getEventLocationType(newLocationType);
|
||||
const eventLocationType = getLocationByType(newLocationType);
|
||||
if (!eventLocationType) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user