import React from 'react'; import { Input } from '../ui/Input'; import { Card, CardBody, CardHeader } from '../ui/Card'; import { Badge } from '../ui/Badge'; import type { EnhancedTicketType, SharedPool, TicketRules } from '../../types/ticketing'; interface InventoryAndRulesEditorProps { ticketType: EnhancedTicketType; sharedPools: SharedPool[]; onUpdate: (updates: Partial) => void; } export const InventoryAndRulesEditor: React.FC = ({ ticketType, sharedPools, onUpdate }) => { const formatDateForInput = (dateString?: string) => { if (!dateString) return ''; try { return new Date(dateString).toISOString().slice(0, 16); } catch { return ''; } }; const handleRulesUpdate = (updates: Partial) => { const currentRules = ticketType.rules || { idCheck: false, reentry: 'none' as const, waiverRequired: false }; onUpdate({ rules: { ...currentRules, ...updates } }); }; return (
{/* Inventory Management */}

Inventory & Capacity

onUpdate({ capacity: parseInt(e.target.value) || 0 })} placeholder="100" helperText="Total tickets available" required />
{ticketType.sold}

Tickets sold (read-only)

{(ticketType.capacity || 0) - ticketType.sold - ticketType.reserved}

Available for purchase

{/* Sales Window */}
{ if (e.target.value) { onUpdate({ onSaleStart: new Date(e.target.value).toISOString() }); } else { onUpdate({}); // Send empty update to clear the field } }} className="w-full px-3 py-2 border border-border-subtle rounded-lg bg-background-elevated text-text-primary focus:ring-2 focus:ring-accent-primary-500 focus:border-accent-primary-500 transition-colors" />

When sales begin (optional)

{ if (e.target.value) { onUpdate({ onSaleEnd: new Date(e.target.value).toISOString() }); } else { onUpdate({}); // Send empty update to clear the field } }} className="w-full px-3 py-2 border border-border-subtle rounded-lg bg-background-elevated text-text-primary focus:ring-2 focus:ring-accent-primary-500 focus:border-accent-primary-500 transition-colors" />

When sales end (optional)

{/* Shared Pools Section (Simplified) */} {sharedPools.length > 0 && (
Shared Inventory Pools

Advanced feature: Share capacity with other ticket types

{sharedPools.map((pool) => ( ))}
)}
{/* Gate Rules & Restrictions */}

Gate Rules & Restrictions

{ if (e.target.value) { const value = parseInt(e.target.value); handleRulesUpdate({ ageMin: value }); } else { handleRulesUpdate({}); // Send empty update to clear the field } }} placeholder="18" helperText="Optional age restriction" /> { if (e.target.value) { const value = parseInt(e.target.value); handleRulesUpdate({ ageMax: value }); } else { handleRulesUpdate({}); // Send empty update to clear the field } }} placeholder="65" helperText="For youth/senior tickets" />
{ if (e.target.value) { const value = parseInt(e.target.value); handleRulesUpdate({ scanLimit: value }); } else { handleRulesUpdate({}); // Send empty update to clear the field } }} placeholder="1" helperText="Max times ticket can be scanned" />