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

@@ -16,7 +16,7 @@ function useAddAnnouncement() {
function handleAdd(formData: FormData) {
void doSend({}, {
body: formData
body: formData,
})
}

View File

@@ -1,18 +1,8 @@
import { useCallback } from 'react'
import { isObject } from '../../utils/types'
import { useSendWithButton } from '..'
import { composeBookURL, processBook } from '../../api/book'
type BookResponse = {
Success: boolean
}
const isBookResponse = (obj: unknown): obj is BookResponse => (
isObject(obj, {
'Success': 'boolean'
})
)
import { isBookResponse } from '../../api/book/types'
function useBook() {
const { doSend, button } = useSendWithButton('Забронировать',
@@ -22,17 +12,17 @@ function useBook() {
'POST',
true,
isBookResponse,
processBook
processBook,
)
const handleBook = useCallback((id: number) => {
void doSend({}, {
body: JSON.stringify({
id
id,
}),
headers: {
'Content-Type': 'application/json'
}
'Content-Type': 'application/json',
},
})
}, [doSend])

View File

@@ -11,7 +11,7 @@ const useOsmAddresses = (addressPosition: LatLng) => (
false,
isOsmAddressResponse,
processOsmAddress,
''
'',
)
)

View File

@@ -13,17 +13,17 @@ const useRemoveAnnouncement = (resolve: () => void) => {
'DELETE',
true,
isRemoveAnnouncementResponse,
processRemoveAnnouncement
processRemoveAnnouncement,
)
const doSendWithClose = useCallback(async (id: number) => {
const res = await doSend({}, {
body: JSON.stringify({
id
id,
}),
headers: {
'Content-Type': 'application/json'
}
'Content-Type': 'application/json',
},
})
if (res) {

View File

@@ -17,7 +17,7 @@ function useSignIn() {
async function handleSignIn(formData: FormData) {
const token = await doSend({}, {
body: formData
body: formData,
})
if (token !== undefined) {

View File

@@ -18,8 +18,8 @@ function useSignUp() {
const res = await doSend({}, {
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
'Content-Type': 'application/json',
},
})
return res ?? false

View File

@@ -11,7 +11,7 @@ const useTrashboxes = (position: LatLng) => (
true,
isTrashboxResponse,
processTrashbox,
[]
[],
)
)

View File

@@ -16,8 +16,8 @@ const useUser = (): UseFetchReturn<User> => (
data: initialUser,
loading: false,
error: null,
refetch: () => { return }
refetch: () => { return },
}
)
export default useUser
export default useUser