Updated announcement fetching to new response schema
This commit is contained in:
parent
e1e1244b3a
commit
c52a623907
@ -6,7 +6,7 @@ type AnnouncementResponse = {
|
|||||||
user_id: number,
|
user_id: number,
|
||||||
name: string,
|
name: string,
|
||||||
category: Category,
|
category: Category,
|
||||||
best_by: number,
|
best_by: string,
|
||||||
address: string,
|
address: string,
|
||||||
longtitude: number,
|
longtitude: number,
|
||||||
latitude: number,
|
latitude: number,
|
||||||
@ -23,7 +23,7 @@ const isAnnouncementResponse = (obj: unknown): obj is AnnouncementResponse => (
|
|||||||
'user_id': 'number',
|
'user_id': 'number',
|
||||||
'name': 'string',
|
'name': 'string',
|
||||||
'category': isCategory,
|
'category': isCategory,
|
||||||
'best_by': 'number',
|
'best_by': 'string',
|
||||||
'address': 'string',
|
'address': 'string',
|
||||||
'longtitude': 'number',
|
'longtitude': 'number',
|
||||||
'latitude': 'number',
|
'latitude': 'number',
|
||||||
|
@ -11,7 +11,7 @@ const composeAnnouncementsURL = (filters: FiltersType) => (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const processAnnouncements = (data: AnnouncementsResponse): Announcement[] => (
|
const processAnnouncements = (data: AnnouncementsResponse): Announcement[] => (
|
||||||
data.list_of_announcements.map(processAnnouncement)
|
data.map(processAnnouncement)
|
||||||
)
|
)
|
||||||
|
|
||||||
export { initialAnnouncements, composeAnnouncementsURL, processAnnouncements }
|
export { initialAnnouncements, composeAnnouncementsURL, processAnnouncements }
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
import { isArrayOf, isObject } from '../../utils/types'
|
import { isArrayOf } from '../../utils/types'
|
||||||
import { AnnouncementResponse, isAnnouncementResponse } from '../announcement/types'
|
import { AnnouncementResponse, isAnnouncementResponse } from '../announcement/types'
|
||||||
|
|
||||||
type AnnouncementsResponse = {
|
type AnnouncementsResponse = AnnouncementResponse[]
|
||||||
list_of_announcements: AnnouncementResponse[],
|
|
||||||
Success: boolean,
|
|
||||||
}
|
|
||||||
|
|
||||||
const isAnnouncementsResponse = (obj: unknown): obj is AnnouncementsResponse => (
|
const isAnnouncementsResponse = (obj: unknown): obj is AnnouncementsResponse => (
|
||||||
isObject(obj, {
|
isArrayOf<AnnouncementResponse>(obj, isAnnouncementResponse)
|
||||||
'list_of_announcements': obj => isArrayOf<AnnouncementResponse>(obj, isAnnouncementResponse),
|
|
||||||
'Success': 'boolean',
|
|
||||||
})
|
|
||||||
)
|
)
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user