diff --git a/components/steam-reviews.tsx b/components/steam-reviews.tsx index e82a057..d601916 100644 --- a/components/steam-reviews.tsx +++ b/components/steam-reviews.tsx @@ -91,9 +91,11 @@ export function SteamReviews({ gameId, steamAppId, className }: SteamReviewsProp if (!data?.query_summary) return null; const { query_summary: summary } = data; + const totalReviews = summary.total_reviews ?? 0; + const totalPositive = summary.total_positive ?? 0; const positivePercent = - summary.total_reviews > 0 - ? Math.round((summary.total_positive / summary.total_reviews) * 100) + totalReviews > 0 + ? Math.round((totalPositive / totalReviews) * 100) : 0; return ( @@ -103,7 +105,7 @@ export function SteamReviews({ gameId, steamAppId, className }: SteamReviewsProp

Steam Reviews

- {summary.review_score_desc} — {positivePercent}% positive ({summary.total_reviews.toLocaleString()} reviews) + {summary.review_score_desc ?? "No reviews"} — {positivePercent}% positive ({totalReviews.toLocaleString()} reviews)

- {data.reviews.map((review) => ( + {(data.reviews ?? []).map((review) => (
- {Math.floor(review.author.playtime_forever / 60)}h played + {Math.floor((review.author?.playtime_forever ?? 0) / 60)}h played

{review.review}