Even more code styling things

This commit is contained in:
2023-07-31 12:41:19 +03:00
parent 9eb30d2066
commit 9b35a54ae9
51 changed files with 127 additions and 113 deletions

View File

@ -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 }

View File

@ -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 {

View File

@ -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',
})
)

View File

@ -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',
})
)

View File

@ -1,7 +1,7 @@
import { isObject } from '../../utils/types'
type OsmAddressResponse = {
display_name: string
display_name: string,
}
const isOsmAddressResponse = (obj: unknown): obj is OsmAddressResponse => (

View File

@ -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',
})
)

View File

@ -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',
})
)

View File

@ -11,7 +11,7 @@ type SignUpResponse = {
Success: true,
} | {
Success: false,
Message: string
Message: string,
}
const isSignUpResponse = (obj: unknown): obj is SignUpResponse => (

View File

@ -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',
})
)

View File

@ -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 }

View File

@ -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),
})
)

View File

@ -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 = () => (

View File

@ -4,7 +4,7 @@ type User = {
id: number,
name: string,
regDate: number,
points: number
points: number,
}
const isUser = (obj: unknown): obj is User => (