import { MembershipRole } from "@prisma/client"; import { Trans } from "next-i18next"; import { useMemo } from "react"; import { Controller, useForm } from "react-hook-form"; import { IS_TEAM_BILLING_ENABLED } from "@calcom/lib/constants"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { Button, TextField } from "@calcom/ui/components"; import CheckboxField from "@calcom/ui/components/form/checkbox/Checkbox"; import { Form } from "@calcom/ui/form/fields"; import { Dialog, DialogContent, DialogFooter, Select } from "@calcom/ui/v2"; import { PendingMember } from "../lib/types"; type MemberInvitationModalProps = { isOpen: boolean; onExit: () => void; onSubmit: (values: NewMemberForm) => void; members: PendingMember[]; }; type MembershipRoleOption = { value: MembershipRole; label: string; }; export interface NewMemberForm { emailOrUsername: string; role: MembershipRoleOption; sendInviteEmail: boolean; } export default function MemberInvitationModal(props: MemberInvitationModalProps) { const { t } = useLocale(); const options: MembershipRoleOption[] = useMemo(() => { return [ { value: "MEMBER", label: t("member") }, { value: "ADMIN", label: t("admin") }, { value: "OWNER", label: t("owner") }, ]; }, [t]); const newMemberFormMethods = useForm(); const validateUniqueInvite = (value: string) => { return !( props.members.some((member) => member?.username === value) || props.members.some((member) => member?.email === value) ); }; return ( { props.onExit(); newMemberFormMethods.reset(); }}> Note: This will cost an extra seat ($15/m){" "} on your subscription. ) : ( "" ) }>
props.onSubmit(values)}>
validateUniqueInvite(value) || t("member_already_invited"), }} render={({ field: { onChange }, fieldState: { error } }) => ( <> {error && {error.message}} )} /> (