Files
e2e 3bb535efe8
Some checks failed
Main / Setup and Test (push) Has been cancelled
Main / Build Website (push) Has been cancelled
chore: heygermany customer project
2026-07-11 10:35:04 +02:00

42 lines
977 B
TypeScript

import React, { useMemo } from 'react'
import { Select } from '@pikku/mantine/core'
import { useGetCountries } from '@/hooks/useGetCountries'
interface CountrySearchProps {
value: string
onChange: (value: string) => void
error?: string
label?: any
placeholder?: any
}
export const CountrySearch: React.FunctionComponent<CountrySearchProps> = ({
value,
onChange,
error,
label,
placeholder
}) => {
const { data: countriesMap = {}, isLoading } = useGetCountries()
const countryOptions = useMemo(() => {
return Object.entries(countriesMap).map(([iso3, name]) => ({
value: iso3,
label: name
}))
}, [countriesMap])
return (
<Select
label={label as any}
value={value}
data={countryOptions}
onChange={(selectedValue) => onChange(selectedValue || '')}
placeholder={placeholder as any}
searchable
error={error as any}
disabled={isLoading && countryOptions.length === 0}
/>
)
}