'use client'; import { useState, useEffect } from 'react'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; import { Label } from '@/components/ui/label'; import { Company } from '@/lib/types/autotask'; import { useApi } from '@/lib/hooks/use-api'; import { Building2 } from 'lucide-react'; interface CompanySelectorEnhancedProps { value?: number; onValueChange: (value: number | undefined, companyName?: string) => void; label?: string; } export function CompanySelectorEnhanced({ value, onValueChange, label = 'Select Company' }: CompanySelectorEnhancedProps) { const { data, loading, error } = useApi<{ companies: Company[] }>('/api/companies'); const companies = data?.companies || []; const handleChange = (val: string) => { const companyId = parseInt(val); const company = companies.find(c => c.id === companyId); onValueChange(companyId, company?.companyName); }; return (
); }