import { formatCPF } from '@brazilian-utils/brazilian-utils' import { AlertTriangleIcon, CheckIcon, UserIcon, XIcon } from 'lucide-react' import type { ControllerFieldState } from 'react-hook-form' import { Abbr } from '@repo/ui/components/abbr' import { SearchFilter } from '@repo/ui/components/search-filter' import { Avatar, AvatarFallback } from '@repo/ui/components/ui/avatar' import { CommandItem } from '@repo/ui/components/ui/command' import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '@repo/ui/components/ui/input-group' import { Spinner } from '@repo/ui/components/ui/spinner' import { cn, initials } from '@repo/ui/lib/utils' import type { User } from './data' interface UserPickerProps { value?: User onChange: (value: User | null) => void onSearch: (search: string) => Promise fieldState: ControllerFieldState } export function UserPicker({ value, onChange, onSearch, fieldState }: UserPickerProps) { return ( ( { onSelect() onClose() }} >
{initials(name)}
  • {name}
  • {email}
  • {cpf ? (
  • {formatCPF(cpf)}
  • ) : (
  • InelegĂ­vel
  • )}
)} > {({ loading }) => ( {value && ( { e.preventDefault() onChange?.(null) }} > )} {loading && ( )} )}
) }