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, CheckboxField, Dialog, DialogContent, DialogFooter, Form, TextField, Label, ToggleGroup, } from "@calcom/ui"; 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: MembershipRole; 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}} )} /> (
)} /> ( newMemberFormMethods.setValue("sendInviteEmail", e.target.checked)} /> )} />
); }