Converted api/announcements to use api/announcement processer as its part
This commit is contained in:
parent
de8a1abcbf
commit
bc55ab8f68
@ -0,0 +1,12 @@
|
|||||||
|
import { Announcement, AnnouncementResponse } from './types'
|
||||||
|
|
||||||
|
const processAnnouncement = (data: AnnouncementResponse): Announcement => ({
|
||||||
|
...data,
|
||||||
|
lat: data.latitude,
|
||||||
|
lng: data.longtitude,
|
||||||
|
bestBy: data.best_by,
|
||||||
|
bookedBy: data.booked_by,
|
||||||
|
userId: data.user_id
|
||||||
|
})
|
||||||
|
|
||||||
|
export { processAnnouncement }
|
@ -1,5 +1,6 @@
|
|||||||
import { API_URL } from '../../config'
|
import { API_URL } from '../../config'
|
||||||
import { FiltersType, URLEncodeFilters } from '../../utils/filters'
|
import { FiltersType, URLEncodeFilters } from '../../utils/filters'
|
||||||
|
import { processAnnouncement } from '../announcement'
|
||||||
import { Announcement } from '../announcement/types'
|
import { Announcement } from '../announcement/types'
|
||||||
import { AnnouncementsResponse } from './types'
|
import { AnnouncementsResponse } from './types'
|
||||||
|
|
||||||
@ -9,17 +10,8 @@ const composeAnnouncementsURL = (filters: FiltersType) => (
|
|||||||
API_URL + '/announcements?' + new URLSearchParams(URLEncodeFilters(filters)).toString()
|
API_URL + '/announcements?' + new URLSearchParams(URLEncodeFilters(filters)).toString()
|
||||||
)
|
)
|
||||||
|
|
||||||
const processAnnouncements = (data: AnnouncementsResponse): Announcement[] => {
|
const processAnnouncements = (data: AnnouncementsResponse): Announcement[] => (
|
||||||
const annList = data.list_of_announcements
|
data.list_of_announcements.map(processAnnouncement)
|
||||||
|
)
|
||||||
return annList.map(ann => ({
|
|
||||||
...ann,
|
|
||||||
lat: ann.latitude,
|
|
||||||
lng: ann.longtitude,
|
|
||||||
bestBy: ann.best_by,
|
|
||||||
bookedBy: ann.booked_by,
|
|
||||||
userId: ann.user_id
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export { initialAnnouncements, composeAnnouncementsURL, processAnnouncements }
|
export { initialAnnouncements, composeAnnouncementsURL, processAnnouncements }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user