// src/features/charts/TopDeals.tsx import React, { useMemo } from 'react'; import type { FlyerItem } from '../../types'; import { TrophyIcon } from '../../components/icons/TrophyIcon'; interface TopDealsProps { items: FlyerItem[]; } export const TopDeals: React.FC = ({ items }) => { const topDeals = useMemo(() => { // Use a type guard in the filter to inform TypeScript that price_in_cents is non-null // in subsequent operations. This allows removing the redundant nullish coalescing in sort. return [...items] .filter( (item): item is FlyerItem & { price_in_cents: number } => item.price_in_cents !== null, ) .sort((a, b) => a.price_in_cents - b.price_in_cents) .slice(0, 10); }, [items]); if (topDeals.length === 0) return null; return (

Top 10 Deals Across All Flyers

); };