Added users rating in announcement details
This commit is contained in:
@@ -9,3 +9,5 @@ export { default as useSignIn } from './useSignIn'
|
||||
export { default as useSignUp } from './useSignUp'
|
||||
export { default as usePoetry } from './usePoetry'
|
||||
export { default as useDispose } from './useDispose'
|
||||
export { default as useSendRate } from './useSendRate'
|
||||
export { default as useUserRating } from './useUserRating'
|
||||
|
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
|
30
front/src/hooks/api/useUserRating.ts
Normal file
30
front/src/hooks/api/useUserRating.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { composeUserRatingURL, initialUserRating, processUserRating } from '../../api/userRating'
|
||||
import { UserRating, isUserRatingResponse } from '../../api/userRating/types'
|
||||
import useFetch, { UseFetchReturn } from '../useFetch'
|
||||
|
||||
const useUserRating = (userId: number): UseFetchReturn<UserRating> => (
|
||||
// useFetch(
|
||||
// composeUserRatingURL(userId),
|
||||
// 'GET',
|
||||
// false,
|
||||
// isUserRatingResponse,
|
||||
// processUserRating,
|
||||
// initialUserRating
|
||||
// )
|
||||
|
||||
{
|
||||
data: 3,
|
||||
loading: false,
|
||||
error: null,
|
||||
refetch: () => { return },
|
||||
}
|
||||
|
||||
// {
|
||||
// data: undefined,
|
||||
// loading: true,
|
||||
// error: null,
|
||||
// refetch: () => { return },
|
||||
// }
|
||||
)
|
||||
|
||||
export default useUserRating
|
Reference in New Issue
Block a user