Even more code styling things
This commit is contained in:
@ -6,7 +6,7 @@ const processAnnouncement = (data: AnnouncementResponse): Announcement => ({
|
||||
lng: data.longtitude,
|
||||
bestBy: data.best_by,
|
||||
bookedBy: data.booked_by,
|
||||
userId: data.user_id
|
||||
userId: data.user_id,
|
||||
})
|
||||
|
||||
export { processAnnouncement }
|
||||
|
@ -14,7 +14,7 @@ type AnnouncementResponse = {
|
||||
src: string | null,
|
||||
metro: string,
|
||||
trashId: number | null,
|
||||
booked_by: number
|
||||
booked_by: number,
|
||||
}
|
||||
|
||||
const isAnnouncementResponse = (obj: unknown): obj is AnnouncementResponse => (
|
||||
@ -31,7 +31,7 @@ const isAnnouncementResponse = (obj: unknown): obj is AnnouncementResponse => (
|
||||
'src': 'string?',
|
||||
'metro': 'string',
|
||||
'trashId': 'number?',
|
||||
'booked_by': 'number'
|
||||
'booked_by': 'number',
|
||||
})
|
||||
)
|
||||
|
||||
@ -48,7 +48,7 @@ type Announcement = {
|
||||
src: string | null,
|
||||
metro: string,
|
||||
trashId: number | null,
|
||||
bookedBy: number
|
||||
bookedBy: number,
|
||||
}
|
||||
|
||||
export type {
|
||||
|
@ -3,13 +3,13 @@ import { AnnouncementResponse, isAnnouncementResponse } from '../announcement/ty
|
||||
|
||||
type AnnouncementsResponse = {
|
||||
list_of_announcements: AnnouncementResponse[],
|
||||
Success: boolean
|
||||
Success: boolean,
|
||||
}
|
||||
|
||||
const isAnnouncementsResponse = (obj: unknown): obj is AnnouncementsResponse => (
|
||||
isObject(obj, {
|
||||
'list_of_announcements': obj => isArrayOf<AnnouncementResponse>(obj, isAnnouncementResponse),
|
||||
'Success': 'boolean'
|
||||
'Success': 'boolean',
|
||||
})
|
||||
)
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { isObject } from '../../utils/types'
|
||||
|
||||
type BookResponse = {
|
||||
Success: boolean
|
||||
Success: boolean,
|
||||
}
|
||||
|
||||
const isBookResponse = (obj: unknown): obj is BookResponse => (
|
||||
isObject(obj, {
|
||||
'Success': 'boolean'
|
||||
'Success': 'boolean',
|
||||
})
|
||||
)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { isObject } from '../../utils/types'
|
||||
|
||||
type OsmAddressResponse = {
|
||||
display_name: string
|
||||
display_name: string,
|
||||
}
|
||||
|
||||
const isOsmAddressResponse = (obj: unknown): obj is OsmAddressResponse => (
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { isObject } from '../../utils/types'
|
||||
|
||||
type PutAnnouncementResponse = {
|
||||
Answer: boolean
|
||||
Answer: boolean,
|
||||
}
|
||||
|
||||
const isPutAnnouncementResponse = (obj: unknown): obj is PutAnnouncementResponse => (
|
||||
isObject(obj, {
|
||||
'Answer': 'boolean'
|
||||
'Answer': 'boolean',
|
||||
})
|
||||
)
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { isObject } from '../../utils/types'
|
||||
|
||||
type RemoveAnnouncementResponse = {
|
||||
Answer: boolean
|
||||
Answer: boolean,
|
||||
}
|
||||
|
||||
const isRemoveAnnouncementResponse = (obj: unknown): obj is RemoveAnnouncementResponse => (
|
||||
isObject(obj, {
|
||||
'Answer': 'boolean'
|
||||
'Answer': 'boolean',
|
||||
})
|
||||
)
|
||||
|
||||
|
@ -11,7 +11,7 @@ type SignUpResponse = {
|
||||
Success: true,
|
||||
} | {
|
||||
Success: false,
|
||||
Message: string
|
||||
Message: string,
|
||||
}
|
||||
|
||||
const isSignUpResponse = (obj: unknown): obj is SignUpResponse => (
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { isObject } from '../../utils/types'
|
||||
|
||||
type TokenResponse = {
|
||||
access_token: string
|
||||
access_token: string,
|
||||
}
|
||||
|
||||
const isTokenResponse = (obj: unknown): obj is TokenResponse => (
|
||||
isObject(obj, {
|
||||
'access_token': 'string'
|
||||
'access_token': 'string',
|
||||
})
|
||||
)
|
||||
|
||||
|
@ -6,11 +6,12 @@ import { Trashbox, TrashboxResponse } from './types'
|
||||
const composeTrashboxURL = (position: LatLng) => (
|
||||
API_URL + '/trashbox?' + new URLSearchParams({
|
||||
lat: position.lat.toString(),
|
||||
lng: position.lng.toString()
|
||||
lng: position.lng.toString(),
|
||||
}).toString()
|
||||
)
|
||||
|
||||
const processTrashbox = (data: TrashboxResponse): Trashbox[] =>
|
||||
const processTrashbox = (data: TrashboxResponse): Trashbox[] => (
|
||||
data
|
||||
)
|
||||
|
||||
export { composeTrashboxURL, processTrashbox }
|
||||
|
@ -4,7 +4,7 @@ type Trashbox = {
|
||||
Lat: number,
|
||||
Lng: number,
|
||||
Address: string,
|
||||
Categories: string[]
|
||||
Categories: string[],
|
||||
}
|
||||
|
||||
const isTrashbox = (obj: unknown): obj is Trashbox => (
|
||||
@ -12,7 +12,7 @@ const isTrashbox = (obj: unknown): obj is Trashbox => (
|
||||
'Lat': 'number',
|
||||
'Lng': 'number',
|
||||
'Address': 'string',
|
||||
'Categories': obj => isArrayOf<string>(obj, isString)
|
||||
'Categories': obj => isArrayOf<string>(obj, isString),
|
||||
})
|
||||
)
|
||||
|
||||
|
@ -10,10 +10,10 @@ const initialUser: User = import.meta.env.DEV ? { // Temporary, until api is rea
|
||||
regDate: faker.date.anytime().getTime(),
|
||||
points: Math.round(Math.random() * 1000),
|
||||
} : {
|
||||
id: -1,
|
||||
name: '',
|
||||
id: 1,
|
||||
name: 'Вася пупкин',
|
||||
regDate: 0,
|
||||
points: 0,
|
||||
points: 100,
|
||||
}
|
||||
|
||||
const composeUserURL = () => (
|
||||
|
@ -4,7 +4,7 @@ type User = {
|
||||
id: number,
|
||||
name: string,
|
||||
regDate: number,
|
||||
points: number
|
||||
points: number,
|
||||
}
|
||||
|
||||
const isUser = (obj: unknown): obj is User => (
|
||||
|
Reference in New Issue
Block a user