Added users rating in announcement details

This commit is contained in:
2023-08-07 14:08:51 +03:00
parent b93ab9794d
commit d2a3393a11
11 changed files with 231 additions and 5 deletions

View File

@ -0,0 +1,12 @@
import { API_URL } from '../../config'
import { SendRateResponse, SendRate } from './types'
const composeSendRateURL = () => (
API_URL + '/user/rating?'
)
const processSendRate = (data: SendRateResponse): SendRate => {
return data.Success
}
export { composeSendRateURL, processSendRate }

View File

@ -0,0 +1,17 @@
import { isObject } from '../../utils/types'
type SendRateResponse = {
Success: boolean
}
const isSendRateResponse = (obj: unknown): obj is SendRateResponse => (
isObject(obj, {
'Success': 'boolean',
})
)
type SendRate = boolean
export type { SendRateResponse, SendRate }
export { isSendRateResponse }

View File

@ -0,0 +1,14 @@
import { API_URL } from '../../config'
import { UserRatingResponse, UserRating } from './types'
const initialUserRating: UserRating = 0
const composeUserRatingURL = (userId: number) => (
API_URL + '/user/rating?' + (new URLSearchParams({ user_id: userId.toString() })).toString()
)
const processUserRating = (data: UserRatingResponse): UserRating => {
return data.rating
}
export { initialUserRating, composeUserRatingURL, processUserRating }

View File

@ -0,0 +1,17 @@
import { isObject } from '../../utils/types'
type UserRatingResponse = {
rating: number
}
const isUserRatingResponse = (obj: unknown): obj is UserRatingResponse => (
isObject(obj, {
'rating': 'number',
})
)
type UserRating = number
export type { UserRatingResponse, UserRating }
export { isUserRatingResponse }