Fixing items readded to location dropdown issue (#1316)

Co-authored-by: Manoj <yogeshwaranmanoharan@gmail.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
This commit is contained in:
Omar López 2021-12-14 15:14:35 -07:00 committed by GitHub
parent 7e6d56ca1f
commit 5deea2c5f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,6 +59,19 @@ import * as RadioArea from "@components/ui/form/radio-area";
dayjs.extend(utc); dayjs.extend(utc);
dayjs.extend(timezone); dayjs.extend(timezone);
const addDefaultLocationOptions = (
defaultLocations: OptionTypeBase[],
locationOptions: OptionTypeBase[]
): void => {
const existingLocationOptions = locationOptions.flatMap((locationOptionItem) => [locationOptionItem.value]);
defaultLocations.map((item) => {
if (!existingLocationOptions.includes(item.value)) {
locationOptions.push(item);
}
});
};
const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => { const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
const { t } = useLocale(); const { t } = useLocale();
const PERIOD_TYPES = [ const PERIOD_TYPES = [
@ -77,10 +90,15 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
]; ];
const { eventType, locationOptions, availability, team, teamMembers, hasPaymentIntegration, currency } = const { eventType, locationOptions, availability, team, teamMembers, hasPaymentIntegration, currency } =
props; props;
locationOptions.push(
/** Appending default locations */
const defaultLocations = [
{ value: LocationType.InPerson, label: t("in_person_meeting") }, { value: LocationType.InPerson, label: t("in_person_meeting") },
{ value: LocationType.Phone, label: t("phone_call") } { value: LocationType.Phone, label: t("phone_call") },
); ];
addDefaultLocationOptions(defaultLocations, locationOptions);
const router = useRouter(); const router = useRouter();