import { LatLng } from 'leaflet'

import useFetch from './useFetch'
import { composeOsmAddressURL, processOsmAddress } from '../../api/osmAddress'
import { isOsmAddressResponse } from '../../api/osmAddress/types'

const useOsmAddresses = (addressPosition: LatLng) =>
    useFetch(
        composeOsmAddressURL(addressPosition),
        'GET',
        false,
        isOsmAddressResponse,
        processOsmAddress,
        ''
    )

export default useOsmAddresses
