import { LatLng } from 'leaflet'

import { useFetch } from '../'
import { composeTrashboxURL, processTrashbox } from '../../api/trashbox'
import { isTrashboxResponse } from '../../api/trashbox/types'

const useTrashboxes = (position: LatLng) => (
    useFetch(
        composeTrashboxURL(position),
        'GET',
        true,
        isTrashboxResponse,
        processTrashbox,
        []
    )
)

export default useTrashboxes
