Fixed ann removal
This commit is contained in:
@ -1,12 +1,13 @@
|
||||
import { useCallback } from 'react'
|
||||
|
||||
import { useSendWithButton } from '..'
|
||||
import { composeRemoveAnnouncementURL, processRemoveAnnouncement } from '../../api/removeAnnouncement'
|
||||
import { isRemoveAnnouncementResponse } from '../../api/removeAnnouncement/types'
|
||||
|
||||
const useRemoveAnnouncement = (close: () => void) => {
|
||||
const useRemoveAnnouncement = (resolve: () => void) => {
|
||||
const { doSend, button } = useSendWithButton(
|
||||
'Удалить',
|
||||
'Удалено',
|
||||
'Закрыть',
|
||||
'Закрыто',
|
||||
true,
|
||||
composeRemoveAnnouncementURL(),
|
||||
'DELETE',
|
||||
@ -16,14 +17,19 @@ const useRemoveAnnouncement = (close: () => void) => {
|
||||
)
|
||||
|
||||
const doSendWithClose = useCallback(async (id: number) => {
|
||||
await doSend({}, {
|
||||
const res = await doSend({}, {
|
||||
body: JSON.stringify({
|
||||
id
|
||||
})
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
|
||||
close()
|
||||
}, [doSend, close])
|
||||
if (res) {
|
||||
resolve()
|
||||
}
|
||||
}, [doSend, resolve])
|
||||
|
||||
return { handleRemove: doSendWithClose, removeButton: button }
|
||||
}
|
||||
|
Reference in New Issue
Block a user