forked from Transparency/kgroad-frontend2
Fixing bug with comments/reviews
This commit is contained in:
parent
67b935b47f
commit
566c4d4473
@ -12,7 +12,3 @@ export interface IReview {
|
||||
review: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface IReviewList extends IList {
|
||||
results: IReview[];
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import "./ReviewSection.scss";
|
||||
import { apiInstance } from "@/shared/config/apiConfig";
|
||||
import { IReviewList } from "@/shared/types/review-type";
|
||||
import { IReview } from "@/shared/types/review-type";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useEffect, useState } from "react";
|
||||
import calendar from "./icons/calendar.svg";
|
||||
@ -17,7 +17,7 @@ const ReviewSection: React.FC<IReviewsSectionProps> = ({
|
||||
endpoint,
|
||||
id,
|
||||
}: IReviewsSectionProps) => {
|
||||
const [reviews, setReviews] = useState<IReviewList>();
|
||||
const [reviews, setReviews] = useState<IReview[]>();
|
||||
const session = useSession();
|
||||
const handleSubmit: React.MouseEventHandler<
|
||||
HTMLFormElement
|
||||
@ -52,11 +52,10 @@ const ReviewSection: React.FC<IReviewsSectionProps> = ({
|
||||
};
|
||||
|
||||
const getReviews = async () => {
|
||||
const response = await apiInstance.get<IReviewList>(
|
||||
const response = await apiInstance.get<IReview[]>(
|
||||
`/${endpoint}/${id}/reviews/`
|
||||
);
|
||||
|
||||
setReviews(response.data);
|
||||
setReviews(response?.data);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@ -94,7 +93,7 @@ const ReviewSection: React.FC<IReviewsSectionProps> = ({
|
||||
</h3>
|
||||
|
||||
<ul>
|
||||
{reviews?.results.map((review) => (
|
||||
{reviews?.map((review) => (
|
||||
<li key={review.id} className="review">
|
||||
<div className="review__author">
|
||||
<img
|
||||
|
Loading…
Reference in New Issue
Block a user