fix: display organizer location after booking (#12088)
Co-authored-by: Hariom Balhara <[email protected]>
This commit is contained in:
1 parent
63f2f6edba
commit
621f7639ff
5 files changed
+132
-14
No files matched your search
@@ -427,3 +427,11 @@ export const getTranslatedLocation = (
|
||||
|
||||
return translatedLocation;
|
||||
};
|
||||
|
||||
export const getOrganizerInputLocationsType = () => {
|
||||
const locationTypes: DefaultEventLocationType["type"] | EventLocationTypeFromApp["type"][] = [];
|
||||
const locations = locationsTypes.filter((location) => !!location.organizerInputType);
|
||||
locations?.forEach((l) => locationTypes.push(l.type));
|
||||
|
||||
return locationTypes;
|
||||
};
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useFormContext } from "react-hook-form";
|
||||
|
||||
import type { LocationObject } from "@calcom/app-store/locations";
|
||||
import { getOrganizerInputLocationsType } from "@calcom/app-store/locations";
|
||||
import type { GetBookingType } from "@calcom/features/bookings/lib/get-booking";
|
||||
import getLocationOptionsForSelect from "@calcom/features/bookings/lib/getLocationOptionsForSelect";
|
||||
import { FormBuilderField } from "@calcom/features/form-builder/FormBuilderField";
|
||||
@@ -105,6 +106,29 @@ export const BookingFields = ({
|
||||
);
|
||||
}
|
||||
|
||||
if (field?.options) {
|
||||
const organzierInputTypes = getOrganizerInputLocationsType();
|
||||
const organzierInputObj: Record<string, number> = {};
|
||||
|
||||
field.options.forEach((f) => {
|
||||
if (f.value in organzierInputObj) {
|
||||
organzierInputObj[f.value]++;
|
||||
} else {
|
||||
organzierInputObj[f.value] = 1;
|
||||
}
|
||||
});
|
||||
|
||||
field.options = field.options.map((field) => {
|
||||
return {
|
||||
...field,
|
||||
value:
|
||||
organzierInputTypes.includes(field.value) && organzierInputObj[field.value] > 1
|
||||
? field.label
|
||||
: field.value,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<FormBuilderField className="mb-4" field={{ ...field, hidden }} readOnly={readOnly} key={index} />
|
||||
);
|
||||
|
||||
@@ -311,9 +311,8 @@ export const ComponentForField = ({
|
||||
if (!field.optionsInputs) {
|
||||
throw new Error("Field optionsInputs is not defined");
|
||||
}
|
||||
const options = field.options.map((field) => {
|
||||
return { ...field, value: field.value === "inPerson" ? field.label : field.value };
|
||||
});
|
||||
|
||||
const options = field.options;
|
||||
|
||||
return field.options.length ? (
|
||||
<WithLabel field={field} readOnly={readOnly}>
|
||||
|
||||
Reference in new issue
Block a user