Even more code styling things
This commit is contained in:
@@ -16,7 +16,7 @@ function useAddAnnouncement() {
|
||||
|
||||
function handleAdd(formData: FormData) {
|
||||
void doSend({}, {
|
||||
body: formData
|
||||
body: formData,
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -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])
|
||||
|
||||
|
@@ -11,7 +11,7 @@ const useOsmAddresses = (addressPosition: LatLng) => (
|
||||
false,
|
||||
isOsmAddressResponse,
|
||||
processOsmAddress,
|
||||
''
|
||||
'',
|
||||
)
|
||||
)
|
||||
|
||||
|
@@ -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) {
|
||||
|
@@ -17,7 +17,7 @@ function useSignIn() {
|
||||
|
||||
async function handleSignIn(formData: FormData) {
|
||||
const token = await doSend({}, {
|
||||
body: formData
|
||||
body: formData,
|
||||
})
|
||||
|
||||
if (token !== undefined) {
|
||||
|
@@ -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
|
||||
|
@@ -11,7 +11,7 @@ const useTrashboxes = (position: LatLng) => (
|
||||
true,
|
||||
isTrashboxResponse,
|
||||
processTrashbox,
|
||||
[]
|
||||
[],
|
||||
)
|
||||
)
|
||||
|
||||
|
@@ -16,8 +16,8 @@ const useUser = (): UseFetchReturn<User> => (
|
||||
data: initialUser,
|
||||
loading: false,
|
||||
error: null,
|
||||
refetch: () => { return }
|
||||
refetch: () => { return },
|
||||
}
|
||||
)
|
||||
|
||||
export default useUser
|
||||
export default useUser
|
||||
|
Reference in New Issue
Block a user