Added announcement disposal:

Added ann details button
Added modal shown on its click
Moved trashbox selection there
Added trashboxes mock while testing in restricted area
This commit is contained in:
2023-08-01 18:23:56 +03:00
parent 47fca02858
commit b93ab9794d
15 changed files with 383 additions and 126 deletions

View File

@ -0,0 +1,19 @@
import { API_URL } from '../../config'
import { TrashboxDispose, DisposeResponse } from './types'
const composeDisposeURL = () => (
API_URL + '/announcement/dispose?'
)
const composeDisposeBody = (ann_id: number, trashbox: TrashboxDispose) => (
JSON.stringify({
ann_id,
trashbox,
})
)
const processDispose = (data: DisposeResponse): boolean => {
return data.Success
}
export { composeDisposeURL, composeDisposeBody, processDispose }

View File

@ -0,0 +1,23 @@
import { composeDisposeBody } from '.'
import { isObject } from '../../utils/types'
import { Trashbox } from '../trashbox/types'
type TrashboxDispose = Omit<Trashbox, 'Categories' | 'Address'> & { Category: string }
type DisposeParams = Parameters<typeof composeDisposeBody>
type DisposeAnnParams = DisposeParams extends [ann_id: number, ...args: infer P] ? P : never
type DisposeResponse = {
Success: boolean,
}
const isDisposeResponse = (obj: unknown): obj is DisposeResponse => (
isObject(obj, {
'Success': 'boolean',
})
)
export type { TrashboxDispose, DisposeParams, DisposeAnnParams, DisposeResponse }
export { isDisposeResponse }

View File

@ -1,6 +1,7 @@
import { isArrayOf, isObject, isString } from '../../utils/types'
type Trashbox = {
Name: string,
Lat: number,
Lng: number,
Address: string,
@ -9,6 +10,7 @@ type Trashbox = {
const isTrashbox = (obj: unknown): obj is Trashbox => (
isObject(obj, {
'Name': 'string',
'Lat': 'number',
'Lng': 'number',
'Address': 'string',