Skip to content

Commit 013e614

Browse files
fix: handle empty location in event types (calcom#24342)
1 parent 6843ced commit 013e614

1 file changed

Lines changed: 5 additions & 15 deletions

File tree

packages/features/eventtypes/components/locations/Locations.tsx

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@ import { useAutoAnimate } from "@formkit/auto-animate/react";
22
import { ErrorMessage } from "@hookform/error-message";
33
import Link from "next/link";
44
import { useEffect, useState } from "react";
5-
import { useFieldArray, useFormContext } from "react-hook-form";
5+
import { useFieldArray } from "react-hook-form";
66
import type { UseFormGetValues, UseFormSetValue, Control, FormState } from "react-hook-form";
77

88
import type { EventLocationType } from "@calcom/app-store/locations";
99
import { getEventLocationType, MeetLocationType } from "@calcom/app-store/locations";
1010
import { useIsPlatform } from "@calcom/atoms/hooks/useIsPlatform";
11-
import type {
12-
LocationFormValues,
13-
EventTypeSetupProps,
14-
FormValues,
15-
} from "@calcom/features/eventtypes/lib/types";
11+
import type { LocationFormValues, EventTypeSetupProps } from "@calcom/features/eventtypes/lib/types";
1612
import CheckboxField from "@calcom/features/form/components/CheckboxField";
1713
import type { SingleValueLocationOption } from "@calcom/features/form/components/LocationSelect";
1814
import LocationSelect from "@calcom/features/form/components/LocationSelect";
@@ -34,10 +30,6 @@ export type TLocationOptions = Pick<EventTypeSetupProps, "locationOptions">["loc
3430
export type TDestinationCalendar = { integration: string } | null;
3531
export type TPrefillLocation = { credentialId?: number; type: string };
3632

37-
type LocationInputCustomClassNames = {
38-
addressInput?: string;
39-
phoneInput?: string;
40-
};
4133

4234
type LocationsProps = {
4335
team: { id: number } | null;
@@ -96,7 +88,7 @@ const Locations: React.FC<LocationsProps> = ({
9688
disableLocationProp,
9789
isManagedEventType,
9890
getValues,
99-
setValue,
91+
setValue: _setValue,
10092
control,
10193
formState,
10294
team,
@@ -116,8 +108,6 @@ const Locations: React.FC<LocationsProps> = ({
116108
name: "locations",
117109
});
118110

119-
const formMethods = useFormContext<FormValues>();
120-
121111
const locationOptions = props.locationOptions.map((locationOption) => {
122112
const options = locationOption.options.filter((option) => {
123113
// Skip "Organizer's Default App" for non-team members
@@ -172,8 +162,7 @@ const Locations: React.FC<LocationsProps> = ({
172162
setSelectedNewOption(prefillLocation);
173163
}
174164
}
175-
// eslint-disable-next-line react-hooks/exhaustive-deps
176-
}, [prefillLocation, seatsEnabled]);
165+
}, [prefillLocation, seatsEnabled, validLocations, append]);
177166

178167
const isPlatform = useIsPlatform();
179168

@@ -250,6 +239,7 @@ const Locations: React.FC<LocationsProps> = ({
250239
type="button"
251240
onClick={() => {
252241
remove(index);
242+
setSelectedNewOption(null);
253243
}}
254244
aria-label={t("remove")}>
255245
<div className="h-4 w-4">

0 commit comments

Comments
 (0)