Added users rating in announcement details
This commit is contained in:
33
front/src/hooks/api/useSendRate.ts
Normal file
33
front/src/hooks/api/useSendRate.ts
Normal file
@ -0,0 +1,33 @@
|
||||
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
|
Reference in New Issue
Block a user