34 lines
684 B
TypeScript
34 lines
684 B
TypeScript
import { useSend } from '..'
|
|
import { composeSendRateURL, processSendRate } from '../../api/sendRate'
|
|
import { isSendRateResponse } from '../../api/sendRate/types'
|
|
|
|
function useSendRate() {
|
|
const { doSend, ...rest } = useSend(
|
|
composeSendRateURL(),
|
|
'POST',
|
|
true,
|
|
isSendRateResponse,
|
|
processSendRate,
|
|
)
|
|
|
|
const doSendRate = (rate: number) => (
|
|
doSend({}, {
|
|
body: JSON.stringify({
|
|
rate,
|
|
}),
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
|
|
})
|
|
)
|
|
|
|
|
|
return {
|
|
doSendRate,
|
|
...rest,
|
|
}
|
|
}
|
|
|
|
export default useSendRate
|