// Management → Tables → Floor plans (plan step 6.8, D-31): the venue's floor plans by zone (a zone
// can have several, e.g. "Ground floor" and "Upstairs"; a plan may have no zone), "New floor plan",
// and the chosen plan's editor (FloorEditor). The phones, the counter and the Tables page draw
// the saved plans live (@xenia/floorplan FloorView).
import { useState } from 'react'
import toast from 'react-hot-toast'
import { Plus } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import { useTranslation } from '@xenia/i18n'
import { Button, Dialog, EmptyState, Field, Input, Select, Spinner, cx } from '@xenia/ui'
import { useLiveQuery } from '../../live/useLiveQuery'
import FloorEditor from './FloorEditor'
import * as api from './floorApi'
const SIZES = { small: [800, 600], medium: [1200, 800], large: [1800, 1200] }
export default function FloorPlansTab() {
const { t } = useTranslation('manager')
const { data, refetch } = useLiveQuery({ queryKey: ['floor-plans'], queryFn: api.listPlans, events: api.FLOOR_EVENTS })
const { data: groups = [] } = useLiveQuery({ queryKey: ['table-groups'], queryFn: api.listZones, events: ['table_list_changed'] })
const [chosen, setChosen] = useState(null)
const [creating, setCreating] = useState(false)
const [version, setVersion] = useState(0) // a new editor after a save (it starts from what was saved)
if (!data) return