import type { GroupBase, Props, SingleValue } from "react-select"; import { components } from "react-select"; import type { EventLocationType } from "@calcom/app-store/locations"; import { useIsPlatform } from "@calcom/atoms/monorepo"; import { classNames } from "@calcom/lib"; import invertLogoOnDark from "@calcom/lib/invertLogoOnDark"; import { Select, Icon } from "@calcom/ui"; export type LocationSelectCustomClassNames = { optionIcon?: string; optionLabel?: string; optionWrapper?: string; groupLabel?: string; selectWrapper?: string; }; export type LocationOption = { label: string; value: EventLocationType["type"]; icon?: string; disabled?: boolean; address?: string; credentialId?: number; teamName?: string; customClassNames?: LocationSelectCustomClassNames; }; export type SingleValueLocationOption = SingleValue; export type GroupOptionType = GroupBase; const OptionWithIcon = ({ icon, label, value, customClassNames, }: { icon?: string; label: string; value: string; customClassNames?: LocationSelectCustomClassNames; }) => { const isPlatform = useIsPlatform(); const getIconFromValue = (value: string) => { switch (value) { case "phone": return ; case "userPhone": return ; case "inPerson": return ; case "attendeeInPerson": return ; case "link": return ; case "somewhereElse": return ; default: return ; } }; if (isPlatform) { return (
{getIconFromValue(value)} {label}
); } return (
{icon && cover} {label}
); }; export default function LocationSelect({ customClassNames, ...props }: Props & { customClassNames?: LocationSelectCustomClassNames }) { const isPlatform = useIsPlatform(); return ( name="location" id="location-select" data-testid="location-select" components={{ Option: (props) => { return (
); }, SingleValue: (props) => { return (
); }, }} formatOptionLabel={(e, d) => (
{e.icon && !isPlatform && ( app-icon )} {e.label}
)} formatGroupLabel={(e) => (

{e.label}

)} {...props} /> ); }