"use client" import { ErrorMessage } from "@hookform/error-message" import { useRef } from "react" import { Button, ComboBox, FieldError, Input, type Key, ListBox, ListBoxItem, Popover, } from "react-aria-components" import { useController, useFormContext } from "react-hook-form" import { useIntl } from "react-intl" import SelectChevron from "../SelectChevron" import { countries } from "./countries" import styles from "./country.module.css" import type { CountryProps } from "./country" export default function CountrySelect({ name = "country", registerOptions, }: CountryProps) { const { formatMessage } = useIntl() const divRef = useRef(null) const { control, setValue } = useFormContext() const { field } = useController({ control, name, rules: registerOptions, }) function handleChange(country: Key) { setValue(name, country) } const selectCountryLabel = formatMessage({ id: "Select a country" }) return (
{countries.map((country, idx) => ( {country.name} ))}
) }