Fix account/member form validation, add member number to tables

- Fix account create form blocking on empty name when includeFirstMember
- Add noValidate to forms to prevent browser native validation on optional fields
- Show member number column on account members tab
- Replace DOB with phone in members table for better at-a-glance info
This commit is contained in:
Ryan Moon
2026-03-28 11:31:28 -05:00
parent f4e5a57846
commit 6ca38e2105
3 changed files with 9 additions and 6 deletions

View File

@@ -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 (
<form id="account-form" onSubmit={handleSubmit(handleFormSubmit)} className="space-y-4 max-w-lg">
<form id="account-form" onSubmit={handleSubmit(handleFormSubmit)} noValidate className="space-y-4 max-w-lg">
<div className="space-y-2">
<Label htmlFor="name">Account Name {includeFirstMember ? '' : '*'}</Label>
<Input id="name" {...register('name')} placeholder={includeFirstMember ? 'Auto-generated from member name if blank' : 'e.g. Smith Family, Lincoln Elementary'} />