fix: add location publicly

fix/organizer-location
Udit Takkar 2023-10-26 15:22:48 +05:30
parent 52b3120fd9
commit 82c5f6f22c
1 changed files with 13 additions and 11 deletions

View File

@ -8,7 +8,7 @@ import { Controller, useFormContext, useFieldArray } from "react-hook-form";
import type { MultiValue } from "react-select"; import type { MultiValue } from "react-select";
import type { EventLocationType } from "@calcom/app-store/locations"; import type { EventLocationType } from "@calcom/app-store/locations";
import { getEventLocationType, LocationType, MeetLocationType } from "@calcom/app-store/locations"; import { getEventLocationType, MeetLocationType } from "@calcom/app-store/locations";
import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager"; import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider"; import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
import { CAL_URL } from "@calcom/lib/constants"; import { CAL_URL } from "@calcom/lib/constants";
@ -256,17 +256,18 @@ export const EventSetupTab = (
const [showEmptyLocationSelect, setShowEmptyLocationSelect] = useState(false); const [showEmptyLocationSelect, setShowEmptyLocationSelect] = useState(false);
const [selectedNewOption, setSelectedNewOption] = useState<SingleValueLocationOption | null>(null); const [selectedNewOption, setSelectedNewOption] = useState<SingleValueLocationOption | null>(null);
return ( return (
<div className="w-full"> <div className="w-full">
<ul ref={animationRef} className="space-y-2"> <ul ref={animationRef} className="space-y-2">
{locationFields.map((field, index) => { {locationFields.map((field, index) => {
const eventLocationType = getEventLocationType(field.type); const eventLocationType = getEventLocationType(field.type);
const defaultLocation = formMethods const defaultLocation = formMethods.getValues("locations")?.find((location) => {
.getValues("locations") if (eventLocationType?.organizerInputType) {
?.find((location: { type: EventLocationType["type"]; address?: string }) => { return (
if (location.type === LocationType.InPerson) { location.type === eventLocationType?.type &&
return location.type === eventLocationType?.type && location.address === field?.address; location[eventLocationType.defaultValueVariable] ===
field?.[eventLocationType.defaultValueVariable]
);
} else { } else {
return location.type === eventLocationType?.type; return location.type === eventLocationType?.type;
} }
@ -338,6 +339,7 @@ export const EventSetupTab = (
</div> </div>
<div className="ml-6"> <div className="ml-6">
<CheckboxField <CheckboxField
name={`locations[${index}].displayLocationPublicly`}
data-testid="display-location" data-testid="display-location"
defaultChecked={defaultLocation?.displayLocationPublicly} defaultChecked={defaultLocation?.displayLocationPublicly}
description={t("display_location_label")} description={t("display_location_label")}