27 lines
715 B
TypeScript
27 lines
715 B
TypeScript
import { useSendWithButton } from '..'
|
|
import { composePutAnnouncementURL, processPutAnnouncement } from '../../api/putAnnouncement'
|
|
import { isPutAnnouncementResponse } from '../../api/putAnnouncement/types'
|
|
|
|
function useAddAnnouncement() {
|
|
const { doSend, button } = useSendWithButton(
|
|
'Опубликовать',
|
|
'Опубликовано',
|
|
true,
|
|
composePutAnnouncementURL(),
|
|
'PUT',
|
|
true,
|
|
isPutAnnouncementResponse,
|
|
processPutAnnouncement
|
|
)
|
|
|
|
function handleAdd(formData: FormData) {
|
|
void doSend({}, {
|
|
body: formData,
|
|
})
|
|
}
|
|
|
|
return { handleAdd, addButton: button }
|
|
}
|
|
|
|
export default useAddAnnouncement
|