Added address to dispose trashbox request
styling fixes
This commit is contained in:
parent
d9925647c6
commit
864f5a040c
@ -2,7 +2,7 @@ import { composeDisposeBody } from '.'
|
||||
import { isObject } from '../../utils/types'
|
||||
import { Trashbox } from '../trashbox/types'
|
||||
|
||||
type TrashboxDispose = Omit<Trashbox, 'Categories' | 'Address'> & { Category: string }
|
||||
type TrashboxDispose = Omit<Trashbox, 'Categories'> & { Category: string }
|
||||
|
||||
type DisposeParams = Parameters<typeof composeDisposeBody>
|
||||
|
||||
|
@ -2,11 +2,13 @@ import { LatLng } from 'leaflet'
|
||||
|
||||
import { API_URL } from '../../config'
|
||||
import { Trashbox, TrashboxResponse } from './types'
|
||||
import { Category } from '../../assets/category'
|
||||
|
||||
const composeTrashboxURL = (position: LatLng) => (
|
||||
const composeTrashboxURL = (position: LatLng, category: Category) => (
|
||||
API_URL + '/trashbox?' + new URLSearchParams({
|
||||
lat: position.lat.toString(),
|
||||
lng: position.lng.toString(),
|
||||
category: category,
|
||||
}).toString()
|
||||
)
|
||||
|
||||
|
@ -81,12 +81,13 @@ function SelectDisposalTrashbox({ annId, category, address, closeRefresh }: Sele
|
||||
variant='success'
|
||||
onClick={() => {
|
||||
if (gotResponse(trashboxes) && !gotError(trashboxes)) {
|
||||
const { Lat, Lng, Name } = trashboxes.data[selectedTrashbox.index]
|
||||
const { Lat, Lng, Name, Address } = trashboxes.data[selectedTrashbox.index]
|
||||
void handleDispose(annId, {
|
||||
Category: selectedTrashbox.category,
|
||||
Lat,
|
||||
Lng,
|
||||
Name,
|
||||
Address,
|
||||
})
|
||||
}
|
||||
}}
|
||||
|
@ -4,7 +4,7 @@ import { useSendWithButton } from '..'
|
||||
import { composeDisposeBody, composeDisposeURL, processDispose } from '../../api/dispose'
|
||||
import { DisposeParams, isDisposeResponse } from '../../api/dispose/types'
|
||||
|
||||
const useDispose = (resolve: () => void) => {
|
||||
function useDispose(resolve: () => void) {
|
||||
const { doSend, button } = useSendWithButton(
|
||||
'Выбор сделан',
|
||||
'Зачтено',
|
||||
|
@ -2,8 +2,7 @@ import { composePoetryURL, initialPoetry, processPoetry } from '../../api/poetry
|
||||
import { Poetry, isPoetryResponse } from '../../api/poetry/types'
|
||||
import useFetch, { UseFetchReturn } from '../useFetch'
|
||||
|
||||
function usePoetry(): UseFetchReturn<Poetry> {
|
||||
return (
|
||||
const usePoetry = (): UseFetchReturn<Poetry> => (
|
||||
useFetch(
|
||||
composePoetryURL(),
|
||||
'GET',
|
||||
@ -13,6 +12,6 @@ function usePoetry(): UseFetchReturn<Poetry> {
|
||||
initialPoetry,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
export default usePoetry
|
||||
|
@ -4,7 +4,7 @@ import { useSendWithButton } from '..'
|
||||
import { composeRemoveAnnouncementURL, processRemoveAnnouncement } from '../../api/removeAnnouncement'
|
||||
import { isRemoveAnnouncementResponse } from '../../api/removeAnnouncement/types'
|
||||
|
||||
const useRemoveAnnouncement = (resolve: () => void) => {
|
||||
function useRemoveAnnouncement(resolve: () => void) {
|
||||
const { doSend, button } = useSendWithButton(
|
||||
'Закрыть объявление',
|
||||
'Закрыто',
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { LatLng } from 'leaflet'
|
||||
import { sampleSize, random } from 'lodash'
|
||||
|
||||
import { Trashbox } from '../../api/trashbox/types'
|
||||
import { UseFetchReturn } from '../useFetch'
|
||||
import { Trashbox, isTrashboxResponse } from '../../api/trashbox/types'
|
||||
import useFetch, { UseFetchReturn } from '../useFetch'
|
||||
|
||||
import { faker } from '@faker-js/faker/locale/ru'
|
||||
import { Category, categories } from '../../assets/category'
|
||||
import { useCallback, useMemo } from 'react'
|
||||
import { Category } from '../../assets/category'
|
||||
import { useMemo } from 'react'
|
||||
import { composeTrashboxURL, processTrashbox } from '../../api/trashbox'
|
||||
|
||||
function genMockTrashbox(pos: LatLng): Trashbox {
|
||||
const loc = faker.location.nearbyGPSCoordinate({ origin: [pos.lat, pos.lng], radius: 1 })
|
||||
@ -21,16 +21,17 @@ function genMockTrashbox(pos: LatLng): Trashbox {
|
||||
}
|
||||
|
||||
const useTrashboxes = (position: LatLng, category: Category): UseFetchReturn<Trashbox[]> => (
|
||||
// useFetch(
|
||||
// composeTrashboxURL(position, category),
|
||||
// 'GET',
|
||||
// true,
|
||||
// isTrashboxResponse,
|
||||
// processTrashbox,
|
||||
// [],
|
||||
// )
|
||||
|
||||
{
|
||||
// TODO: Remove once available
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
import.meta.env.PROD ? useFetch(
|
||||
composeTrashboxURL(position, category),
|
||||
'GET',
|
||||
true,
|
||||
isTrashboxResponse,
|
||||
processTrashbox,
|
||||
[],
|
||||
) : {
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
data: useMemo(() => new Array(3).fill(3).map(() => genMockTrashbox(position)), [position]),
|
||||
loading: false,
|
||||
error: null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user