Skip to content

Commit

Permalink
fixed showing reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
dudchakk committed Dec 4, 2024
1 parent 1b90e71 commit 5ecbd02
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { MockResponseItem } from '~/containers/user-profile/comments-block/CommentsBlock'

export const defaultReviewsResponse = {
count: 0,
reviews: []
}

export interface MockReview extends MockResponseItem {
_id: string
comment: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { styles } from '~/containers/user-profile/comments-with-rating-block/Com
import { ReviewService } from '~/services/review-service'
import { useAppSelector } from '~/hooks/use-redux'
import useAxios from '~/hooks/use-axios'
import { defaultResponses } from '~/constants'
import { defaultReviewsResponse } from '~/containers/user-profile/comments-with-rating-block/CommentsWithRatingBlock.constants'

interface CommentsWithRatingBlockProps {
averageRating: number
Expand Down Expand Up @@ -47,7 +47,7 @@ const CommentsWithRatingBlock = ({

const { response, loading } = useAxios<ReviewsResponse>({
service: getReviews,
defaultResponse: defaultResponses.itemsWithCount
defaultResponse: defaultReviewsResponse
})

const titleKey =
Expand Down Expand Up @@ -78,7 +78,9 @@ const CommentsWithRatingBlock = ({
</MenuItem>
))

const filteredItems = response.items.filter(
console.log(response)

const filteredItems = response.reviews.filter(
(item) => filter === null || item.rating === filter
)

Expand Down
2 changes: 1 addition & 1 deletion src/types/reviews/interfaces/reviews.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface ReviewResponse extends Omit<ReviewData, 'offer'> {

export interface ReviewsResponse {
count: number
items: ReviewResponse[]
reviews: ReviewResponse[]
}

export interface GetReviewsParams {
Expand Down

0 comments on commit 5ecbd02

Please sign in to comment.