forked from polka_billy/porridger
Code styling
Added brackets for const lambdas Converted const lambdas with multiple instructions to functions
This commit is contained in:
@ -17,21 +17,23 @@ type AnnouncementResponse = {
|
||||
booked_by: number
|
||||
}
|
||||
|
||||
const isAnnouncementResponse = (obj: unknown): obj is AnnouncementResponse => isObject(obj, {
|
||||
'id': 'number',
|
||||
'user_id': 'number',
|
||||
'name': 'string',
|
||||
'category': isCategory,
|
||||
'best_by': 'number',
|
||||
'address': 'string',
|
||||
'longtitude': 'number',
|
||||
'latitude': 'number',
|
||||
'description': 'string',
|
||||
'src': 'string?',
|
||||
'metro': 'string',
|
||||
'trashId': 'number?',
|
||||
'booked_by': 'number'
|
||||
})
|
||||
const isAnnouncementResponse = (obj: unknown): obj is AnnouncementResponse => (
|
||||
isObject(obj, {
|
||||
'id': 'number',
|
||||
'user_id': 'number',
|
||||
'name': 'string',
|
||||
'category': isCategory,
|
||||
'best_by': 'number',
|
||||
'address': 'string',
|
||||
'longtitude': 'number',
|
||||
'latitude': 'number',
|
||||
'description': 'string',
|
||||
'src': 'string?',
|
||||
'metro': 'string',
|
||||
'trashId': 'number?',
|
||||
'booked_by': 'number'
|
||||
})
|
||||
)
|
||||
|
||||
type Announcement = {
|
||||
id: number,
|
||||
|
@ -5,8 +5,9 @@ import { AnnouncementsResponse } from './types'
|
||||
|
||||
const initialAnnouncements: Announcement[] = []
|
||||
|
||||
const composeAnnouncementsURL = (filters: FiltersType) =>
|
||||
const composeAnnouncementsURL = (filters: FiltersType) => (
|
||||
API_URL + '/announcements?' + new URLSearchParams(URLEncodeFilters(filters)).toString()
|
||||
)
|
||||
|
||||
const processAnnouncements = (data: AnnouncementsResponse): Announcement[] => {
|
||||
const annList = data.list_of_announcements
|
||||
|
@ -6,10 +6,12 @@ type AnnouncementsResponse = {
|
||||
Success: boolean
|
||||
}
|
||||
|
||||
const isAnnouncementsResponse = (obj: unknown): obj is AnnouncementsResponse => isObject(obj, {
|
||||
'list_of_announcements': obj => isArrayOf<AnnouncementResponse>(obj, isAnnouncementResponse),
|
||||
'Success': 'boolean'
|
||||
})
|
||||
const isAnnouncementsResponse = (obj: unknown): obj is AnnouncementsResponse => (
|
||||
isObject(obj, {
|
||||
'list_of_announcements': obj => isArrayOf<AnnouncementResponse>(obj, isAnnouncementResponse),
|
||||
'Success': 'boolean'
|
||||
})
|
||||
)
|
||||
|
||||
export type {
|
||||
AnnouncementsResponse,
|
||||
|
@ -3,10 +3,12 @@ import { OsmAddressResponse } from './types'
|
||||
|
||||
const initialOsmAddress = ''
|
||||
|
||||
const composeOsmAddressURL = (addressPosition: LatLng) =>
|
||||
const composeOsmAddressURL = (addressPosition: LatLng) => (
|
||||
`${location.protocol}//nominatim.openstreetmap.org/reverse?format=json&accept-language=ru&lat=${addressPosition.lat}&lon=${addressPosition.lng}`
|
||||
)
|
||||
|
||||
const processOsmAddress = (data: OsmAddressResponse): string =>
|
||||
const processOsmAddress = (data: OsmAddressResponse): string => (
|
||||
data.display_name
|
||||
)
|
||||
|
||||
export { initialOsmAddress, composeOsmAddressURL, processOsmAddress }
|
||||
|
@ -4,9 +4,11 @@ type OsmAddressResponse = {
|
||||
display_name: string
|
||||
}
|
||||
|
||||
const isOsmAddressResponse = (obj: unknown): obj is OsmAddressResponse => isObject(obj, {
|
||||
'display_name': 'string',
|
||||
})
|
||||
const isOsmAddressResponse = (obj: unknown): obj is OsmAddressResponse => (
|
||||
isObject(obj, {
|
||||
'display_name': 'string',
|
||||
})
|
||||
)
|
||||
|
||||
export type {
|
||||
OsmAddressResponse,
|
||||
|
@ -2,10 +2,11 @@ import { LatLng } from 'leaflet'
|
||||
|
||||
import { API_URL } from '../../config'
|
||||
|
||||
const composeTrashboxURL = (position: LatLng) =>
|
||||
const composeTrashboxURL = (position: LatLng) => (
|
||||
API_URL + '/trashbox?' + new URLSearchParams({
|
||||
lat: position.lat.toString(),
|
||||
lng: position.lng.toString()
|
||||
}).toString()
|
||||
)
|
||||
|
||||
export { composeTrashboxURL }
|
||||
|
@ -7,16 +7,20 @@ type Trashbox = {
|
||||
Categories: string[]
|
||||
}
|
||||
|
||||
const isTrashbox = (obj: unknown): obj is Trashbox => isObject(obj, {
|
||||
'Lat': 'number',
|
||||
'Lng': 'number',
|
||||
'Address': 'string',
|
||||
'Categories': obj => isArrayOf<string>(obj, isString)
|
||||
})
|
||||
const isTrashbox = (obj: unknown): obj is Trashbox => (
|
||||
isObject(obj, {
|
||||
'Lat': 'number',
|
||||
'Lng': 'number',
|
||||
'Address': 'string',
|
||||
'Categories': obj => isArrayOf<string>(obj, isString)
|
||||
})
|
||||
)
|
||||
|
||||
type TrashboxResponse = Trashbox[]
|
||||
|
||||
const isTrashboxResponse = (obj: unknown): obj is Trashbox[] => isArrayOf(obj, isTrashbox)
|
||||
const isTrashboxResponse = (obj: unknown): obj is Trashbox[] => (
|
||||
isArrayOf(obj, isTrashbox)
|
||||
)
|
||||
|
||||
export type { Trashbox, TrashboxResponse }
|
||||
export { isTrashbox, isTrashboxResponse }
|
||||
|
Reference in New Issue
Block a user