Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pages/dashboard/reviews/product-details/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const UserReview = () => {
//* Added page variable and current page state also added isLoading state to hide page change
const [currentPage, setCurrentPage] = useState<number>(1);

const [data, setData] = useState<ReviewData[] | null>(null);
const [data, setData] = useState<ReviewData[] | null>([]);
const [rats, setRats] = useState<RatsData>();
const [filterRating, setFilterRating] = useState<string>('all');
const [filterView, setFilterView] = useState<string>('topReviews');
Expand Down Expand Up @@ -70,15 +70,15 @@ const UserReview = () => {
}&pageSize=10`;
fetch(url)
.then((res) => res.json())
.then((data: ReviewApiResponse) => setData(data.data))
.then((data) => setData(data.data.items))
.catch((e) => console.log(e));
} else {
const url: string = `https://team-liquid-repo.onrender.com/api/review/shop/products/1/reviews/rating?rating=${filterRating}&pageNumber=${
const url: string = `https://team-liquid-repo.onrender.com/api/review/shop/products/${id}/reviews/rating?rating=${filterRating}&pageNumber=${
currentPage - 1
}&pageSize=10`;
fetch(url)
.then((res) => res.json())
.then((data: ReviewApiResponse) => setData(data.data))
.then((data) => setData(data.data.items))
.catch((e) => console.log(e));
}
}, [mountUI, filterRating, filterView, currentPage, id]);
Expand Down Expand Up @@ -154,7 +154,7 @@ const UserReview = () => {
<div className=" h-[70vh] flex justify-center items-center">
<Loader />
</div>
) : data === null || data.length === 0 ? (
) : data === null ? (
<EmptyReviewPage />
) : (
<div className="flex flex-col justify-center items-center md:mb-16">
Expand Down