porridger/front/src/hooks/api/useSendRate.ts
dm1sh d9925647c6
Refactored Rating component
Separated annDetails, added to userPage, made actually operating
2023-08-08 19:26:37 +03:00

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