'use client'; import type { ComponentProps } from 'react'; import type { FieldErrors, UseFormRegister } from 'react-hook-form'; import { Loader2 } from 'lucide-react'; import { FormField } from '@/components/form'; import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; import type { Client, Plan } from '@/types'; import type { TenantFormValues } from '../hooks/useTenantForm'; interface TenantSheetProps { open: boolean; onOpenChange: (open: boolean) => void; tenantId?: number; isEditMode: boolean; register: UseFormRegister; errors: FieldErrors; isSubmitted: boolean; onSubmit: ComponentProps<'form'>['onSubmit']; canSubmit: boolean; clientId: string; planId: string; onClientChange: (clientId: string) => void; onPlanChange: (planId: string) => void; onNameChange: (name: string) => void; clients: Client[]; plans: Plan[]; isLookupsLoading: boolean; isSaving: boolean; adminEmail?: string; } export function TenantSheet({ open, onOpenChange, tenantId, isEditMode, register, errors, isSubmitted, onSubmit, canSubmit, clientId, planId, onClientChange, onPlanChange, onNameChange, clients, plans, isLookupsLoading, isSaving, adminEmail, }: TenantSheetProps) { const fieldError = (field: keyof TenantFormValues) => isSubmitted ? errors[field]?.message : undefined; return ( {tenantId ? 'Edit Tenant' : 'Create Tenant'} Bind a client and subscription plan, then invite the tenant administrator.

Basic Information

Tenant identity and subscription binding.

onNameChange(event.target.value), })} />