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:
19
front/src/api/dispose/index.ts
Normal file
19
front/src/api/dispose/index.ts
Normal 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 }
|
23
front/src/api/dispose/types.ts
Normal file
23
front/src/api/dispose/types.ts
Normal 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 }
|
@ -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',
|
||||
|
Reference in New Issue
Block a user