// Prep zones (plan step 6.10; replaces the v1 Management → Prep zones page): where each dish's // ticket prints and how the kitchen screen treats it. A card per zone (its printers, whether it // prints, the ticket's sorting, the kitchen screen's shortcuts); New / Edit open the zone's // dialog, Delete asks first. Products are put in zones from the product editor. import { useState } from 'react' import { useMutation, useQueryClient } from '@tanstack/react-query' import toast from 'react-hot-toast' import { CookingPot, Pencil, Plus, Printer, Trash2 } from 'lucide-react' import { useCan } from '@xenia/access' import { errorMessage } from '@xenia/api' import { useTranslation } from '@xenia/i18n' import { Button, Dialog, EmptyState, IconButton, Spinner } from '@xenia/ui' import client from '../../api/client' import { useLiveQuery } from '../../live/useLiveQuery' import { Pill } from '../overview/parts' import ZoneDialog from './ZoneDialog' export default function PrepZonesPage() { const { t } = useTranslation('manager') const qc = useQueryClient() const canEdit = useCan('catalog.menu.manage') const [editing, setEditing] = useState(null) // a zone, or {} for a new one const [deleting, setDeleting] = useState(null) const { data: zones, isPending } = useLiveQuery({ queryKey: ['prep-zones'], queryFn: () => client.get('/api/prep-zones').then(r => r.data) }) const { data: printers = [] } = useLiveQuery({ queryKey: ['printers'], queryFn: () => client.get('/api/system/printers').then(r => r.data), staleTime: 60_000 }) const { data: categories = [] } = useLiveQuery({ queryKey: ['categories'], queryFn: () => client.get('/api/products/categories').then(r => r.data), staleTime: 60_000 }) const remove = useMutation({ mutationFn: id => client.delete(`/api/prep-zones/${id}`), onSuccess: () => { toast.success(t('printing.zones.deleted')); setDeleting(null); qc.invalidateQueries({ queryKey: ['prep-zones'] }) }, onError: err => toast.error(errorMessage(err, t)), }) const nameOf = id => printers.find(p => p.id === id)?.name ?? `#${id}` return (
{t('printing.zones.intro')}
{z.notification_name}
} {z.description &&{z.description}
}