diff --git a/packages/admin/src/components/accounts/account-form.tsx b/packages/admin/src/components/accounts/account-form.tsx index a9faca1..5441c7c 100644 --- a/packages/admin/src/components/accounts/account-form.tsx +++ b/packages/admin/src/components/accounts/account-form.tsx @@ -1,5 +1,6 @@ import { useForm } from 'react-hook-form' import { zodResolver } from '@hookform/resolvers/zod' +import { z } from 'zod' import { AccountCreateSchema } from '@forte/shared/schemas' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' @@ -17,7 +18,7 @@ interface AccountFormProps { } export function AccountForm({ defaultValues, onSubmit, loading, includeFirstMember }: AccountFormProps) { - const optionalNameSchema = AccountCreateSchema.extend({ name: AccountCreateSchema.shape.name.optional() }) + const optionalNameSchema = AccountCreateSchema.extend({ name: z.string().max(255).optional() }) const schema = includeFirstMember ? optionalNameSchema : AccountCreateSchema const { @@ -29,7 +30,7 @@ export function AccountForm({ defaultValues, onSubmit, loading, includeFirstMemb } = useForm({ resolver: zodResolver(schema), defaultValues: { - name: defaultValues?.name ?? '', + name: defaultValues?.name ?? (includeFirstMember ? undefined : ''), email: defaultValues?.email ?? undefined, phone: defaultValues?.phone ?? undefined, billingMode: defaultValues?.billingMode ?? 'consolidated', @@ -60,7 +61,7 @@ export function AccountForm({ defaultValues, onSubmit, loading, includeFirstMemb } return ( -