feat: room type dropdown uses categories from API when available
This commit is contained in:
@@ -61,7 +61,7 @@ export function RoomModal({ open, room, categories = [], onClose, onSave, onDele
|
||||
number: room?.number ?? '',
|
||||
name: room?.name ?? '',
|
||||
floor: room?.floor ?? 1,
|
||||
type: room?.type ?? 'Стандарт',
|
||||
type: room?.type ?? (categories[0]?.name ?? 'Стандарт'),
|
||||
bedType: (room?.bedType ?? 'double') as BedType,
|
||||
maxGuests: room?.maxGuests ?? 2,
|
||||
baseRate: room?.baseRate ?? 5000,
|
||||
@@ -70,7 +70,7 @@ export function RoomModal({ open, room, categories = [], onClose, onSave, onDele
|
||||
sortOrder: room?.sortOrder ?? 99,
|
||||
allowHourly: room?.allowHourly ?? false,
|
||||
hourlyRate: room?.hourlyRate ?? 1000,
|
||||
categoryId: room?.categoryId ?? '',
|
||||
categoryId: room?.categoryId ?? (categories.find(c => c.name === room?.type)?.id ?? categories[0]?.id ?? ''),
|
||||
description: room?.description ?? '',
|
||||
earlyCheckinFee: room?.earlyCheckinFee ?? '',
|
||||
lateCheckoutFee: room?.lateCheckoutFee ?? '',
|
||||
@@ -228,21 +228,26 @@ export function RoomModal({ open, room, categories = [], onClose, onSave, onDele
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1.5">Тип номера</label>
|
||||
{categories.length > 0 ? (
|
||||
<select
|
||||
className="input"
|
||||
value={form.categoryId}
|
||||
onChange={e => {
|
||||
const cat = categories.find(c => c.id === e.target.value)
|
||||
set('categoryId', e.target.value)
|
||||
if (cat) set('type', cat.name)
|
||||
}}
|
||||
>
|
||||
<option value="">— Выберите категорию —</option>
|
||||
{categories.map(c => <option key={c.id} value={c.id}>{c.name}</option>)}
|
||||
</select>
|
||||
) : (
|
||||
<select className="input" value={form.type} onChange={e => set('type', e.target.value)}>
|
||||
{ROOM_TYPES.map(t => <option key={t} value={t}>{t}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{categories.length > 0 && (
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-1.5">Категория</label>
|
||||
<select className="input" value={form.categoryId} onChange={e => set('categoryId', e.target.value)}>
|
||||
<option value="">— Без категории —</option>
|
||||
{categories.map(c => <option key={c.id} value={c.id}>{c.name}</option>)}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user