18 lines
703 B
TypeScript

import { API_URL } from '../../config'
import { FiltersType, URLEncodeFilters, convertFilterNames } from '../../utils/filters'
import { processAnnouncement } from '../announcement'
import { Announcement } from '../announcement/types'
import { AnnouncementsResponse } from './types'
const initialAnnouncements: Announcement[] = []
const composeAnnouncementsURL = (filters: FiltersType) => (
API_URL + '/announcements?' + new URLSearchParams(convertFilterNames(URLEncodeFilters(filters))).toString()
)
const processAnnouncements = (data: AnnouncementsResponse): Announcement[] => (
data.map(processAnnouncement)
)
export { initialAnnouncements, composeAnnouncementsURL, processAnnouncements }