import { useCategories, useItems, useTypes } from '../api/queries'; interface CTISelectProps { value: { categoryId: string; typeId: string; itemId: string }; onChange: (value: { categoryId: string; typeId: string; itemId: string }) => void; disabled?: boolean; compact?: boolean; } export default function CTISelect({ value, onChange, disabled, compact }: CTISelectProps) { const { data: categories = [] } = useCategories(); const { data: types = [] } = useTypes(value.categoryId || undefined); const { data: items = [] } = useItems(value.typeId || undefined); const handleCategory = (categoryId: string) => { onChange({ categoryId, typeId: '', itemId: '' }); }; const handleType = (typeId: string) => { onChange({ ...value, typeId, itemId: '' }); }; const handleItem = (itemId: string) => { onChange({ ...value, itemId }); }; const selectClass = 'block w-full rounded-md border border-input bg-background px-3 py-1.5 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50'; if (compact) { return (
); } return (
); }