[d7b7f00] | 1 | import React from 'react';
|
---|
| 2 | import { useNavigate } from 'react-router-dom';
|
---|
| 3 | import { FaStar } from 'react-icons/fa';
|
---|
| 4 | import styles from '../../css/ProfileCss/myReviews.module.css';
|
---|
| 5 |
|
---|
| 6 | const ReviewCard = ({ imageURL, rating, reviewText, recipeName, recipeId, isUserReview }) => {
|
---|
| 7 | const navigate = useNavigate();
|
---|
| 8 | const handleCardClick = () => {
|
---|
| 9 | navigate(`/recipes/${recipeId}`, {
|
---|
| 10 | state: { fromMyReviews: true }
|
---|
| 11 | });
|
---|
| 12 | };
|
---|
| 13 |
|
---|
| 14 | const renderStars = () => {
|
---|
| 15 | return (
|
---|
| 16 | <div className={styles.starRating}>
|
---|
| 17 | {[...Array(5)].map((_, index) => (
|
---|
| 18 | <FaStar
|
---|
| 19 | key={index}
|
---|
| 20 | className={styles.star}
|
---|
| 21 | color={index < rating ? "#FFA550" : "#ccc"}
|
---|
| 22 | />
|
---|
| 23 | ))}
|
---|
| 24 | </div>
|
---|
| 25 | );
|
---|
| 26 | };
|
---|
| 27 |
|
---|
| 28 | return (
|
---|
| 29 | <div className={styles.cardContainer} onClick={handleCardClick}>
|
---|
| 30 | <div className={styles.imgContainer}>
|
---|
| 31 | <img
|
---|
| 32 | alt={recipeName}
|
---|
| 33 | src={imageURL}
|
---|
| 34 | className={styles.img}
|
---|
| 35 | />
|
---|
| 36 | </div>
|
---|
| 37 | <div className={styles.contentContainer}>
|
---|
| 38 | <div className={styles.textSection}>
|
---|
| 39 | <h3 className={styles.recipeName}>{recipeName}</h3>
|
---|
| 40 | {isUserReview && <span className={styles.userReviewIndicator}>Your Review:</span>}
|
---|
| 41 | <p className={styles.reviewText}>{reviewText || "No review provided."}</p>
|
---|
| 42 | </div>
|
---|
| 43 | <div className={styles.ratingSection}>
|
---|
| 44 | {renderStars()}
|
---|
| 45 | </div>
|
---|
| 46 | </div>
|
---|
| 47 | </div>
|
---|
| 48 | );
|
---|
| 49 | };
|
---|
| 50 |
|
---|
| 51 | export default ReviewCard;
|
---|