import React from 'react';
import { useNavigate } from 'react-router-dom';
import type { FoodItem } from '../types';
import { useCart } from '../contexts/CartContext';
import { Star } from 'lucide-react';
import './ItemCard.css';
interface ItemCardProps {
item: FoodItem;
isLast?: boolean;
variant?: 'carousel' | 'list';
}
export const VegNonVegIcon: React.FC<{ isVeg: boolean }> = ({ isVeg }) => {
return (
);
};
const ItemCard: React.FC = ({ item, isLast, variant = 'list' }) => {
const navigate = useNavigate();
const { addToCart, updateQuantity, getItemQuantity } = useCart();
const quantity = getItemQuantity(item.id);
const isLimitReached = item.stock !== undefined && quantity >= item.stock && item.stock > 0;
// Visual helper values matching mockup metadata
const rating = item.rating !== undefined ? item.rating : 5.0;
const ratingCount = item.ratingCount !== undefined ? item.ratingCount : 0;
if (variant === 'carousel') {
return (
navigate(`/item/${item.id}`)}
>
{ratingCount > 0 && (
{rating.toFixed(1)}
)}
{item.image ? (

) : (
🍲
)}
{item.name}
{item.stallName || 'Unknown Stall'}
e.stopPropagation()}>
🅡{item.price.toFixed(2)}
{quantity === 0 ? (
) : (
{quantity}
)}
);
}
// default 'list' layout
return (
navigate(`/item/${item.id}`)}
>
e.stopPropagation()}>
{item.image ? (

) : (
🍲
)}
{item.isPopular &&
Bestseller}
{item.stock === 0 &&
Sold Out}
{item.name}
{ratingCount > 0 && (
{rating.toFixed(1)} ({ratingCount})
)}
{item.stallName || 'Unknown Stall'}
e.stopPropagation()}>
🅡{item.price.toFixed(2)}
{quantity === 0 ? (
) : (
{quantity}
)}
);
};
export default ItemCard;