feat: single ФИО field with autocomplete replaces 3 separate name inputs

- BookingModal (room tab): replace Фамилия/Имя/Отчество grid with single 'ФИО *' input; parseFullName() splits by spaces into last/first/middle; DB search via api.guests.list (debounced 300ms); dropdown shows current bookings + DB guests with phone/email autofill
- BookingDetailPanel: merge Фамилия (with autocomplete) + Имя + Отчество into single ФИО * input; existing acQuery/acResults infrastructure reused; parseFio() updates all 3 bgForm fields on every keystroke; openEditForm initializes ФИО from full name
- RentalBookingModal + BookingModal rental tab: include middleName when displaying DB guest results and when setting guestName on selection; update type to include middleName field

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-22 01:22:46 +03:00
parent e403689522
commit b1b6854663
3 changed files with 131 additions and 55 deletions

View File

@@ -73,7 +73,7 @@ export function RentalBookingModal({
const nameRef = useRef<HTMLDivElement>(null)
// DB guest search
const [dbResults, setDbResults] = useState<{ id: string; firstName: string; lastName: string; phone: string | null }[]>([])
const [dbResults, setDbResults] = useState<{ id: string; firstName: string; lastName: string; middleName: string | null; phone: string | null }[]>([])
const searchTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
const [saving, setSaving] = useState(false)
@@ -395,13 +395,15 @@ export function RentalBookingModal({
})}
{/* DB guest search results */}
{dbResults
.filter(g => !filtered.some(b => b.guestName === `${g.lastName} ${g.firstName}`))
.map(g => (
.filter(g => !filtered.some(b => b.guestName.startsWith(g.lastName)))
.map(g => {
const fullName = [g.lastName, g.firstName, g.middleName].filter(Boolean).join(' ')
return (
<button
key={g.id}
type="button"
onMouseDown={() => {
setGuestName(`${g.lastName} ${g.firstName}`)
setGuestName(fullName)
setGuestPhone(g.phone ?? '')
setShowSuggestions(false)
setDbResults([])
@@ -411,13 +413,13 @@ export function RentalBookingModal({
>
<div className="w-2 h-2 rounded-full shrink-0 bg-slate-400" />
<div className="min-w-0 flex-1">
<p className="text-sm font-medium text-slate-800 dark:text-slate-200 truncate">{g.lastName} {g.firstName}</p>
<p className="text-sm font-medium text-slate-800 dark:text-slate-200 truncate">{fullName}</p>
<p className="text-[11px] text-slate-400 truncate">
{g.phone ?? 'нет телефона'}
</p>
</div>
</button>
))
)})
}
</div>
)}