Scheduling infrastructure for absolutely everyone.
feat: :sparkles: Show dialog only for InPerson and Link locations (#2206)
Miguel Nieto A6ed945943a84
diff --git a/apps/web/pages/event-types/[type].tsx b/apps/web/pages/event-types/[type].tsxindex f7e24c6b91b..90f1081356e 100644--- a/apps/web/pages/event-types/[type].tsx+++ b/apps/web/pages/event-types/[type].tsx@@ -274,6 +274,23 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {);};+ const addLocation = (newLocationType: LocationType, details = {}) => {+ const existingIdx = formMethods.getValues("locations").findIndex((loc) => newLocationType === loc.type);+ if (existingIdx !== -1) {+ const copy = formMethods.getValues("locations");+ copy[existingIdx] = {+ ...formMethods.getValues("locations")[existingIdx],+ ...details,+ };+ formMethods.setValue("locations", copy);+ } else {+ formMethods.setValue(+ "locations",+ formMethods.getValues("locations").concat({ type: newLocationType, ...details })+ );+ }+ };+const LocationOptions = () => {if (!selectedLocation) {return null;@@ -457,8 +474,13 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {className="react-select-container focus:border-primary-500 focus:ring-primary-500 block w-full min-w-0 flex-1 rounded-sm border border-gray-300 sm:text-sm"onChange={(e) => {if (e?.value) {- locationFormMethods.setValue("locationType", e.value);- openLocationModal(e.value);+ const newLocationType: LocationType = e.value;+ locationFormMethods.setValue("locationType", newLocationType);+ if (newLocationType === LocationType.InPerson || newLocationType === LocationType.Link) {+ openLocationModal(newLocationType);+ } else {+ addLocation(newLocationType);+ }}}}/>@@ -1587,26 +1609,11 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {if (newLocation === LocationType.InPerson) {details = { address: values.locationAddress };}-if (newLocation === LocationType.Link) {details = { link: values.locationLink };}- const existingIdx = formMethods- .getValues("locations")- .findIndex((loc) => values.locationType === loc.type);- if (existingIdx !== -1) {- const copy = formMethods.getValues("locations");- copy[existingIdx] = {- ...formMethods.getValues("locations")[existingIdx],- ...details,- };- formMethods.setValue("locations", copy);- } else {- formMethods.setValue(- "locations",- formMethods.getValues("locations").concat({ type: values.locationType, ...details })- );- }++ addLocation(newLocation, details);setShowLocationModal(false);}}><Controller