import { z } from 'zod' import { useForm } from 'react-hook-form' import { zodResolver } from '@hookform/resolvers/zod' import { IconMailPlus, IconSend } from '@tabler/icons-react' import { showSubmittedData } from '@/utils/show-submitted-data' import { Button } from '@/components/ui/button' import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from '@/components/ui/form' import { Input } from '@/components/ui/input' import { Textarea } from '@/components/ui/textarea' import { SelectDropdown } from '@/components/select-dropdown' import { userTypes } from '../data/data' const formSchema = z.object({ email: z .string() .min(1, { message: 'Email is required.' }) .email({ message: 'Email is invalid.' }), role: z.string().min(1, { message: 'Role is required.' }), desc: z.string().optional(), }) type UserInviteForm = z.infer interface Props { open: boolean onOpenChange: (open: boolean) => void } export function UsersInviteDialog({ open, onOpenChange }: Props) { const form = useForm({ resolver: zodResolver(formSchema), defaultValues: { email: '', role: '', desc: '' }, }) const onSubmit = (values: UserInviteForm) => { form.reset() showSubmittedData(values) onOpenChange(false) } return ( { form.reset() onOpenChange(state) }} > Invite User Invite new user to join your team by sending them an email invitation. Assign a role to define their access level.
( Email )} /> ( Role ({ label, value, }))} /> )} /> ( Description (optional)