import useFetch from '../useFetch'
import { FiltersType } from '../../utils/filters'
import { composeAnnouncementsURL, initialAnnouncements, processAnnouncements } from '../../api/announcements'
import { isAnnouncementsResponse } from '../../api/announcements/types'

const useAnnouncements = (filters: FiltersType) => (
    useFetch(
        composeAnnouncementsURL(filters),
        'GET',
        false,
        isAnnouncementsResponse,
        processAnnouncements,
        initialAnnouncements
    )
)

export default useAnnouncements
