import { SchedulingType } from "@prisma/client"; import { EventTypeSetupProps, FormValues } from "pages/event-types/[type]"; import { ComponentProps } from "react"; import { Controller, useFormContext, useWatch, Control } from "react-hook-form"; import { Options } from "react-select"; import CheckedTeamSelect, { CheckedSelectOption, } from "@calcom/features/eventtypes/components/CheckedTeamSelect"; import { WEBAPP_URL } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { Label, Select } from "@calcom/ui"; interface IMemberToValue { id: number | null; name: string | null; username: string | null; email: string; } const mapUserToValue = ({ id, name, username, email }: IMemberToValue) => ({ value: `${id || ""}`, label: `${name || ""}`, avatar: `${WEBAPP_URL}/${username}/avatar.png`, email, }); const FixedHosts = ({ control, labelText, placeholder, options = [], ...rest }: { control: Control; labelText: string; placeholder: string; options?: Options; } & Partial>) => { return (
{ return ( { onChange( options.map((option) => ({ isFixed: true, userId: parseInt(option.value, 10), })) ); }} value={value .map( (host) => // eslint-disable-next-line @typescript-eslint/no-non-null-assertion options.find((member) => member.value === host.userId.toString())! ) .filter(Boolean)} controlShouldRenderValue={false} options={options} placeholder={placeholder} {...rest} /> ); }} />
); }; export const EventTeamTab = ({ team, teamMembers }: Pick) => { const formMethods = useFormContext(); const { t } = useLocale(); const schedulingType = useWatch({ control: formMethods.control, name: "schedulingType", }); const schedulingTypeOptions: { value: SchedulingType; label: string; // description: string; }[] = [ { value: SchedulingType.COLLECTIVE, label: t("collective"), // description: t("collective_description"), }, { value: SchedulingType.ROUND_ROBIN, label: t("round_robin"), // description: t("round_robin_description"), }, ]; const teamMembersOptions = teamMembers.map(mapUserToValue); return (
{team && (
(