Add delete room button in RoomModal

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-17 18:02:08 +03:00
parent 791d8637f9
commit 1d24e5a4c4
2 changed files with 23 additions and 2 deletions

View File

@@ -2,7 +2,7 @@ import { useState, useRef } from 'react'
import { Modal } from '../ui/Modal'
import { cn } from '../../lib/utils'
import type { Room, RoomStatus, HousekeepingStatus, BedType, BedItem, BedItemType, ExtraPlace, ChildPolicy } from '../../types'
import { ImagePlus, X as XIcon, ChevronLeft, ChevronRight, Plus, Minus, Baby } from 'lucide-react'
import { ImagePlus, X as XIcon, ChevronLeft, ChevronRight, Plus, Minus, Baby, Trash2 } from 'lucide-react'
import { useAmenities } from '../../contexts/AmenitiesContext'
const ROOM_TYPES = ['Стандарт', 'Делюкс', 'Полулюкс', 'Люкс', 'Пентхаус', 'Апартаменты', 'Другой']
@@ -49,10 +49,11 @@ interface RoomModalProps {
categories?: { id: string; name: string }[]
onClose: () => void
onSave: (room: Room) => void
onDelete?: () => void
error?: string | null
}
export function RoomModal({ open, room, categories = [], onClose, onSave, error }: RoomModalProps) {
export function RoomModal({ open, room, categories = [], onClose, onSave, onDelete, error }: RoomModalProps) {
const isEdit = !!room
const [tab, setTab] = useState<ModalTab>('main')
@@ -165,6 +166,15 @@ export function RoomModal({ open, room, categories = [], onClose, onSave, error
size="xl"
footer={
<>
{isEdit && onDelete && (
<button
onClick={onDelete}
className="btn-ghost text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 mr-auto"
>
<Trash2 size={14} />
Удалить номер
</button>
)}
{error && (
<p className="text-sm text-red-600 dark:text-red-400 flex-1 text-left">{error}</p>
)}