porridger/front/src/hooks/api/useSendRate.ts
2023-08-15 23:33:58 +03:00

35 lines
730 B
TypeScript

import useSend from '../useSend'
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, user_id: number) => (
doSend({}, {
body: JSON.stringify({
rate,
user_id,
}),
headers: {
'Content-Type': 'application/json',
},
})
)
return {
doSendRate,
...rest,
}
}
export default useSendRate