Skip to content

Conversation

@pol2rd
Copy link

@pol2rd pol2rd commented Dec 24, 2025

couldn't find Details.tsx


const DropDownFilter: React.FC<DropDownFilterProps> = ({ onClick, isOpen, filterByGenre, genre }) => {
const categories: Category[] = [
export const categories: Category[] = [
Copy link

@nadav-cohen11 nadav-cohen11 Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Exporting categories: You exported categories, which is good for reusability. However, keep in mind:

    1.1. If categories is only used in this component, exporting might introduce dead code elsewhere.
    1.2. If it is reused (as we see in Card), this solution is appropriate. Consider adding a comment or utility
    folder structure for constants (like categories).

  2. Performance Optimization: The categories array is recreated on every render, which is unnecessary. Instead:

You can define it as a const outside the component to ensure it's only created once.

export const categories: Category[] = [...]; // Move outside the function.

<p><strong>Category: </strong></p>
<p><strong>{`Price: ${props.product.price}`}</strong></p>
<p><strong>{`Rating: ${props.product.rating.rate}/${maxRatings} (${props.product.rating.count} Reviews)`}</strong></p>
<p><strong>{`Category: ${categories.find((category) => category.id == props.product.category)?.name}`}</strong></p>
Copy link

@nadav-cohen11 nadav-cohen11 Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accessing categories:

Good use of categories.find. However, watch out for cases where find might return undefined. To make it more robust, provide a fallback value:

const categoryName = categories.find(category => category.id == props.product.category)?.name || 'Unknown Category';


const Card: React.FC<CardProps> = () => {
const Card: React.FC<CardProps> = (props: CardProps) => {
const maxRatings = 5
Copy link

@nadav-cohen11 nadav-cohen11 Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic Numbers (maxRatings):

Use constants or make the logic more descriptive.
const MAX_RATINGS = 5;

<div className='product scale-effect'>
<div className='product-image'>
<img />
<img src={props.product.image}/>
Copy link

@nadav-cohen11 nadav-cohen11 Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error Handling for Loading Image:

props.product.image is used directly. If the image URL fails, it might display a broken image. Add an onError:

<img src={props.product.image} alt={props.product.title} onError={(e) => (e.target.src = '/placeholder.png')} />

}

const Card: React.FC<CardProps> = () => {
const Card: React.FC<CardProps> = (props: CardProps) => {
Copy link

@nadav-cohen11 nadav-cohen11 Dec 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Destructure Props:

Destructure props to improve readability:

const { product } = props;

Copy link

@nadav-cohen11 nadav-cohen11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job on adding more functionality:

Loading data from the fakestoreapi with axios.
Creating reusable categories.
Making the Card component dynamic by adding props.
Attention to detail is important:

Properly componentized and streamlined logic for filtering products.

Nice work cleaning up TODO comments.

Please fix the comments that i wrote you and open the pull request again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants