Skip to content

Scheduling infrastructure for absolutely everyone.

fix: Multiple In Person Locations not working as expected in Event Setup Tab (#9465)

Jaideep Guntupalli4d3026495068
diff --git a/apps/web/components/dialog/EditLocationDialog.tsx b/apps/web/components/dialog/EditLocationDialog.tsx
index 5b59ff4cd15..b8c8d219df6 100644
--- a/apps/web/components/dialog/EditLocationDialog.tsx
+++ b/apps/web/components/dialog/EditLocationDialog.tsx
@@ -91,6 +91,9 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
useEffect(() => {
if (selection) {
locationFormMethods.setValue("locationType", selection?.value);
+ if (selection?.address) {
+ locationFormMethods.setValue("locationAddress", selection?.address);
+ }
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [selection]);
@@ -152,12 +155,25 @@ export const EditLocationDialog = (props: ISetLocationDialog) => {
name: "locationType",
});
+ const selectedAddrValue = useWatch({
+ control: locationFormMethods.control,
+ name: "locationAddress",
+ });
+
const eventLocationType = getEventLocationType(selectedLocation);
const defaultLocation = defaultValues?.find(
- (location: { type: EventLocationType["type"] }) => location.type === eventLocationType?.type
+ (location: { type: EventLocationType["type"]; address?: string }) => {
+ if (location.type === LocationType.InPerson) {
+ return location.type === eventLocationType?.type && location.address === selectedAddrValue;
+ } else {
+ return location.type === eventLocationType?.type;
+ }
+ }
);
+ console.log(defaultLocation);
+
const LocationOptions = (() => {
if (eventLocationType && eventLocationType.organizerInputType && LocationInput) {
if (!eventLocationType.variable) {
diff --git a/apps/web/components/eventtype/EventSetupTab.tsx b/apps/web/components/eventtype/EventSetupTab.tsx
index 82e46844b71..f88f6028b3b 100644
--- a/apps/web/components/eventtype/EventSetupTab.tsx
+++ b/apps/web/components/eventtype/EventSetupTab.tsx
@@ -136,9 +136,17 @@ export const EventSetupTab = (
selectedMultipleDuration.find((opt) => opt.value === eventType.length) ?? null
);
- const openLocationModal = (type: EventLocationType["type"]) => {
+ const openLocationModal = (type: EventLocationType["type"], address = "") => {
const option = getLocationFromType(type, locationOptions);
- setSelectedLocation(option);
+ if (option && option.value === LocationType.InPerson) {
+ const inPersonOption = {
+ ...option,
+ address,
+ };
+ setSelectedLocation(inPersonOption);
+ } else {
+ setSelectedLocation(option);
+ }
setShowLocationModal(true);
};
@@ -298,10 +306,14 @@ export const EventSetupTab = (
onClick={() => {
locationFormMethods.setValue("locationType", location.type);
locationFormMethods.unregister("locationLink");
- locationFormMethods.unregister("locationAddress");
+ if (location.type === LocationType.InPerson) {
+ locationFormMethods.setValue("locationAddress", location.address);
+ } else {
+ locationFormMethods.unregister("locationAddress");
+ }
locationFormMethods.unregister("locationPhoneNumber");
setEditingLocationType(location.type);
- openLocationModal(location.type);
+ openLocationModal(location.type, location.address);
}}
aria-label={t("edit")}
className="hover:text-emphasis text-subtle mr-1 p-1">
@@ -517,7 +529,18 @@ export const EventSetupTab = (
defaultValues={formMethods.getValues("locations")}
selection={
selectedLocation
- ? { value: selectedLocation.value, label: t(selectedLocation.label), icon: selectedLocation.icon }
+ ? selectedLocation.address
+ ? {
+ value: selectedLocation.value,
+ label: t(selectedLocation.label),
+ icon: selectedLocation.icon,
+ address: selectedLocation.address,
+ }
+ : {
+ value: selectedLocation.value,
+ label: t(selectedLocation.label),
+ icon: selectedLocation.icon,
+ }
: undefined
}
setSelectedLocation={setSelectedLocation}
diff --git a/apps/web/components/ui/form/LocationSelect.tsx b/apps/web/components/ui/form/LocationSelect.tsx
index 846082b26d2..95f1a7eebeb 100644
--- a/apps/web/components/ui/form/LocationSelect.tsx
+++ b/apps/web/components/ui/form/LocationSelect.tsx
@@ -11,6 +11,7 @@ export type LocationOption = {
value: EventLocationType["type"];
icon?: string;
disabled?: boolean;
+ address?: string;
};
export type SingleValueLocationOption = SingleValue<LocationOption>;
diff --git a/packages/app-store/locations.ts b/packages/app-store/locations.ts
index 5eac81100fb..31ae8af722d 100644
--- a/packages/app-store/locations.ts
+++ b/packages/app-store/locations.ts
@@ -148,6 +148,7 @@ export const defaultLocations: DefaultEventLocationType[] = [
export type LocationObject = {
type: string;
+ address?: string;
displayLocationPublicly?: boolean;
} & Partial<
Record<"address" | "attendeeAddress" | "link" | "hostPhoneNumber" | "hostDefault" | "phone", string>